> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/opencode-ai/opencode/llms.txt
> Use this file to discover all available pages before exploring further.

# AI models

> Supported AI models and providers in OpenCode

## 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):

<CardGroup cols={2}>
  <Card title="GitHub Copilot" icon="github">
    Access multiple models through your GitHub Copilot subscription at no additional cost
  </Card>

  <Card title="Anthropic" icon="brain">
    Claude models with extended thinking and large context windows
  </Card>

  <Card title="OpenAI" icon="openai">
    GPT and o-series models with reasoning capabilities
  </Card>

  <Card title="Google Gemini" icon="google">
    Gemini models with massive context windows
  </Card>

  <Card title="Groq" icon="bolt">
    Fast inference for Llama and other open models
  </Card>

  <Card title="OpenRouter" icon="route">
    Unified access to multiple providers
  </Card>

  <Card title="AWS Bedrock" icon="aws">
    Claude and other models on AWS infrastructure
  </Card>

  <Card title="Azure OpenAI" icon="microsoft">
    OpenAI models through Azure with enterprise features
  </Card>

  <Card title="Google Cloud Vertex AI" icon="cloud">
    Gemini models on Google Cloud Platform
  </Card>
</CardGroup>

## GitHub Copilot models

<Note>
  GitHub Copilot models are **free** with a GitHub Copilot subscription and automatically detected from your GitHub CLI credentials.
</Note>

### Authentication

OpenCode automatically detects GitHub Copilot credentials from:

* GitHub CLI configuration (`~/.config/github-copilot/hosts.json`)
* Environment variable: `GITHUB_TOKEN`

### Available models

| Model ID                    | Name              | Context Window | Max Tokens | Reasoning |
| --------------------------- | ----------------- | -------------- | ---------- | --------- |
| `copilot.gpt-4o`            | GPT-4o            | 128K           | 16K        | ✗         |
| `copilot.gpt-4o-mini`       | GPT-4o Mini       | 128K           | 4K         | ✗         |
| `copilot.gpt-4.1`           | GPT-4.1           | 128K           | 16K        | ✓         |
| `copilot.claude-3.5-sonnet` | Claude 3.5 Sonnet | 90K            | 8K         | ✗         |
| `copilot.claude-3.7-sonnet` | Claude 3.7 Sonnet | 200K           | 16K        | ✗         |
| `copilot.claude-sonnet-4`   | Claude Sonnet 4   | 128K           | 16K        | ✗         |
| `copilot.o1`                | OpenAI o1         | 200K           | 100K       | ✓         |
| `copilot.o3-mini`           | OpenAI o3-mini    | 200K           | 100K       | ✓         |
| `copilot.o4-mini`           | OpenAI o4-mini    | 128K           | 16K        | ✓         |
| `copilot.gemini-2.0-flash`  | Gemini 2.0 Flash  | 1M             | 8K         | ✗         |
| `copilot.gemini-2.5-pro`    | Gemini 2.5 Pro    | 128K           | 64K        | ✗         |

## Anthropic (Claude)

### Authentication

```bash theme={null}
export ANTHROPIC_API_KEY="sk-ant-..."
```

Or in `.opencode.json`:

```json theme={null}
{
  "providers": {
    "anthropic": {
      "apiKey": "sk-ant-..."
    }
  }
}
```

### Available models

| Model ID            | Name              | Context Window | Max Tokens | Cost (per 1M tokens) | Reasoning |
| ------------------- | ----------------- | -------------- | ---------- | -------------------- | --------- |
| `claude-4-sonnet`   | Claude 4 Sonnet   | 200K           | 50K        | $3.00 / $15.00       | ✓         |
| `claude-4-opus`     | Claude 4 Opus     | 200K           | 4K         | $15.00 / $75.00      | ✗         |
| `claude-3.7-sonnet` | Claude 3.7 Sonnet | 200K           | 50K        | $3.00 / $15.00       | ✓         |
| `claude-3.5-sonnet` | Claude 3.5 Sonnet | 200K           | 5K         | $3.00 / $15.00       | ✗         |
| `claude-3.5-haiku`  | Claude 3.5 Haiku  | 200K           | 4K         | $0.80 / $4.00        | ✗         |
| `claude-3-opus`     | Claude 3 Opus     | 200K           | 4K         | $15.00 / $75.00      | ✗         |
| `claude-3-haiku`    | Claude 3 Haiku    | 200K           | 4K         | $0.25 / $1.25        | ✗         |

