Providers
OpenCode uses the AI SDK and Models.dev to support 75+ LLM providers, including local models. This page covers how to connect providers and configure them.
Connecting a Provider
Use the /connect command inside the OpenCode TUI to add a provider:
/connectThis opens a provider selection list. Choose your provider, then:
- Authenticate (OAuth, API key, or subscription login)
- Paste your API key when prompted
- Run
/modelsto select a model
/modelsOpenCode Zen
Recommended for beginners. OpenCode Zen offers curated models that have been tested and verified by the OpenCode team.
- Run
/connectand select OpenCode Zen - Sign in at opencode.ai/auth and create an API key
- Paste your API key
- Run
/modelsto see recommended models
OpenCode Go
A low-cost subscription plan with reliable access to popular open coding models.
Popular Providers
Anthropic (Claude)
/connect
# Select "Anthropic"
# Choose "Claude Pro/Max" for subscription login, or "Manually enter API Key"After authentication, run /models to access all Claude models.
WARNING
Anthropic explicitly prohibits using Claude Pro/Max subscriptions through third-party plugins. Use official authentication methods only.
OpenAI (ChatGPT)
/connect
# Select "OpenAI"
# Choose "ChatGPT Plus/Pro" for subscription login, or "Manually enter API Key"We recommend signing up for ChatGPT Plus or Pro for the best experience.
GitHub Copilot
/connect
# Select "GitHub Copilot"
# Navigate to github.com/login/device and enter the code shownSome models may require a Pro+ subscription.
Google Vertex AI
Set environment variables:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
export GOOGLE_CLOUD_PROJECT=your-project-id
export VERTEX_LOCATION=global # optional, defaults to "global"Then run /connect and select Google Vertex AI.
Azure OpenAI
export AZURE_RESOURCE_NAME=your-resource-nameRun /connect, select Azure, enter your API key. The deployment name must match the model name.
Local Models
Ollama
Configure in 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 with Ollama, try increasing num_ctx to 16k–32k.
LM Studio
{
"$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)"
}
}
}
}
}llama.cpp
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"llama.cpp": {
"npm": "@ai-sdk/openai-compatible",
"name": "llama-server (local)",
"options": {
"baseURL": "http://127.0.0.1:8080/v1"
},
"models": {
"qwen3-coder:a3b": {
"name": "Qwen3-Coder: a3b-30b (local)",
"limit": {
"context": 128000,
"output": 65536
}
}
}
}
}
}Custom Provider
For any OpenAI-compatible provider not in the /connect list:
- Run
/connectand scroll to Other - Enter a unique provider ID (e.g.,
myprovider) - Enter your API key
- Add configuration to
opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"myprovider": {
"npm": "@ai-sdk/openai-compatible",
"name": "My Provider",
"options": {
"baseURL": "https://api.myprovider.com/v1"
},
"models": {
"my-model": {
"name": "My Model",
"limit": {
"context": 200000,
"output": 65536
}
}
}
}
}
}Key configuration fields:
| Field | Description |
|---|---|
npm | AI SDK package. Use @ai-sdk/openai-compatible for /v1/chat/completions, or @ai-sdk/openai for /v1/responses |
name | Display name in the UI |
options.baseURL | API endpoint URL |
options.apiKey | API key (use {env:VAR} syntax recommended) |
options.headers | Custom request headers |
models | Map of model IDs to their config |
models.*.limit.context | Max input tokens |
models.*.limit.output | Max output tokens |
Provider Management
Disable Providers
Prevent specific providers from loading:
{
"disabled_providers": ["openai", "gemini"]
}Enable Only Specific Providers
Restrict to an allowlist:
{
"enabled_providers": ["anthropic", "openai"]
}disabled_providers takes priority over enabled_providers.
Troubleshooting
- Check auth setup: Run
opencode auth listto verify credentials - Custom providers: Ensure the provider ID in
/connectmatches the ID in your config - Correct npm package: Use
@ai-sdk/openai-compatiblefor most providers,@ai-sdk/openaifor/v1/responsesendpoints - Base URL: Verify the API endpoint is correct