Skip to main content

Overview

OpenCode supports multiple AI providers and models, allowing you to choose the best model for your use case and budget. You can configure different models for different agent types (coder, task, title).

Supported providers

OpenCode supports the following AI providers (in order of auto-configuration preference):

GitHub Copilot

Access multiple models through your GitHub Copilot subscription at no additional cost

Anthropic

Claude models with extended thinking and large context windows

OpenAI

GPT and o-series models with reasoning capabilities

Google Gemini

Gemini models with massive context windows

Groq

Fast inference for Llama and other open models

OpenRouter

Unified access to multiple providers

AWS Bedrock

Claude and other models on AWS infrastructure

Azure OpenAI

OpenAI models through Azure with enterprise features

Google Cloud Vertex AI

Gemini models on Google Cloud Platform

GitHub Copilot models

GitHub Copilot models are free with a GitHub Copilot subscription and automatically detected from your GitHub CLI credentials.

Authentication

OpenCode automatically detects GitHub Copilot credentials from:
  • GitHub CLI configuration (~/.config/github-copilot/hosts.json)
  • Environment variable: GITHUB_TOKEN

Available models

Model IDNameContext WindowMax TokensReasoning
copilot.gpt-4oGPT-4o128K16K
copilot.gpt-4o-miniGPT-4o Mini128K4K
copilot.gpt-4.1GPT-4.1128K16K
copilot.claude-3.5-sonnetClaude 3.5 Sonnet90K8K
copilot.claude-3.7-sonnetClaude 3.7 Sonnet200K16K
copilot.claude-sonnet-4Claude Sonnet 4128K16K
copilot.o1OpenAI o1200K100K
copilot.o3-miniOpenAI o3-mini200K100K
copilot.o4-miniOpenAI o4-mini128K16K
copilot.gemini-2.0-flashGemini 2.0 Flash1M8K
copilot.gemini-2.5-proGemini 2.5 Pro128K64K

Anthropic (Claude)

Authentication

export ANTHROPIC_API_KEY="sk-ant-..."
Or in .opencode.json:
{
  "providers": {
    "anthropic": {
      "apiKey": "sk-ant-..."
    }
  }
}

Available models

Model IDNameContext WindowMax TokensCost (per 1M tokens)Reasoning
claude-4-sonnetClaude 4 Sonnet200K50K3.00/3.00 / 15.00
claude-4-opusClaude 4 Opus200K4K15.00/15.00 / 75.00
claude-3.7-sonnetClaude 3.7 Sonnet200K50K3.00/3.00 / 15.00
claude-3.5-sonnetClaude 3.5 Sonnet200K5K3.00/3.00 / 15.00
claude-3.5-haikuClaude 3.5 Haiku200K4K0.80/0.80 / 4.00
claude-3-opusClaude 3 Opus200K4K15.00/15.00 / 75.00
claude-3-haikuClaude 3 Haiku200K4K0.25/0.25 / 1.25
Claude models support extended thinking mode via reasoningEffort parameter (low, medium, high).

OpenAI

Authentication

export OPENAI_API_KEY="sk-..."
Or in .opencode.json:
{
  "providers": {
    "openai": {
      "apiKey": "sk-..."
    }
  }
}

Available models

Model IDNameContext WindowMax TokensCost (per 1M tokens)Reasoning
gpt-4.1GPT-4.11M20K2.00/2.00 / 8.00
gpt-4.1-miniGPT-4.1 Mini200K20K0.40/0.40 / 1.60
gpt-4.1-nanoGPT-4.1 Nano1M20K0.10/0.10 / 0.40
gpt-4.5-previewGPT-4.5 Preview128K15K75.00/75.00 / 150.00
gpt-4oGPT-4o128K4K2.50/2.50 / 10.00
gpt-4o-miniGPT-4o Mini128K0.15/0.15 / 0.60
o1O1200K50K15.00/15.00 / 60.00
o1-proO1 Pro200K50K150.00/150.00 / 600.00
o1-miniO1 Mini128K50K1.10/1.10 / 4.40
o3O3200K10.00/10.00 / 40.00
o3-miniO3 Mini200K50K1.10/1.10 / 4.40
o4-miniO4 Mini128K50K1.10/1.10 / 4.40
OpenAI reasoning models (o-series) support reasoningEffort parameter for controlling inference time.

