Providers
OpenCode supports 75+ LLM providers through the AI SDK and Models.dev, enabling integration with numerous language model services and local models.
Setup Process
- Add API keys using the
/connectcommand - Configure the provider in your OpenCode config
- Credentials are stored in
~/.local/share/opencode/auth.json
Base URL Configuration
{
"$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.
- Run
/connect, select opencode - Visit opencode.ai/auth to authenticate
- Copy and paste your API key
- Use
/modelsto view recommended models
Popular Providers
Anthropic
- Run
/connectand select Anthropic - Choose Claude Pro/Max for browser authentication
- Access models via
/modelscommand
OpenAI
- Create API key at platform.openai.com/api-keys
- Run
/connectand search OpenAI - Enter API key
- Select model with
/models
OpenRouter
{
"provider": {
"openrouter": {
"models": {
"moonshotai/kimi-k2": {
"options": {
"provider": {
"order": ["baseten"],
"allow_fallbacks": false
}
}
}
}
}
}
}Ollama (Local)
{
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (local)",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"llama2": {
"name": "Llama 2"
}
}
}
}
}LM Studio (Local)
{
"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)"
}
}
}
}
}Amazon Bedrock
{
"provider": {
"amazon-bedrock": {
"options": {
"region": "us-east-1",
"profile": "my-aws-profile"
}
}
}
}Azure OpenAI
- Create Azure OpenAI resource in Azure portal
- Deploy model in Azure AI Foundry
- Run
/connectand search Azure - Set
AZURE_RESOURCE_NAMEenvironment variable
Custom Provider Setup
For OpenAI-compatible providers:
{
"provider": {
"myprovider": {
"npm": "@ai-sdk/openai-compatible",
"name": "My AI Provider",
"options": {
"baseURL": "https://api.myprovider.com/v1",
"apiKey": "{env:MY_API_KEY}"
},
"models": {
"my-model": {
"name": "My Model",
"limit": {
"context": 200000,
"output": 65536
}
}
}
}
}
}Troubleshooting
- Check authentication: Run
opencode auth listto verify credentials - Custom provider issues:
- Verify provider ID matches between
/connectand config - Confirm correct npm package
- Check API endpoint in
options.baseURL
- Verify provider ID matches between