Skip to main content
OpenCode supports multiple AI providers, each with their own authentication methods and model offerings. This page documents all supported providers and their configuration requirements.

Supported providers

OpenCode supports the following AI providers (in order of automatic detection priority):
  1. GitHub Copilot - Free with GitHub Copilot subscription
  2. Anthropic - Claude models
  3. OpenAI - GPT models
  4. Google Gemini - Gemini models
  5. Groq - Fast inference for open-source models
  6. OpenRouter - Access to multiple models through one API
  7. AWS Bedrock - Claude models via AWS
  8. Azure OpenAI - OpenAI models via Azure
  9. Google Cloud VertexAI - Gemini models via Google Cloud
  10. 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 with openrouter.:
  • openrouter.gpt-4.1, openrouter.gpt-4.1-mini, openrouter.gpt-4.1-nano
  • openrouter.o1, openrouter.o1-mini, openrouter.o3, openrouter.o3-mini, openrouter.o4-mini
  • openrouter.claude-3.7-sonnet, openrouter.claude-3.5-sonnet, openrouter.claude-3.5-haiku
  • openrouter.gemini-2.5, openrouter.gemini-2.5-flash
  • openrouter.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:
  1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables
  2. AWS_PROFILE or AWS_DEFAULT_PROFILE environment variables
  3. 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
Entra ID authentication: If 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 with azure.:
  • azure.gpt-4.1, azure.gpt-4.1-mini, azure.gpt-4.1-nano
  • azure.gpt-4o, azure.gpt-4o-mini
  • azure.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)
Alternatively:
  • GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_REGION (or GOOGLE_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:
  1. GITHUB_TOKEN environment variable
  2. 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 | 3.00/3.00 / 15.00 | | grok-3-mini-beta | Grok 3 Mini Beta | 131,072 | 20,000 | 0.30/0.30 / 0.50 | | grok-3-fast-beta | Grok 3 Fast Beta | 131,072 | 20,000 | 5.00/5.00 / 25.00 | | grok-3-mini-fast-beta | Grok 3 Mini Fast Beta | 131,072 | 20,000 | 0.60/0.60 / 4.00 |

Default model selection

OpenCode automatically selects default models based on available providers in this priority order:
  1. GitHub Copilotcopilot.gpt-4o
  2. Anthropicclaude-4-sonnet
  3. OpenAIgpt-4.1 (coder), gpt-4.1-mini (task/title)
  4. Geminigemini-2.5 (coder), gemini-2.5-flash (task/title)
  5. Groqqwen-qwq
  6. OpenRouteropenrouter.claude-3.7-sonnet
  7. xAIgrok-3-beta
  8. AWS Bedrockbedrock.claude-3.7-sonnet
  9. Azure OpenAIazure.gpt-4.1
  10. VertexAIvertexai.gemini-2.5
You can override defaults by explicitly configuring the agents section in your configuration file.