Google Gemini

Authentication

export GEMINI_API_KEY="..."
Or in .opencode.json:
{
  "providers": {
    "gemini": {
      "apiKey": "..."
    }
  }
}

Available models

Model IDNameContext WindowMax TokensCost (per 1M tokens)
gemini-2.5Gemini 2.5 Pro1M50K1.25/1.25 / 10.00
gemini-2.5-flashGemini 2.5 Flash1M50K0.15/0.15 / 0.60
gemini-2.0-flashGemini 2.0 Flash1M6K0.10/0.10 / 0.40
gemini-2.0-flash-liteGemini 2.0 Flash Lite1M6K0.05/0.05 / 0.30

Groq

Authentication

export GROQ_API_KEY="gsk_..."
Or in .opencode.json:
{
  "providers": {
    "groq": {
      "apiKey": "gsk_..."
    }
  }
}

Available models

Model IDNameContext WindowMax TokensCost (per 1M tokens)Reasoning
qwen-qwqQwen QwQ128K50K0.29/0.29 / 0.39
llama-3.3-70b-versatileLlama 3.3 70B128K0.59/0.59 / 0.79
meta-llama/llama-4-scout-17b-16e-instructLlama 4 Scout128K0.11/0.11 / 0.34
meta-llama/llama-4-maverick-17b-128e-instructLlama 4 Maverick128K0.20/0.20 / 0.20
deepseek-r1-distill-llama-70bDeepSeek R1 Distill128K0.75/0.75 / 0.99

OpenRouter

Authentication

export OPENROUTER_API_KEY="sk-or-..."
Or in .opencode.json:
{
  "providers": {
    "openrouter": {
      "apiKey": "sk-or-..."
    }
  }
}

Available models

OpenRouter provides access to models from multiple providers with unified billing: OpenAI models:
  • openrouter.gpt-4.1, openrouter.gpt-4.1-mini, openrouter.gpt-4.1-nano
  • openrouter.gpt-4.5-preview, openrouter.gpt-4o, openrouter.gpt-4o-mini
  • openrouter.o1, openrouter.o1-pro, openrouter.o1-mini
  • openrouter.o3, openrouter.o3-mini, openrouter.o4-mini
Anthropic models:
  • openrouter.claude-3.5-sonnet, openrouter.claude-3.7-sonnet
  • openrouter.claude-3.5-haiku, openrouter.claude-3-haiku
  • openrouter.claude-3-opus
Google models:
  • openrouter.gemini-2.5, openrouter.gemini-2.5-flash
Free models:
  • openrouter.deepseek-r1-free - Free DeepSeek R1 (163K context)
See OpenRouter pricing for current rates.

AWS Bedrock

Authentication

Bedrock uses standard AWS credentials:
export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_REGION="us-east-1"

# Or use AWS profile
export AWS_PROFILE="my-profile"

Available models

Model IDNameContext WindowCost (per 1M tokens)Reasoning
bedrock.claude-3.7-sonnetClaude 3.7 Sonnet3.00/3.00 / 15.00

Azure OpenAI

Authentication

export AZURE_OPENAI_ENDPOINT="https://....openai.azure.com/"
export AZURE_OPENAI_API_KEY="..."  # Optional with Entra ID auth
Or in .opencode.json:
{
  "providers": {
    "azure": {
      "apiKey": "..."
    }
  }
}

Available models

Azure OpenAI provides the same models as OpenAI with the azure. prefix:
  • azure.gpt-4.1, azure.gpt-4.1-mini, azure.gpt-4.1-nano
  • azure.gpt-4.5-preview, azure.gpt-4o, azure.gpt-4o-mini
  • azure.o1, azure.o1-mini
  • azure.o3, azure.o3-mini, azure.o4-mini
