2025-05-21 18:59:09 +00:00
---
title: Models
2025-07-02 22:44:01 +00:00
description: Configuring an LLM provider and model.
2025-05-21 18:59:09 +00:00
---
2025-10-03 17:46:56 +00:00
OpenCode uses the [AI SDK](https://ai-sdk.dev/) and [Models.dev](https://models.dev) to support for **75+ LLM providers** and it supports running local models.
2025-05-21 18:59:09 +00:00
2025-06-19 20:26:58 +00:00
---
## Providers
2025-05-21 19:01:12 +00:00
2025-12-02 23:08:19 +00:00
Most popular providers are preloaded by default. If you've added the credentials for a provider through the `/connect` command, they'll be available when you start OpenCode.
2025-05-21 19:01:12 +00:00
2025-07-30 22:16:11 +00:00
Learn more about [providers](/docs/providers).
2025-06-19 20:26:58 +00:00
2025-07-10 17:49:24 +00:00
---
2025-07-30 22:16:11 +00:00
## Select a model
2025-07-15 18:57:50 +00:00
2025-07-30 22:16:11 +00:00
Once you've configured your provider you can select the model you want by typing in:
2025-07-15 18:57:50 +00:00
2025-07-30 22:16:11 +00:00
```bash frame="none"
/models
2025-07-15 18:57:50 +00:00
```
---
2025-07-30 22:16:11 +00:00
## Recommended models
2025-07-19 16:40:28 +00:00
2025-07-30 22:16:11 +00:00
There are a lot of models out there, with new models coming out every week.
2025-07-19 16:40:28 +00:00
2025-07-30 22:16:11 +00:00
:::tip
Consider using one of the models we recommend.
:::
2025-07-19 16:40:28 +00:00
2025-10-13 02:35:31 +00:00
However, there are only a few of them that are good at both generating code and tool calling.
2025-07-19 16:40:28 +00:00
2025-11-20 19:16:27 +00:00
Here are several models that work well with OpenCode, in no particular order. (This is not an exhaustive list):
2025-11-20 19:17:06 +00:00
2025-11-20 19:16:27 +00:00
- GPT 5.1
- GPT 5.1 Codex
2025-10-03 21:06:20 +00:00
- Claude Sonnet 4.5
2025-11-20 19:16:27 +00:00
- Claude Haiku 4.5
2025-07-30 22:16:11 +00:00
- Kimi K2
2025-11-20 19:16:27 +00:00
- GLM 4.6
2025-07-30 22:16:11 +00:00
- Qwen3 Coder
2025-11-20 19:16:27 +00:00
- Gemini 3 Pro
2025-07-19 16:40:28 +00:00
---
2025-07-30 22:16:11 +00:00
## Set a default
2025-06-19 20:26:58 +00:00
2025-07-30 22:16:11 +00:00
To set one of these as the default model, you can set the `model` key in your
2025-10-03 17:46:56 +00:00
OpenCode config.
2025-07-10 17:49:24 +00:00
```json title="opencode.json" {3}
{
"$schema": "https://opencode.ai/config.json",
"model": "lmstudio/google/gemma-3n-e4b"
}
```
2025-07-30 22:16:11 +00:00
Here the full ID is `provider_id/model_id`.
2025-06-19 20:26:58 +00:00
2025-07-30 22:16:11 +00:00
If you've configured a [custom provider](/docs/providers#custom), the `provider_id` is key from the `provider` part of your config, and the `model_id` is the key from `provider.models`.
2025-06-19 20:26:58 +00:00
---
2025-08-13 18:07:08 +00:00
## Configure models
You can globally configure a model's options through the config.
2025-08-27 14:41:51 +00:00
```jsonc title="opencode.jsonc" {7-12,19-24}
2025-08-13 18:07:08 +00:00
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openai": {
"models": {
"gpt-5": {
"options": {
"reasoningEffort": "high",
"textVerbosity": "low",
"reasoningSummary": "auto",
2025-08-27 14:41:51 +00:00
"include": ["reasoning.encrypted_content"],
},
},
},
},
"anthropic": {
"models": {
2025-10-03 21:06:20 +00:00
"claude-sonnet-4-5-20250929": {
2025-08-27 14:41:51 +00:00
"options": {
"thinking": {
"type": "enabled",
"budgetTokens": 16000,
},
},
},
},
},
},
2025-08-13 18:07:08 +00:00
}
```
2025-10-13 02:35:31 +00:00
Here we're configuring global settings for two built-in models: `gpt-5` when accessed via the `openai` provider, and `claude-sonnet-4-20250514` when accessed via the `anthropic` provider.
2025-09-29 11:52:26 +00:00
The built-in provider and model names can be found on [Models.dev](https://models.dev).
2025-08-13 18:07:08 +00:00
You can also configure these options for any agents that you are using. The agent config overrides any global options here. [Learn more](/docs/agents/#additional).
2025-09-29 11:52:26 +00:00
You can also define custom models that extend built-in ones and can optionally use specific options by referring to their id:
```jsonc title="opencode.jsonc" {6-20}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"opencode": {
"models": {
"gpt-5-high": {
"id": "gpt-5",
2025-12-20 17:54:49 +00:00
"name": "MyGPT5 (High Reasoning)",
2025-09-29 11:52:26 +00:00
"options": {
"reasoningEffort": "high",
"textVerbosity": "low",
2025-10-13 02:35:31 +00:00
"reasoningSummary": "auto",
},
2025-09-29 11:52:26 +00:00
},
"gpt-5-low": {
"id": "gpt-5",
2025-12-20 17:54:49 +00:00
"name": "MyGPT5 (Low Reasoning)",
2025-09-29 11:52:26 +00:00
"options": {
"reasoningEffort": "low",
"textVerbosity": "low",
2025-10-13 02:35:31 +00:00
"reasoningSummary": "auto",
},
},
},
},
},
2025-09-29 11:52:26 +00:00
}
```
2025-08-13 18:07:08 +00:00
---
2025-06-19 20:26:58 +00:00
## Loading models
2025-10-03 17:46:56 +00:00
When OpenCode starts up, it checks for models in the following priority order:
2025-06-19 20:26:58 +00:00
2025-08-02 14:29:03 +00:00
1. The `--model` or `-m` command line flag. The format is the same as in the config file: `provider_id/model_id`.
2025-10-03 17:46:56 +00:00
2. The model list in the OpenCode config.
2025-06-19 20:26:58 +00:00
2025-06-19 20:36:15 +00:00
```json title="opencode.json"
2025-06-19 20:26:58 +00:00
{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-4-20250514"
}
```
The format here is `provider/model`.
2025-08-02 14:29:03 +00:00
3. The last used model.
2025-06-19 20:26:58 +00:00
2025-08-02 14:29:03 +00:00
4. The first model using an internal priority.