What API does opencode support?
This post might have stale content, as HEAD is 921 commits ahead.
what api does it support?
OpenCode is designed to be provider-agnostic, supporting a wide range of AI models and protocols. Based on the source code and documentation, it supports the following APIs and integrations:
###1. LLM Provider APIs
OpenCode integrates with major AI providers, primarily using the Vercel AI SDK (@ai-sdk). Supported providers include:
- Anthropic: Full support for Claude models (Claude 3.5 Sonnet, Opus, Haiku, and upcoming versions).
- OpenAI: Support for GPT-4o, GPT-4, GPT-3.5, and reasoning models (o1, o3).
- Google: Support for Gemini models (1.5 Pro, 1.5 Flash) via both Google Generative AI and Vertex AI.
- Azure OpenAI: Dedicated support for Azure-hosted instances.
- AWS Bedrock: Support for models hosted on Bedrock (specifically Anthropic models).
- OpenAI-Compatible APIs: You can connect to any provider that follows the OpenAI API specification (e.g., DeepSeek, Groq, Perplexity) or local servers like Ollama, LM Studio, and vLLM.
###2. OpenCode Zen
OpenCode provides its own curated gateway called OpenCode Zen. It allows users to:
- Access a variety of models (Claude, GPT, Gemini, etc.) using a single API key.
- Benefit from optimized pricing and tested/verified model configurations specifically for coding tasks.
###3. Model Context Protocol (MCP)
OpenCode has extensive support for the Model Context Protocol (MCP), allowing you to extend the agent's capabilities with external tools:
- Local MCP Servers: Run tools locally via command execution (e.g.,
npx,python). - Remote MCP Servers: Connect to tools hosted via HTTPS.
- OAuth Support: Handles authentication for remote MCP servers that require it.
- Tool/Resource Integration: MCP tools and resources are automatically registered and available to the LLM.
###4. Developer & System APIs
- Language Server Protocol (LSP): Built-in support for LSPs to provide the agent with deep code intelligence (definitions, references, etc.).
- Internal REST API: The project follows a client/server architecture. The server (
opencode serve) exposes a comprehensive REST API (defined inpackages/sdk/openapi.json) for managing sessions, tools, MCP servers, and more. - Claude Code Compatibility: It supports conventions from Anthropic's Claude Code, such as
.claude/skillsandCLAUDE.mdconfiguration files.
###5. Other Gateways
The codebase also contains configurations for several other AI gateways:
- Cloudflare AI Gateway
- Vercel AI Gateway
- SAP AI Core
- GitLab Duo (via Anthropic proxy)
END OF POST