Pricing matches OpenAI’s rates. See Azure OpenAI pricing.

Google Cloud Vertex AI

Authentication

export VERTEXAI_PROJECT="my-project"
export VERTEXAI_LOCATION="us-central1"

# Or use standard Google Cloud env vars
export GOOGLE_CLOUD_PROJECT="my-project"
export GOOGLE_CLOUD_REGION="us-central1"

Available models

Model IDNameContext WindowMax Tokens
vertexai.gemini-2.5Gemini 2.5 Pro1M50K
vertexai.gemini-2.5-flashGemini 2.5 Flash1M50K

xAI (Grok)

Authentication

export XAI_API_KEY="..."

Available models

Model IDNameContext WindowMax TokensCost (per 1M tokens)
grok-3-betaGrok 3 Beta131K20K3.00/3.00 / 15.00
grok-3-mini-betaGrok 3 Mini Beta131K20K0.30/0.30 / 0.50
grok-3-fast-betaGrok 3 Fast Beta131K20K5.00/5.00 / 25.00
grok-3-mini-fast-betaGrok 3 Mini Fast Beta131K20K0.60/0.60 / 4.00

Choosing the right model

For coding (coder agent)

  • claude-4-sonnet - Best overall for complex reasoning
  • o1 or o3 - Excellent for algorithmic challenges
  • gpt-4.1 - Strong general coding capabilities

For code search (task agent)

Fast, cost-effective models work best:
  • gpt-4.1-mini
  • gpt-4o-mini
  • claude-3.5-haiku
  • gemini-2.5-flash

For titles (title agent)

Any fast model works (auto-configured, maxTokens=80):
  • gpt-4o-mini
  • claude-3.5-haiku
  • gemini-2.0-flash-lite

Model capabilities

Reasoning models

Models with extended thinking/reasoning capabilities:
  • OpenAI: o1, o1-pro, o1-mini, o3, o3-mini, o4-mini
  • Anthropic: claude-4-sonnet, claude-3.7-sonnet
  • Groq: deepseek-r1-distill-llama-70b
Configure with reasoningEffort (low, medium, high):
{
  "agents": {
    "coder": {
      "model": "o1",
      "reasoningEffort": "high"
    }
  }
}

File attachments

Most models support file attachments except:
  • o3-mini
  • llama-3.3-70b-versatile
  • Groq’s Qwen and DeepSeek models

Context windows

Largest context windows:
  1. 1M tokens: Gemini models, VertexAI Gemini
  2. 1M+ tokens: gpt-4.1, gpt-4.1-nano (1,047,576 tokens)
  3. 200K tokens: Claude models, OpenAI o-series, gpt-4.1-mini

Cost optimization

Prompt caching

Many models support prompt caching to reduce costs on repeated context:
  • Anthropic: All Claude models
  • OpenAI: GPT-4.1, o-series models
  • Gemini: Not yet supported

Strategy recommendations

{
  "agents": {
    "coder": {
      "model": "gpt-4.1-mini",
      "maxTokens": 5000
    },
    "task": {
      "model": "gpt-4o-mini",
      "maxTokens": 3000
    }
  }
}
Estimated cost: ~$0.50-2.00 per day of active use
{
  "agents": {
    "coder": {
      "model": "copilot.gpt-4.1"
    },
    "task": {
      "model": "copilot.gpt-4o-mini"
    }
  }
}
Cost: Included in GitHub Copilot subscription
{
  "agents": {
    "coder": {
      "model": "claude-4-sonnet",
      "maxTokens": 50000,
      "reasoningEffort": "high"
    },
    "task": {
      "model": "gpt-4.1-mini",
      "maxTokens": 5000
    }
  }
}
Estimated cost: ~$5-20 per day of active use

Build docs developers (and LLMs) love