Supported providers
OpenCode supports the following AI providers (in order of automatic detection priority):- GitHub Copilot - Free with GitHub Copilot subscription
- Anthropic - Claude models
- OpenAI - GPT models
- Google Gemini - Gemini models
- Groq - Fast inference for open-source models
- OpenRouter - Access to multiple models through one API
- AWS Bedrock - Claude models via AWS
- Azure OpenAI - OpenAI models via Azure
- Google Cloud VertexAI - Gemini models via Google Cloud
- xAI - Grok models
Anthropic
Provider for Claude models with industry-leading performance.Authentication
string
required
Your Anthropic API key. Get one at console.anthropic.com
Configuration
Supported models
Extended thinking models support the
reasoningEffort parameter for deeper analysis.OpenAI
Provider for GPT models including the reasoning-capable o-series.Authentication
string
required
Your OpenAI API key. Get one at platform.openai.com
Configuration
Supported models
Reasoning models (o-series) support the
reasoningEffort parameter: low, medium, or high.Google Gemini
Provider for Gemini models with large context windows.Authentication
string
required
Your Google AI Studio API key. Get one at aistudio.google.com
Configuration
Supported models
Groq
Provider for fast inference with open-source models.Authentication
string
required
Your Groq API key. Get one at console.groq.com
Configuration
Supported models
OpenRouter
Provider for accessing multiple models through a single API.Authentication
string
required
Your OpenRouter API key. Get one at openrouter.ai/keys
Configuration
Supported models
OpenRouter provides access to models from multiple providers. Prefix model IDs withopenrouter.:
openrouter.gpt-4.1,openrouter.gpt-4.1-mini,openrouter.gpt-4.1-nanoopenrouter.o1,openrouter.o1-mini,openrouter.o3,openrouter.o3-mini,openrouter.o4-miniopenrouter.claude-3.7-sonnet,openrouter.claude-3.5-sonnet,openrouter.claude-3.5-haikuopenrouter.gemini-2.5,openrouter.gemini-2.5-flashopenrouter.deepseek-r1-free- Free access to DeepSeek R1
Pricing matches the underlying provider. See OpenRouter’s model pricing for details.
AWS Bedrock
Provider for Claude models via AWS infrastructure.Authentication
Bedrock uses AWS credentials. OpenCode detects credentials in this order:AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYenvironment variablesAWS_PROFILEorAWS_DEFAULT_PROFILEenvironment variables- EC2 instance profiles or ECS task roles
string
default:"us-east-1"
AWS region for Bedrock (e.g.,
us-east-1, us-west-2)Configuration
Supported models
Bedrock models automatically disable prompt caching as it’s not supported in the Bedrock API.
Azure OpenAI
Provider for OpenAI models via Azure infrastructure.Authentication
Azure OpenAI supports two authentication methods: API Key authentication:string
required
Your Azure OpenAI endpoint (e.g.,
https://your-resource.openai.azure.com)string
Your Azure OpenAI API key (optional when using Entra ID)
string
default:"2025-04-01-preview"
Azure OpenAI API version
AZURE_OPENAI_API_KEY is not provided, OpenCode uses Azure’s DefaultAzureCredential for authentication.
Configuration
Supported models
Azure OpenAI supports the same models as OpenAI. Prefix model IDs withazure.:
azure.gpt-4.1,azure.gpt-4.1-mini,azure.gpt-4.1-nanoazure.gpt-4o,azure.gpt-4o-miniazure.o1,azure.o1-mini,azure.o3,azure.o3-mini,azure.o4-mini
Pricing is similar to OpenAI’s standard pricing but may vary by region.
Google Cloud VertexAI
Provider for Gemini models via Google Cloud infrastructure.Authentication
VertexAI uses Google Cloud credentials. OpenCode detects credentials when these environment variables are set:string
required
Your Google Cloud project ID
string
required
Google Cloud region (e.g.,
us-central1)GOOGLE_CLOUD_PROJECTandGOOGLE_CLOUD_REGION(orGOOGLE_CLOUD_LOCATION)
Configuration
Supported models
| Model ID | Name | Context Window | Default Max Tokens | |----------|------|----------------|--------------------|---| |vertexai.gemini-2.5 | Gemini 2.5 Pro | 1,000,000 | 50,000 |
| vertexai.gemini-2.5-flash | Gemini 2.5 Flash | 1,000,000 | 50,000 |
GitHub Copilot
Provider for models via GitHub Copilot subscription. Includes access to multiple models at no additional cost.Authentication
GitHub Copilot authentication is auto-detected from:GITHUB_TOKENenvironment variable- GitHub Copilot CLI configuration:
~/.config/github-copilot/hosts.json(Linux/macOS)~/.config/github-copilot/apps.json(Linux/macOS)%LOCALAPPDATA%\github-copilot\(Windows)
Configuration
Supported models
All models are included with GitHub Copilot subscription at $0 cost:GitHub Copilot provides the best value with access to multiple providers at no additional cost beyond the subscription.
xAI
Provider for Grok models.Authentication
string
required
Your xAI API key
Configuration
Supported models
| Model ID | Name | Context Window | Default Max Tokens | Cost (Input/Output per 1M tokens) | |----------|------|----------------|--------------------|------------------------------------|---| |grok-3-beta | Grok 3 Beta | 131,072 | 20,000 | 15.00 |
| grok-3-mini-beta | Grok 3 Mini Beta | 131,072 | 20,000 | 0.50 |
| grok-3-fast-beta | Grok 3 Fast Beta | 131,072 | 20,000 | 25.00 |
| grok-3-mini-fast-beta | Grok 3 Mini Fast Beta | 131,072 | 20,000 | 4.00 |
Default model selection
OpenCode automatically selects default models based on available providers in this priority order:- GitHub Copilot →
copilot.gpt-4o - Anthropic →
claude-4-sonnet - OpenAI →
gpt-4.1(coder),gpt-4.1-mini(task/title) - Gemini →
gemini-2.5(coder),gemini-2.5-flash(task/title) - Groq →
qwen-qwq - OpenRouter →
openrouter.claude-3.7-sonnet - xAI →
grok-3-beta - AWS Bedrock →
bedrock.claude-3.7-sonnet - Azure OpenAI →
azure.gpt-4.1 - VertexAI →
vertexai.gemini-2.5
You can override defaults by explicitly configuring the
agents section in your configuration file.