Providers
Providers
Using any LLM provider in OpenCode.
OpenCode uses the AI SDK and Models.dev to support 75+ LLM providers and it supports running local models.
To add a provider you need to:
- Add the API keys for the provider using the
/connectcommand. - Configure the provider in your OpenCode config.
Credentials
When you add a provider’s API keys with the /connect command, they are stored in ~/.local/share/opencode/auth.json.
Config
// Provider 配置基础格式
You can customize the providers through the provider section in your OpenCode config.
// 自定义 Base URL opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"anthropic": {
"options": {
"baseURL": "https://api.anthropic.com/v1"
}
}
}
}
OpenCode Zen
OpenCode Zen is a list of models provided by the OpenCode team that have been tested and verified to work well with OpenCode.
[!TIP] If you are new, we recommend starting with OpenCode Zen.
- Run the
/connectcommand in the TUI, selectOpenCode Zen, and head to opencode.ai/auth. - Sign in, add your billing details, and copy your API key.
- Paste your API key.
- Run
/modelsin the TUI to see the list of models we recommend.
OpenCode Go
OpenCode Go is a low cost subscription plan that provides reliable access to popular open coding models.
- Run the
/connectcommand in the TUI, selectOpenCode Go. - Sign in, add your billing details, and copy your API key.
- Paste your API key.
- Run
/modelsin the TUI to see the list of models.
Directory
Anthropic
- Run
/connectand select Anthropic. - Select Claude Pro/Max option or Manually enter API Key.
- Run
/modelsto see available models.
[!NOTE] Anthropic explicitly prohibits using Claude Pro/Max subscription with third-party tools. Previous versions of OpenCode bundled plugins for this but that is no longer the case as of 1.3.0.
OpenAI
- Run
/connectand select OpenAI. - Select ChatGPT Plus/Pro or Manually enter API Key.
- Run
/modelsto see available models.
Amazon Bedrock
// Amazon Bedrock 配置 To use Amazon Bedrock with OpenCode:
-
Request access to models in the Amazon Bedrock console.
-
Configure authentication:
Environment Variables:
# 使用 AWS Access Keys
AWS_ACCESS_KEY_ID=XXX AWS_SECRET_ACCESS_KEY=YYY opencode
# 使用 AWS Profile
AWS_PROFILE=my-profile opencode
# 使用 Bedrock Bearer Token
AWS_BEARER_TOKEN_BEDROCK=XXX opencode
Configuration File (Recommended): opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"amazon-bedrock": {
"options": {
"region": "us-east-1",
"profile": "my-aws-profile"
}
}
}
}
Available options:
region- AWS 区域(如us-east-1,eu-west-1)profile-~/.aws/credentials中的 AWS 命名配置文件endpoint- VPC 端点的自定义 URL(baseURL 的别名)
Azure OpenAI
- Create an Azure OpenAI resource in the Azure portal.
- Deploy a model in Azure AI Foundry.
- Run
/connectand search for Azure. - Enter your API key.
- Set your resource name as an environment variable:
AZURE_RESOURCE_NAME=XXX opencode
[!NOTE] If you encounter “I cannot assist with that request” errors, try changing the content filter from DefaultV2 to Default.
Google Vertex AI
- Enable Vertex AI API in your Google Cloud project.
- Set required environment variables:
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
GOOGLE_CLOUD_PROJECT=your-project-id
VERTEX_LOCATION=global
- Run
/modelsto select a model.
Ollama
// Ollama 本地模型配置 opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (local)",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"llama2": {
"name": "Llama 2"
}
}
}
}
}
[!TIP] If tool calls aren’t working, try increasing
num_ctxin Ollama. Start around 16k - 32k.
LM Studio
// LM Studio 本地模型配置 opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"lmstudio": {
"npm": "@ai-sdk/openai-compatible",
"name": "LM Studio (local)",
"options": {
"baseURL": "http://127.0.0.1:1234/v1"
},
"models": {
"google/gemma-3n-e4b": {
"name": "Gemma 3n-e4b (local)"
}
}
}
}
}
OpenRouter
- Create an API key in the OpenRouter dashboard.
- Run
/connectand search for OpenRouter. - Enter your API key.
- Run
/modelsto select a model.
{
"provider": {
"openrouter": {
"models": {
"somecoolnewmodel": {}
}
}
}
}
DeepSeek
- Create an account at DeepSeek console.
- Create a new API key.
- Run
/connectand search for DeepSeek. - Enter your API key.
- Run
/modelsto select a model like DeepSeek V4 Pro.
GitLab Duo
[!EXPERIMENTAL] GitLab Duo support in OpenCode is experimental.
OpenCode integrates with the GitLab Duo Agent Platform.
License requirements:
- Premium or Ultimate GitLab subscription
- Available on GitLab.com and GitLab Self-Managed
- Run
/connectand select GitLab. - Choose OAuth or Personal Access Token.
- Run
/modelsto see available models.
Three Claude-based models are available:
- duo-chat-haiku-4-5 (Default) - Fast responses
- duo-chat-sonnet-4-5 - Balanced performance
- duo-chat-opus-4-5 - Most capable
GitHub Copilot
- Run
/connectand search for GitHub Copilot. - Navigate to github.com/login/device and enter the code.
- Run
/modelsto select the model.
[!NOTE] Some models might need a Pro+ subscription.
Cloudflare AI Gateway
- Create a gateway in Cloudflare dashboard (AI > AI Gateway).
- Run
/connectand search for Cloudflare AI Gateway. - Enter Account ID, Gateway ID, and API token.
- Run
/modelsto select a model.
Hugging Face
- Create a token with inference.serverless.write permission.
- Run
/connectand search for Hugging Face. - Enter your token.
- Run
/modelsto select a model.
NVIDIA
NVIDIA provides access to Nemotron models and other open models through build.nvidia.com.
- Generate an API key at build.nvidia.com.
- Run
/connectand search for NVIDIA. - Enter your API key.
- Run
/modelsto select a model.
On-Prem / NIM:
{
"provider": {
"nvidia": {
"options": {
"baseURL": "http://localhost:8000/v1"
}
}
}
}
Groq
- Create an API key at Groq console.
- Run
/connectand search for Groq. - Enter the API key.
- Run
/modelsto select a model.
Cerebras
- Create an account at Cerebras console.
- Generate an API key.
- Run
/connectand search for Cerebras. - Run
/modelsto select a model like Qwen 3 Coder 480B.
Together AI
- Create an account at Together AI.
- Generate an API key.
- Run
/connectand search for Together AI. - Run
/modelsto select a model.
Fireworks AI
- Create an account at Fireworks AI console.
- Create an API key.
- Run
/connectand search for Fireworks AI. - Run
/modelsto select a model.
Cohere
- Create an account and get an API key from the Cohere dashboard.
- Run
/connectand search for Cohere. - Enter your API key.
- Run
/modelsto select a model.
Other Providers
OpenCode supports 75+ providers including:
- 302.AI
- Atomic Chat
- Azure Cognitive Services
- Baseten
- Cloudflare Workers AI
- Cortecs
- Deep Infra
- DigitalOcean
- FrogBot
- IO.NET
- MiniMax
- Moonshot AI
- Nebius Token Factory
- Ollama Cloud
- SAP AI Core
- Scaleway
- Venice AI
- Vercel AI Gateway
- xAI
- Z.AI
- ZenMux
Custom provider
// 自定义 Provider 配置示例 opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"custom-provider": {
"npm": "@ai-sdk/openai-compatible",
"name": "Custom Provider",
"options": {
"baseURL": "https://api.example.com/v1"
},
"models": {
"model-id": {
"name": "Custom Model Name"
}
}
}
}
}
Troubleshooting
Provider not loading
- Check if API key is set:
opencode debug config - Verify environment variables are set correctly
- Check if provider supports your region
Authentication errors
- Verify API key is correct
- Check if subscription is active
- Ensure required scopes are granted
Rate limits
Consider using:
- A proxy/gateway with rate limiting (Cloudflare AI Gateway, Helicone)
- Provider-specific rate limit configurations
- Multiple provider accounts