2025-07-29 08:00:27 +08:00
---
title: Providers
2025-10-04 01:46:56 +08:00
description: Using any LLM provider in OpenCode.
2025-07-29 08:00:27 +08:00
---
2025-09-03 11:30:26 +08:00
import config from "../../../config.mjs"
2025-09-03 05:28:32 +08:00
export const console = config.console
2025-10-04 01:46:56 +08: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-07-29 08:00:27 +08:00
2025-07-31 06:16:11 +08:00
To add a provider you need to:
2025-12-03 07:08:19 +08:00
1. Add the API keys for the provider using the `/connect` command.
2025-10-04 01:46:56 +08:00
2. Configure the provider in your OpenCode config.
2025-07-31 06:16:11 +08:00
---
### Credentials
2025-12-03 07:08:19 +08:00
When you add a provider's API keys with the `/connect` command, they are stored
2025-07-31 06:16:11 +08:00
in `~/.local/share/opencode/auth.json`.
---
### Config
2025-10-04 01:46:56 +08:00
You can customize the providers through the `provider` section in your OpenCode
2025-07-31 06:16:11 +08:00
config.
---
#### Base URL
You can customize the base URL for any provider by setting the `baseURL` option. This is useful when using proxy services or custom endpoints.
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"anthropic": {
"options": {
"baseURL": "https://api.anthropic.com/v1"
}
}
}
}
```
---
2025-10-04 01:46:56 +08:00
## OpenCode Zen
2025-08-01 05:47:20 +08:00
2025-10-04 01:46:56 +08:00
OpenCode Zen is a list of models provided by the OpenCode team that have been
tested and verified to work well with OpenCode. [Learn more](/docs/zen).
2025-08-01 05:47:20 +08:00
:::tip
2025-10-04 01:46:56 +08:00
If you are new, we recommend starting with OpenCode Zen.
2025-08-01 05:47:20 +08:00
:::
2025-12-03 07:08:19 +08:00
1. Run the `/connect` command in the TUI, select opencode, and head to [opencode.ai/auth](https://opencode.ai/auth).
```txt
/connect
```
2025-09-17 01:26:49 +08:00
2. Sign in, add your billing details, and copy your API key.
2025-12-03 07:08:19 +08:00
3. Paste your API key.
2025-09-17 01:26:49 +08:00
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-09-17 01:26:49 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-09-17 01:26:49 +08:00
```
2025-09-17 01:35:32 +08:00
2025-09-17 01:26:49 +08:00
4. Run `/models` in the TUI to see the list of models we recommend.
2025-08-01 05:47:20 +08:00
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-10-04 01:46:56 +08:00
It works like any other provider in OpenCode. And is completely optional to use
2025-09-03 05:28:32 +08:00
it.
2025-08-01 05:47:20 +08:00
---
2025-07-31 06:16:11 +08:00
## Directory
Let's look at some of the providers in detail. If you'd like to add a provider to the
list, feel free to open a PR.
2025-07-31 07:11:36 +08:00
:::note
Don't see a provider here? Submit a PR.
:::
2025-07-31 06:16:11 +08:00
---
### Amazon Bedrock
2025-10-04 01:46:56 +08:00
To use Amazon Bedrock with OpenCode:
2025-07-31 06:16:11 +08:00
1. Head over to the **Model catalog** in the Amazon Bedrock console and request
access to the models you want.
2025-08-01 02:37:26 +08:00
2025-07-31 06:16:11 +08:00
:::tip
You need to have access to the model you want in Amazon Bedrock.
:::
1. You'll need either to set one of the following environment variables:
- `AWS_ACCESS_KEY_ID`: You can get this by creating an IAM user and generating
an access key for it.
- `AWS_PROFILE`: First login through AWS IAM Identity Center (or AWS SSO) using
`aws sso login`. Then get the name of the profile you want to use.
- `AWS_BEARER_TOKEN_BEDROCK`: You can generate a long-term API key from the
2025-08-01 02:37:26 +08:00
Amazon Bedrock console.
2025-07-31 06:16:11 +08:00
Once you have one of the above, set it while running opencode.
2025-08-01 02:37:26 +08:00
2025-07-31 06:16:11 +08:00
```bash
AWS_ACCESS_KEY_ID=XXX opencode
```
2025-08-01 02:37:26 +08:00
2025-07-31 06:16:11 +08:00
Or add it to your bash profile.
2025-08-01 02:37:26 +08:00
2025-07-31 06:16:11 +08:00
```bash title="~/.bash_profile"
export AWS_ACCESS_KEY_ID=XXX
```
2025-08-01 02:37:26 +08:00
1. Run the `/models` command to select the model you want.
2025-07-31 06:16:11 +08:00
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-07-31 06:16:11 +08:00
---
### Anthropic
2025-12-03 07:08:19 +08:00
We recommend signing up for [Claude Pro](https://www.anthropic.com/news/claude-pro) or [Max](https://www.anthropic.com/max).
2025-07-31 06:16:11 +08:00
2025-12-03 07:08:19 +08:00
1. Once you've signed up, run the `/connect` command and select Anthropic.
2025-07-31 06:16:11 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
```
2025-07-31 06:16:11 +08:00
2025-12-03 07:08:19 +08:00
2. Here you can select the **Claude Pro/Max** option and it'll open your browser
and ask you to authenticate.
2025-07-31 06:16:11 +08:00
2025-12-03 07:08:19 +08:00
```txt
┌ Select auth method
│
│ Claude Pro/Max
│ Create an API Key
│ Manually enter API Key
└
```
3. Now all the the Anthropic models should be available when you use the `/models` command.
2025-08-01 05:47:20 +08:00
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-08-01 05:47:20 +08:00
##### Using API keys
2025-12-03 07:08:19 +08:00
You can also select **Create an API Key** if you don't have a Pro/Max subscription. It'll also open your browser and ask you to login to Anthropic and give you a code you can paste in your terminal.
2025-08-01 05:47:20 +08:00
Or if you already have an API key, you can select **Manually enter API Key** and paste it in your terminal.
2025-07-31 06:16:11 +08:00
---
2025-08-01 02:37:26 +08:00
### Azure OpenAI
1. Head over to the [Azure portal](https://portal.azure.com/) and create an **Azure OpenAI** resource. You'll need:
- **Resource name**: This becomes part of your API endpoint (`https://RESOURCE_NAME.openai.azure.com/`)
- **API key**: Either `KEY 1` or `KEY 2` from your resource
2. Go to [Azure AI Foundry](https://ai.azure.com/) and deploy a model.
:::note
The deployment name must match the model name for opencode to work properly.
:::
2025-12-03 07:08:19 +08:00
3. Run the `/connect` command and search for **Azure**.
2025-08-01 02:37:26 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-08-01 02:37:26 +08:00
```
4. Enter your API key.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-08-01 02:37:26 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-08-01 02:37:26 +08:00
```
5. Set your resource name as an environment variable:
```bash
AZURE_RESOURCE_NAME=XXX opencode
```
Or add it to your bash profile:
```bash title="~/.bash_profile"
export AZURE_RESOURCE_NAME=XXX
```
6. Run the `/models` command to select your deployed model.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-08-01 02:37:26 +08:00
---
2025-11-17 14:01:45 +08:00
### Azure Cognitive Services
1. Head over to the [Azure portal](https://portal.azure.com/) and create an **Azure OpenAI** resource. You'll need:
- **Resource name**: This becomes part of your API endpoint (`https://AZURE_COGNITIVE_SERVICES_RESOURCE_NAME.cognitiveservices.azure.com/`)
- **API key**: Either `KEY 1` or `KEY 2` from your resource
2. Go to [Azure AI Foundry](https://ai.azure.com/) and deploy a model.
:::note
The deployment name must match the model name for opencode to work properly.
:::
2025-12-03 07:08:19 +08:00
3. Run the `/connect` command and search for **Azure Cognitive Services**.
2025-11-17 14:01:45 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-11-17 14:01:45 +08:00
```
4. Enter your API key.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-11-17 14:01:45 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-11-17 14:01:45 +08:00
```
5. Set your resource name as an environment variable:
```bash
AZURE_COGNITIVE_SERVICES_RESOURCE_NAME=XXX opencode
```
Or add it to your bash profile:
```bash title="~/.bash_profile"
export AZURE_COGNITIVE_SERVICES_RESOURCE_NAME=XXX
```
6. Run the `/models` command to select your deployed model.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-11-17 14:01:45 +08:00
---
2025-11-15 01:19:46 +08:00
### Baseten
1. Head over to the [Baseten](https://app.baseten.co/), create an account, and generate an API key.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **Baseten**.
2025-11-15 01:19:46 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-11-15 01:19:46 +08:00
```
3. Enter your Baseten API key.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-11-15 01:19:46 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-11-15 01:19:46 +08:00
```
4. Run the `/models` command to select a model.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-11-15 01:19:46 +08:00
---
2025-08-02 06:30:29 +08:00
### Cerebras
1. Head over to the [Cerebras console](https://inference.cerebras.ai/), create an account, and generate an API key.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **Cerebras**.
2025-08-02 06:30:29 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-08-02 06:30:29 +08:00
```
3. Enter your Cerebras API key.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-08-02 06:30:29 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-08-02 06:30:29 +08:00
```
4. Run the `/models` command to select a model like _Qwen 3 Coder 480B_.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-08-02 06:30:29 +08:00
---
2025-11-20 22:34:04 +08:00
### Cortecs
1. Head over to the [Cortecs console](https://cortecs.ai/), create an account, and generate an API key.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **Cortecs**.
2025-11-20 22:34:04 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-11-20 22:34:04 +08:00
```
3. Enter your Cortecs API key.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-11-20 22:34:04 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-11-20 22:34:04 +08:00
```
4. Run the `/models` command to select a model like _Kimi K2 Instruct_.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-11-20 22:34:04 +08:00
---
2025-08-01 05:47:20 +08:00
### DeepSeek
1. Head over to the [DeepSeek console](https://platform.deepseek.com/), create an account, and click **Create new API key**.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **DeepSeek**.
2025-08-01 05:47:20 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-08-01 05:47:20 +08:00
```
3. Enter your DeepSeek API key.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-08-01 05:47:20 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-08-01 05:47:20 +08:00
```
4. Run the `/models` command to select a DeepSeek model like _DeepSeek Reasoner_.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-08-01 05:47:20 +08:00
---
2025-11-07 06:08:48 +08:00
### Deep Infra
1. Head over to the [Deep Infra dashboard](https://deepinfra.com/dash), create an account, and generate an API key.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **Deep Infra**.
2025-11-07 06:08:48 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-11-07 06:08:48 +08:00
```
3. Enter your Deep Infra API key.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-11-07 06:08:48 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-11-07 06:08:48 +08:00
```
4. Run the `/models` command to select a model.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-11-07 06:08:48 +08:00
---
2025-08-01 05:47:20 +08:00
### Fireworks AI
1. Head over to the [Fireworks AI console](https://app.fireworks.ai/), create an account, and click **Create API Key**.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **Fireworks AI**.
2025-08-01 05:47:20 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-08-01 05:47:20 +08:00
```
3. Enter your Fireworks AI API key.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-08-01 05:47:20 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-08-01 05:47:20 +08:00
```
4. Run the `/models` command to select a model like _Kimi K2 Instruct_.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-08-01 05:47:20 +08:00
---
2025-07-31 06:16:11 +08:00
### GitHub Copilot
To use your GitHub Copilot subscription with opencode:
:::note
Some models might need a [Pro+
subscription](https://github.com/features/copilot/plans) to use.
2025-09-23 10:29:16 +08:00
Some models need to be manually enabled in your [GitHub Copilot settings](https://docs.github.com/en/copilot/how-tos/use-ai-models/configure-access-to-ai-models#setup-for-individual-use).
2025-07-31 06:16:11 +08:00
:::
2025-12-03 07:08:19 +08:00
1. Run the `/connect` command and search for GitHub Copilot.
2025-07-31 06:16:11 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
```
2025-08-01 02:37:26 +08:00
2025-12-03 07:08:19 +08:00
2. Navigate to [github.com/login/device](https://github.com/login/device) and enter the code.
```txt
┌ Login with GitHub Copilot
2025-07-31 06:16:11 +08:00
│
2025-12-03 07:08:19 +08:00
│ https://github.com/login/device
2025-07-31 06:16:11 +08:00
│
2025-12-03 07:08:19 +08:00
│ Enter code: 8F43-6FCF
2025-07-31 06:16:11 +08:00
│
2025-12-03 07:08:19 +08:00
└ Waiting for authorization...
2025-07-31 06:16:11 +08:00
```
3. Now run the `/models` command to select the model you want.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-07-31 06:16:11 +08:00
---
2025-10-24 00:44:06 +08:00
### Google Vertex AI
To use Google Vertex AI with OpenCode:
1. Head over to the **Model Garden** in the Google Cloud Console and check the
models available in your region.
2025-11-11 03:25:03 +08:00
:::note
2025-10-24 00:44:06 +08:00
You need to have a Google Cloud project with Vertex AI API enabled.
:::
2025-10-24 00:53:21 +08:00
2. Set the required environment variables:
2025-11-11 03:25:03 +08:00
- `GOOGLE_CLOUD_PROJECT`: Your Google Cloud project ID
- `VERTEX_LOCATION` (optional): The region for Vertex AI (defaults to `global`)
2025-10-24 00:49:53 +08:00
- Authentication (choose one):
2025-10-24 00:44:06 +08:00
- `GOOGLE_APPLICATION_CREDENTIALS`: Path to your service account JSON key file
2025-10-24 00:49:53 +08:00
- Authenticate using gcloud CLI: `gcloud auth application-default login`
2025-10-24 00:44:06 +08:00
2025-10-24 00:49:53 +08:00
Set them while running opencode.
2025-10-24 00:44:06 +08:00
```bash
2025-11-11 03:25:03 +08:00
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json GOOGLE_CLOUD_PROJECT=your-project-id opencode
2025-10-24 00:44:06 +08:00
```
Or add them to your bash profile.
```bash title="~/.bash_profile"
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
2025-11-11 03:25:03 +08:00
export GOOGLE_CLOUD_PROJECT=your-project-id
export VERTEX_LOCATION=global
2025-10-24 00:44:06 +08:00
```
2025-11-11 03:25:03 +08:00
:::tip
The `global` region improves availability and reduces errors at no extra cost. Use regional endpoints (e.g., `us-central1`) for data residency requirements. [Learn more](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-partner-models#regional_and_global_endpoints)
:::
2025-10-24 00:53:21 +08:00
3. Run the `/models` command to select the model you want.
2025-10-24 00:44:06 +08:00
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-10-24 00:44:06 +08:00
---
2025-10-28 06:16:25 +08:00
### Groq
1. Head over to the [Groq console](https://console.groq.com/), click **Create API Key**, and copy the key.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for Groq.
2025-10-28 06:16:25 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-10-28 06:16:25 +08:00
```
3. Enter the API key for the provider.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-10-28 06:16:25 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-10-28 06:16:25 +08:00
```
4. Run the `/models` command to select the one you want.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-11-01 23:33:17 +08:00
---
### Hugging Face
[Hugging Face Inference Providers](https://huggingface.co/docs/inference-providers) provides access to open models supported by 17+ providers.
1. Head over to [Hugging Face settings](https://huggingface.co/settings/tokens/new?ownUserPermissions=inference.serverless.write&tokenType=fineGrained) to create a token with permission to make calls to Inference Providers.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **Hugging Face**.
2025-11-01 23:33:17 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-11-01 23:33:17 +08:00
```
3. Enter your Hugging Face token.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-11-01 23:33:17 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-11-01 23:33:17 +08:00
```
4. Run the `/models` command to select a model like _Kimi-K2-Instruct_ or _GLM-4.6_.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-10-28 06:16:25 +08:00
---
2025-11-27 03:10:15 +08:00
### llama.cpp
You can configure opencode to use local models through [llama.cpp's](https://github.com/ggml-org/llama.cpp) llama-server utility
```json title="opencode.json" "llama.cpp" {5, 6, 8, 10-14}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"llama.cpp": {
"npm": "@ai-sdk/openai-compatible",
"name": "llama-server (local)",
"options": {
"baseURL": "http://127.0.0.1:8080/v1"
},
"models": {
"qwen3-coder:a3b": {
"name": "Qwen3-Coder: a3b-30b (local)"
}
},
2025-11-27 03:10:51 +08:00
"limit": {
"context": 128000,
"output": 65536
2025-11-27 03:10:15 +08:00
}
}
}
}
```
In this example:
- `llama.cpp` is the custom provider ID. This can be any string you want.
- `npm` specifies the package to use for this provider. Here, `@ai-sdk/openai-compatible` is used for any OpenAI-compatible API.
- `name` is the display name for the provider in the UI.
- `options.baseURL` is the endpoint for the local server.
- `models` is a map of model IDs to their configurations. The model name will be displayed in the model selection list.
---
2025-11-27 00:44:05 +08:00
### IO.NET
IO.NET offers 17 models optimized for various use cases:
1. Head over to the [IO.NET console](https://ai.io.net/), create an account, and generate an API key.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **IO.NET**.
2025-11-27 00:44:05 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-11-27 00:44:05 +08:00
```
3. Enter your IO.NET API key.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-11-27 00:44:05 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-11-27 00:44:05 +08:00
```
4. Run the `/models` command to select a model.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-11-27 00:44:05 +08:00
---
2025-07-31 06:16:11 +08:00
### LM Studio
You can configure opencode to use local models through LM Studio.
```json title="opencode.json" "lmstudio" {5, 6, 8, 10-14}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"lmstudio": {
"npm": "@ai-sdk/openai-compatible",
"name": "LM Studio (local)",
"options": {
"baseURL": "http://127.0.0.1:1234/v1"
},
"models": {
"google/gemma-3n-e4b": {
"name": "Gemma 3n-e4b (local)"
}
}
}
}
}
```
In this example:
- `lmstudio` is the custom provider ID. This can be any string you want.
- `npm` specifies the package to use for this provider. Here, `@ai-sdk/openai-compatible` is used for any OpenAI-compatible API.
- `name` is the display name for the provider in the UI.
- `options.baseURL` is the endpoint for the local server.
- `models` is a map of model IDs to their configurations. The model name will be displayed in the model selection list.
---
2025-08-01 05:47:20 +08:00
### Moonshot AI
To use Kimi K2 from Moonshot AI:
1. Head over to the [Moonshot AI console](https://platform.moonshot.ai/console), create an account, and click **Create API key**.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **Moonshot AI**.
2025-08-01 05:47:20 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-08-01 05:47:20 +08:00
```
2025-08-10 07:22:50 +08:00
3. Enter your Moonshot API key.
2025-08-01 05:47:20 +08:00
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-08-01 05:47:20 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-08-01 05:47:20 +08:00
```
2025-08-10 07:22:50 +08:00
4. Run the `/models` command to select _Kimi K2_.
2025-08-01 05:47:20 +08:00
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-08-01 05:47:20 +08:00
---
2025-07-31 06:16:11 +08:00
### Ollama
You can configure opencode to use local models through Ollama.
```json title="opencode.json" "ollama" {5, 6, 8, 10-14}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (local)",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"llama2": {
"name": "Llama 2"
}
}
}
}
}
```
In this example:
- `ollama` is the custom provider ID. This can be any string you want.
- `npm` specifies the package to use for this provider. Here, `@ai-sdk/openai-compatible` is used for any OpenAI-compatible API.
- `name` is the display name for the provider in the UI.
- `options.baseURL` is the endpoint for the local server.
- `models` is a map of model IDs to their configurations. The model name will be displayed in the model selection list.
2025-10-12 23:40:51 +08:00
:::tip
2025-10-13 04:01:32 +08:00
If tool calls aren't working, try increasing `num_ctx` in Ollama. Start around 16k - 32k.
2025-10-12 23:40:51 +08:00
:::
2025-07-31 06:16:11 +08:00
---
2025-11-25 00:51:16 +08:00
### Ollama Cloud
To use Ollama Cloud with OpenCode:
1. Head over to [https://ollama.com/](https://ollama.com/) and sign in or create an account.
2. Navigate to **Settings** > **Keys** and click **Add API Key** to generate a new API key.
3. Copy the API key for use in OpenCode.
2025-12-03 07:08:19 +08:00
4. Run the `/connect` command and search for **Ollama Cloud**.
2025-11-25 00:51:16 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-11-25 00:51:16 +08:00
```
5. Enter your Ollama Cloud API key.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-11-25 00:51:16 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-11-25 00:51:16 +08:00
```
6. **Important**: Before using cloud models in OpenCode, you must pull the model information locally:
```bash
ollama pull gpt-oss:20b-cloud
```
7. Run the `/models` command to select your Ollama Cloud model.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-11-25 00:51:16 +08:00
---
2025-07-31 06:16:11 +08:00
### OpenAI
1. Head over to the [OpenAI Platform console](https://platform.openai.com/api-keys), click **Create new secret key**, and copy the key.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for OpenAI.
2025-07-31 06:16:11 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-07-31 06:16:11 +08:00
```
2025-08-01 02:37:26 +08:00
2025-07-31 06:16:11 +08:00
3. Enter the API key for the provider.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-07-31 06:16:11 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-07-31 06:16:11 +08:00
```
4. Run the `/models` command to select the one you want.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-07-31 06:16:11 +08:00
---
2025-10-04 01:46:56 +08:00
### OpenCode Zen
2025-09-03 05:28:32 +08:00
2025-10-04 01:46:56 +08:00
OpenCode Zen is a list of tested and verified models provided by the OpenCode team. [Learn more](/docs/zen).
2025-09-03 05:28:32 +08:00
2025-10-04 01:46:56 +08:00
1. Sign in to **<a href={console}>OpenCode Zen</a>** and click **Create API Key**.
2025-09-03 05:28:32 +08:00
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **OpenCode Zen**.
2025-09-03 05:28:32 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-09-03 05:28:32 +08:00
```
2025-10-04 01:46:56 +08:00
3. Enter your OpenCode API key.
2025-09-03 05:28:32 +08:00
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-09-03 05:28:32 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-09-03 05:28:32 +08:00
```
4. Run the `/models` command to select a model like _Qwen 3 Coder 480B_.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-09-03 05:28:32 +08:00
---
2025-07-31 06:16:11 +08:00
### OpenRouter
1. Head over to the [OpenRouter dashboard](https://openrouter.ai/settings/keys), click **Create API Key**, and copy the key.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for OpenRouter.
2025-07-31 06:16:11 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-07-31 06:16:11 +08:00
```
2025-08-01 02:37:26 +08:00
2025-07-31 06:16:11 +08:00
3. Enter the API key for the provider.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-07-31 06:16:11 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-07-31 06:16:11 +08:00
```
4. Many OpenRouter models are preloaded by default, run the `/models` command to select the one you want.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-07-31 06:16:11 +08:00
You can also add additional models through your opencode config.
2025-08-01 02:37:26 +08:00
2025-07-31 06:16:11 +08:00
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openrouter": {
"models": {
2025-08-01 02:37:26 +08:00
"somecoolnewmodel": {}
2025-07-31 06:16:11 +08:00
}
}
}
}
```
5. You can also customize them through your opencode config. Here's an example of specifying a provider
2025-08-01 02:37:26 +08:00
2025-07-31 06:16:11 +08:00
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openrouter": {
"models": {
"moonshotai/kimi-k2": {
"options": {
"provider": {
"order": ["baseten"],
"allow_fallbacks": false
}
}
}
}
}
}
}
```
2025-08-01 01:08:12 +08:00
---
2025-11-13 03:28:35 +08:00
### OVHcloud AI Endpoints
1. Head over to the [OVHcloud panel](https://ovh.com/manager). Navigate to the `Public Cloud` section, `AI & Machine Learning` > `AI Endpoints` and in `API Keys` tab, click **Create a new API key**.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **OVHcloud AI Endpoints**.
2025-11-13 03:28:35 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-11-13 03:28:35 +08:00
```
3. Enter your OVHcloud AI Endpoints API key.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-11-13 03:28:35 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-11-13 03:28:35 +08:00
```
4. Run the `/models` command to select a model like _gpt-oss-120b_.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-11-13 03:28:35 +08:00
---
2025-08-01 05:47:20 +08:00
### Together AI
2025-08-01 01:08:12 +08:00
2025-08-01 05:47:20 +08:00
1. Head over to the [Together AI console](https://api.together.ai), create an account, and click **Add Key**.
2025-08-01 01:08:12 +08:00
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **Together AI**.
2025-08-01 01:08:12 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-08-01 01:08:12 +08:00
```
2025-07-31 06:16:11 +08:00
2025-08-01 05:47:20 +08:00
3. Enter your Together AI API key.
2025-07-31 06:16:11 +08:00
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-07-31 06:16:11 +08:00
│
2025-08-01 01:08:12 +08:00
│
2025-12-03 07:08:19 +08:00
└ enter
2025-08-01 01:08:12 +08:00
```
2025-08-01 05:47:20 +08:00
4. Run the `/models` command to select a model like _Kimi K2 Instruct_.
2025-08-01 02:37:26 +08:00
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-08-01 02:11:40 +08:00
---
2025-08-01 01:08:12 +08:00
2025-12-03 07:08:19 +08:00
### Venice AI
2025-08-27 00:27:10 +08:00
2025-12-03 07:08:19 +08:00
1. Head over to the [Venice AI console](https://venice.ai), create an account, and generate an API key.
2025-08-27 00:27:10 +08:00
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **Venice AI**.
```txt
/connect
```
2025-08-27 00:27:10 +08:00
2025-12-03 07:08:19 +08:00
3. Enter your Venice AI API key.
```txt
┌ API key
│
│
└ enter
```
2025-08-27 00:27:10 +08:00
2025-12-03 07:08:19 +08:00
4. Run the `/models` command to select a model like _Llama 3.3 70B_.
2025-08-27 00:27:10 +08:00
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-08-27 00:27:10 +08:00
---
2025-12-03 07:08:19 +08:00
### xAI
2025-08-03 09:20:44 +08:00
2025-12-03 07:08:19 +08:00
1. Head over to the [xAI console](https://console.x.ai/), create an account, and generate an API key.
2025-08-03 09:20:44 +08:00
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for **xAI**.
2025-08-03 09:20:44 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
```
2025-08-03 09:20:44 +08:00
2025-12-03 07:08:19 +08:00
3. Enter your xAI API key.
```txt
┌ API key
2025-08-03 09:20:44 +08:00
│
2025-12-03 07:08:19 +08:00
│
└ enter
2025-08-03 09:20:44 +08:00
```
2025-12-03 07:08:19 +08:00
4. Run the `/models` command to select a model like _Grok Beta_.
2025-09-18 04:54:00 +08:00
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-09-18 04:54:00 +08:00
2025-12-03 07:08:19 +08:00
---
### Z.AI
1. Head over to the [Z.AI API console](https://z.ai/manage-apikey/apikey-list), create an account, and click **Create a new API key**.
2. Run the `/connect` command and search for **Z.AI**.
```txt
/connect
2025-09-18 04:54:00 +08:00
```
2025-12-03 07:08:19 +08:00
If you are subscribed to the **GLM Coding Plan**, select **Z.AI Coding Plan**.
2025-08-03 09:20:44 +08:00
2025-12-03 07:08:19 +08:00
3. Enter your Z.AI API key.
2025-08-03 09:20:44 +08:00
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-08-03 09:20:44 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-08-03 09:20:44 +08:00
```
4. Run the `/models` command to select a model like _GLM-4.5_.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-08-03 09:20:44 +08:00
---
2025-11-16 11:37:30 +08:00
### ZenMux
1. Head over to the [ZenMux dashboard](https://zenmux.ai/settings/keys), click **Create API Key**, and copy the key.
2025-12-03 07:08:19 +08:00
2. Run the `/connect` command and search for ZenMux.
2025-11-16 11:37:30 +08:00
2025-12-03 07:08:19 +08:00
```txt
/connect
2025-11-16 11:37:30 +08:00
```
3. Enter the API key for the provider.
2025-12-03 07:08:19 +08:00
```txt
┌ API key
2025-11-16 11:37:30 +08:00
│
│
2025-12-03 07:08:19 +08:00
└ enter
2025-11-16 11:37:30 +08:00
```
4. Many ZenMux models are preloaded by default, run the `/models` command to select the one you want.
2025-12-03 07:08:19 +08:00
```txt
/models
```
2025-11-16 11:37:30 +08:00
You can also add additional models through your opencode config.
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"zenmux": {
"models": {
"somecoolnewmodel": {}
}
}
}
}
```
2025-11-16 11:38:13 +08:00
2025-11-16 11:37:30 +08:00
---
2025-09-03 05:28:32 +08:00
## Custom provider
2025-12-03 07:08:19 +08:00
To add any **OpenAI-compatible** provider that's not listed in the `/connect` command:
2025-09-03 05:28:32 +08:00
:::tip
You can use any OpenAI-compatible provider with opencode. Most modern AI providers offer OpenAI-compatible APIs.
:::
2025-12-03 07:08:19 +08:00
1. Run the `/connect` command and scroll down to **Other**.
2025-09-03 05:28:32 +08:00
```bash
2025-12-03 07:08:19 +08:00
$ /connect
2025-09-03 05:28:32 +08:00
┌ Add credential
│
◆ Select provider
│ ...
│ ● Other
└
```
2. Enter a unique ID for the provider.
```bash
2025-12-03 07:08:19 +08:00
$ /connect
2025-09-03 05:28:32 +08:00
┌ Add credential
│
◇ Enter provider id
│ myprovider
└
```
:::note
Choose a memorable ID, you'll use this in your config file.
:::
3. Enter your API key for the provider.
```bash
2025-12-03 07:08:19 +08:00
$ /connect
2025-09-03 05:28:32 +08:00
┌ Add credential
│
2025-12-03 07:08:19 +08:00
▲ This only stores a credential for myprovider - you will need to configure it in opencode.json, check the docs for examples.
2025-09-03 05:28:32 +08:00
│
◇ Enter your API key
│ sk-...
└
```
4. Create or update your `opencode.json` file in your project directory:
```json title="opencode.json" ""myprovider"" {5-15}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"myprovider": {
"npm": "@ai-sdk/openai-compatible",
"name": "My AI ProviderDisplay Name",
"options": {
"baseURL": "https://api.myprovider.com/v1"
},
"models": {
"my-model-name": {
"name": "My Model Display Name"
}
}
}
}
}
```
Here are the configuration options:
- **npm**: AI SDK package to use, `@ai-sdk/openai-compatible` for OpenAI-compatible providers
- **name**: Display name in UI.
- **models**: Available models.
- **options.baseURL**: API endpoint URL.
- **options.apiKey**: Optionally set the API key, if not using auth.
- **options.headers**: Optionally set custom headers.
More on the advanced options in the example below.
5. Run the `/models` command and your custom provider and models will appear in the selection list.
---
##### Example
2025-11-05 23:47:11 +08:00
Here's an example setting the `apiKey`, `headers`, and model `limit` options.
2025-09-03 05:28:32 +08:00
2025-11-05 23:47:11 +08:00
```json title="opencode.json" {9,11,17-20}
2025-09-03 05:28:32 +08:00
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"myprovider": {
"npm": "@ai-sdk/openai-compatible",
"name": "My AI ProviderDisplay Name",
"options": {
"baseURL": "https://api.myprovider.com/v1",
"apiKey": "{env:ANTHROPIC_API_KEY}",
"headers": {
"Authorization": "Bearer custom-token"
}
},
"models": {
"my-model-name": {
2025-11-05 23:47:11 +08:00
"name": "My Model Display Name",
"limit": {
"context": 200000,
"output": 65536
}
2025-09-03 05:28:32 +08:00
}
}
}
}
}
```
2025-11-05 23:47:11 +08:00
Configuration details:
- **apiKey**: Set using `env` variable syntax, [learn more](/docs/config#env-vars).
- **headers**: Custom headers sent with each request.
- **limit.context**: Maximum input tokens the model accepts.
- **limit.output**: Maximum tokens the model can generate.
The `limit` fields allow OpenCode to understand how much context you have left. Standard providers pull these from models.dev automatically.
2025-09-03 05:28:32 +08:00
---
2025-08-01 02:11:40 +08:00
## Troubleshooting
2025-08-01 01:08:12 +08:00
2025-08-01 02:11:40 +08:00
If you are having trouble with configuring a provider, check the following:
2025-08-01 01:08:12 +08:00
2025-08-01 02:11:40 +08:00
1. **Check the auth setup**: Run `opencode auth list` to see if the credentials
for the provider are added to your config.
2025-08-01 01:08:12 +08:00
2025-08-01 02:11:40 +08:00
This doesn't apply to providers like Amazon Bedrock, that rely on environment variables for their auth.
2025-07-31 06:16:11 +08:00
2025-08-01 02:11:40 +08:00
2. For custom providers, check the opencode config and:
2025-12-03 07:08:19 +08:00
- Make sure the provider ID used in the `/connect` command matches the ID in your opencode config.
2025-08-01 02:11:40 +08:00
- The right npm package is used for the provider. For example, use `@ai-sdk/cerebras` for Cerebras. And for all other OpenAI-compatible providers, use `@ai-sdk/openai-compatible`.
- Check correct API endpoint is used in the `options.baseURL` field.