<Tip>
  Claude models support **extended thinking** mode via `reasoningEffort` parameter (`low`, `medium`, `high`).
</Tip>

## OpenAI

### Authentication

```bash theme={null}
export OPENAI_API_KEY="sk-..."
```

Or in `.opencode.json`:

```json theme={null}
{
  "providers": {
    "openai": {
      "apiKey": "sk-..."
    }
  }
}
```

### Available models

| Model ID          | Name            | Context Window | Max Tokens | Cost (per 1M tokens) | Reasoning |
| ----------------- | --------------- | -------------- | ---------- | -------------------- | --------- |
| `gpt-4.1`         | GPT-4.1         | 1M             | 20K        | $2.00 / $8.00        | ✗         |
| `gpt-4.1-mini`    | GPT-4.1 Mini    | 200K           | 20K        | $0.40 / $1.60        | ✗         |
| `gpt-4.1-nano`    | GPT-4.1 Nano    | 1M             | 20K        | $0.10 / $0.40        | ✗         |
| `gpt-4.5-preview` | GPT-4.5 Preview | 128K           | 15K        | $75.00 / $150.00     | ✗         |
| `gpt-4o`          | GPT-4o          | 128K           | 4K         | $2.50 / $10.00       | ✗         |
| `gpt-4o-mini`     | GPT-4o Mini     | 128K           | —          | $0.15 / $0.60        | ✗         |
| `o1`              | O1              | 200K           | 50K        | $15.00 / $60.00      | ✓         |
| `o1-pro`          | O1 Pro          | 200K           | 50K        | $150.00 / $600.00    | ✓         |
| `o1-mini`         | O1 Mini         | 128K           | 50K        | $1.10 / $4.40        | ✓         |
| `o3`              | O3              | 200K           | —          | $10.00 / $40.00      | ✓         |
| `o3-mini`         | O3 Mini         | 200K           | 50K        | $1.10 / $4.40        | ✓         |
| `o4-mini`         | O4 Mini         | 128K           | 50K        | $1.10 / $4.40        | ✓         |

<Tip>
  OpenAI reasoning models (o-series) support `reasoningEffort` parameter for controlling inference time.
</Tip>

## Google Gemini

### Authentication

```bash theme={null}
export GEMINI_API_KEY="..."
```

Or in `.opencode.json`:

```json theme={null}
{
  "providers": {
    "gemini": {
      "apiKey": "..."
    }
  }
}
```

### Available models

| Model ID                | Name                  | Context Window | Max Tokens | Cost (per 1M tokens) |
| ----------------------- | --------------------- | -------------- | ---------- | -------------------- |
| `gemini-2.5`            | Gemini 2.5 Pro        | 1M             | 50K        | $1.25 / $10.00       |
| `gemini-2.5-flash`      | Gemini 2.5 Flash      | 1M             | 50K        | $0.15 / $0.60        |
| `gemini-2.0-flash`      | Gemini 2.0 Flash      | 1M             | 6K         | $0.10 / $0.40        |
| `gemini-2.0-flash-lite` | Gemini 2.0 Flash Lite | 1M             | 6K         | $0.05 / $0.30        |

## Groq

### Authentication

```bash theme={null}
export GROQ_API_KEY="gsk_..."
```

Or in `.opencode.json`:

```json theme={null}
{
  "providers": {
    "groq": {
      "apiKey": "gsk_..."
    }
  }
}
```

### Available models

| Model ID                                        | Name                | Context Window | Max Tokens | Cost (per 1M tokens) | Reasoning |
| ----------------------------------------------- | ------------------- | -------------- | ---------- | -------------------- | --------- |
| `qwen-qwq`                                      | Qwen QwQ            | 128K           | 50K        | $0.29 / $0.39        | ✗         |
| `llama-3.3-70b-versatile`                       | Llama 3.3 70B       | 128K           | —          | $0.59 / $0.79        | ✗         |
| `meta-llama/llama-4-scout-17b-16e-instruct`     | Llama 4 Scout       | 128K           | —          | $0.11 / $0.34        | ✗         |
| `meta-llama/llama-4-maverick-17b-128e-instruct` | Llama 4 Maverick    | 128K           | —          | $0.20 / $0.20        | ✗         |
| `deepseek-r1-distill-llama-70b`                 | DeepSeek R1 Distill | 128K           | —          | $0.75 / $0.99        | ✓         |

## OpenRouter

### Authentication

```bash theme={null}
export OPENROUTER_API_KEY="sk-or-..."
```

Or in `.opencode.json`:

```json theme={null}
{
  "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)

<Info>
  See [OpenRouter pricing](https://openrouter.ai/models) for current rates.
</Info>

## AWS Bedrock

### Authentication

Bedrock uses standard AWS credentials:

```bash theme={null}
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 ID                    | Name              | Context Window | Cost (per 1M tokens) | Reasoning |
| --------------------------- | ----------------- | -------------- | -------------------- | --------- |
| `bedrock.claude-3.7-sonnet` | Claude 3.7 Sonnet | —              | $3.00 / $15.00       | ✗         |

## Azure OpenAI

### Authentication

```bash theme={null}
export AZURE_OPENAI_ENDPOINT="https://....openai.azure.com/"
export AZURE_OPENAI_API_KEY="..."  # Optional with Entra ID auth
```

Or in `.opencode.json`:

```json theme={null}
{
  "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`

<Note>
  Pricing matches OpenAI's rates. See [Azure OpenAI pricing](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/).
</Note>

## Google Cloud Vertex AI

### Authentication

```bash theme={null}
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 ID                    | Name             | Context Window | Max Tokens |
| --------------------------- | ---------------- | -------------- | ---------- |
| `vertexai.gemini-2.5`       | Gemini 2.5 Pro   | 1M             | 50K        |
| `vertexai.gemini-2.5-flash` | Gemini 2.5 Flash | 1M             | 50K        |

## xAI (Grok)

### Authentication

```bash theme={null}
export XAI_API_KEY="..."
```

### Available models

| Model ID                | Name                  | Context Window | Max Tokens | Cost (per 1M tokens) |
| ----------------------- | --------------------- | -------------- | ---------- | -------------------- |
| `grok-3-beta`           | Grok 3 Beta           | 131K           | 20K        | $3.00 / $15.00       |
| `grok-3-mini-beta`      | Grok 3 Mini Beta      | 131K           | 20K        | $0.30 / $0.50        |
| `grok-3-fast-beta`      | Grok 3 Fast Beta      | 131K           | 20K        | $5.00 / $25.00       |
| `grok-3-mini-fast-beta` | Grok 3 Mini Fast Beta | 131K           | 20K        | $0.60 / $4.00        |

## Choosing the right model

### For coding (coder agent)

<Tabs>
  <Tab title="Best quality">
    * `claude-4-sonnet` - Best overall for complex reasoning
    * `o1` or `o3` - Excellent for algorithmic challenges
    * `gpt-4.1` - Strong general coding capabilities
  </Tab>

  <Tab title="Balanced">
    * `claude-3.7-sonnet` - Great quality with extended thinking
    * `copilot.gpt-4.1` - Free with Copilot subscription
    * `gemini-2.5` - Large context window
  </Tab>

  <Tab title="Fast & affordable">
    * `gpt-4.1-mini` - Good quality, low cost
    * `claude-3.5-haiku` - Fast Anthropic model
    * `gemini-2.5-flash` - Large context, low cost
  </Tab>
</Tabs>

### 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`):

```json theme={null}
{
  "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

<Accordion title="Budget-conscious setup">
  ```json theme={null}
  {
    "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
</Accordion>

<Accordion title="GitHub Copilot (free)">
  ```json theme={null}
  {
    "agents": {
      "coder": {
        "model": "copilot.gpt-4.1"
      },
      "task": {
        "model": "copilot.gpt-4o-mini"
      }
    }
  }
  ```

  Cost: Included in GitHub Copilot subscription
</Accordion>

<Accordion title="Performance-optimized setup">
  ```json theme={null}
  {
    "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
</Accordion>

## Related topics

* [Configuration](/core-concepts/configuration) - Configure models and providers
* [Architecture](/core-concepts/architecture) - How OpenCode uses AI models internally
