- Full Obsidian vault content - Host configs (ice, grizzley, ubuntu, proxmox, truenas, panda, hyte) - Media stack documentation - Traefik HA setup - Automation scripts - Bachelor party planning
728 lines
36 KiB
Markdown
728 lines
36 KiB
Markdown
---
|
||
type: agent-doc
|
||
agent: OpenCode
|
||
source: https://opencode.ai/docs/providers/
|
||
scraped: 2026-04-28T21:02:13.229640+00:00
|
||
content_hash: 4cbc40bd
|
||
---
|
||
# Providers
|
||
|
||
Using any LLM provider in OpenCode.
|
||
|
||
OpenCode uses the AI SDK and Models.dev to support 75+ LLM providers and it supports running local models.
|
||
|
||
To add a provider you need to:
|
||
|
||
1. Add the API keys for the provider using the /connect command.
|
||
2. Configure the provider in your OpenCode config.
|
||
|
||
---
|
||
|
||
### Credentials
|
||
|
||
When you add a providerâs API keys with the /connect command, they are stored in ~/.local/share/opencode/auth.json.
|
||
|
||
---
|
||
|
||
### Config
|
||
|
||
You can customize the providers through the provider section in your OpenCode 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.
|
||
|
||
```
|
||
{ "$schema": "https://opencode.ai/config.json", "provider": { "anthropic": { "options": { "baseURL": "https://api.anthropic.com/v1" } } }}
|
||
```
|
||
|
||
---
|
||
|
||
## OpenCode Zen
|
||
|
||
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.
|
||
|
||
1. Run the /connect command in the TUI, select OpenCode Zen, and head to opencode.ai/auth. /connect
|
||
2. Sign in, add your billing details, and copy your API key.
|
||
3. Paste your API key. â API keyâââ enter
|
||
4. Run /models in the TUI to see the list of models we recommend. /models
|
||
|
||
It works like any other provider in OpenCode and is completely optional to use.
|
||
|
||
---
|
||
|
||
## OpenCode Go
|
||
|
||
OpenCode Go is a low cost subscription plan that provides reliable access to popular open coding models provided by the OpenCode team that have been tested and verified to work well with OpenCode.
|
||
|
||
1. Run the /connect command in the TUI, select OpenCode Go, and head to opencode.ai/auth. /connect
|
||
2. Sign in, add your billing details, and copy your API key.
|
||
3. Paste your API key. â API keyâââ enter
|
||
4. Run /models in the TUI to see the list of models we recommend. /models
|
||
|
||
It works like any other provider in OpenCode and is completely optional to use.
|
||
|
||
---
|
||
|
||
## 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.
|
||
|
||
---
|
||
|
||
### 302.AI
|
||
|
||
1. Head over to the 302.AI console, create an account, and generate an API key.
|
||
2. Run the /connect command and search for 302.AI. /connect
|
||
3. Enter your 302.AI API key. â API keyâââ enter
|
||
4. Run the /models command to select a model. /models
|
||
|
||
---
|
||
|
||
### Amazon Bedrock
|
||
|
||
To use Amazon Bedrock with OpenCode:
|
||
|
||
1. Head over to the Model catalog in the Amazon Bedrock console and request access to the models you want.
|
||
2. Configure authentication using one of the following methods: Environment Variables (Quick Start) Set one of these environment variables while running opencode: Terminal window# Option 1: Using AWS access keysAWS_ACCESS_KEY_ID=XXX AWS_SECRET_ACCESS_KEY=YYY opencode # Option 2: Using named AWS profileAWS_PROFILE=my-profile opencode # Option 3: Using Bedrock bearer tokenAWS_BEARER_TOKEN_BEDROCK=XXX opencode Or add them to your bash profile: ~/.bash_profileexport AWS_PROFILE=my-dev-profileexport AWS_REGION=us-east-1 Configuration File (Recommended) For project-specific or persistent configuration, use opencode.json: opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "amazon-bedrock": { "options": { "region": "us-east-1", "profile": "my-aws-profile" } } }} Available options: region - AWS region (e.g., us-east-1, eu-west-1) profile - AWS named profile from ~/.aws/credentials endpoint - Custom endpoint URL for VPC endpoints (alias for generic baseURL option) Advanced: VPC Endpoints If youâre using VPC endpoints for Bedrock: opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "amazon-bedrock": { "options": { "region": "us-east-1", "profile": "production", "endpoint": "https://bedrock-runtime.us-east-1.vpce-xxxxx.amazonaws.com" } } }} Authentication Methods AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY: Create an IAM user and generate access keys in the AWS Console AWS_PROFILE: Use named profiles from ~/.aws/credentials. First configure with aws configure --profile my-profile or aws sso login AWS_BEARER_TOKEN_BEDROCK: Generate long-term API keys from the Amazon Bedrock console AWS_WEB_IDENTITY_TOKEN_FILE / AWS_ROLE_ARN: For EKS IRSA (IAM Roles for Service Accounts) or other Kubernetes environments with OIDC federation. These environment variables are automatically injected by Kubernetes when using service account annotations. Authentication Precedence Amazon Bedrock uses the following authentication priority: Bearer Token - AWS_BEARER_TOKEN_BEDROCK environment variable or token from /connect command AWS Credential Chain - Profile, access keys, shared credentials, IAM roles, Web Identity Tokens (EKS IRSA), instance metadata
|
||
3. Run the /models command to select the model you want. /models
|
||
|
||
```
|
||
{ "$schema": "https://opencode.ai/config.json", "provider": { "amazon-bedrock": { // ... "models": { "anthropic-claude-sonnet-4.5": { "id": "arn:aws:bedrock:us-east-1:xxx:application-inference-profile/yyy" } } } }}
|
||
```
|
||
|
||
---
|
||
|
||
### Anthropic
|
||
|
||
1. Once youâve signed up, run the /connect command and select Anthropic. /connect
|
||
2. Here you can select the Claude Pro/Max option and itâll open your browser and ask you to authenticate. â Select auth methodââ Manually enter API Keyâ
|
||
3. Now all the Anthropic models should be available when you use the /models command. /models
|
||
|
||
There are plugins that allow you to use your Claude Pro/Max models with OpenCode. Anthropic explicitly prohibits this.
|
||
|
||
Previous versions of OpenCode came bundled with these plugins but that is no longer the case as of 1.3.0
|
||
|
||
Other companies support freedom of choice with developer tooling - you can use the following subscriptions in OpenCode with zero setup:
|
||
|
||
- ChatGPT Plus
|
||
- Github Copilot
|
||
- Gitlab Duo
|
||
|
||
---
|
||
|
||
### Azure OpenAI
|
||
|
||
1. Head over to the Azure portal 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 and deploy a model.
|
||
3. Run the /connect command and search for Azure. /connect
|
||
4. Enter your API key. â API keyâââ enter
|
||
5. Set your resource name as an environment variable: Terminal windowAZURE_RESOURCE_NAME=XXX opencode Or add it to your bash profile: ~/.bash_profileexport AZURE_RESOURCE_NAME=XXX
|
||
6. Run the /models command to select your deployed model. /models
|
||
|
||
---
|
||
|
||
### Azure Cognitive Services
|
||
|
||
1. Head over to the Azure portal 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 and deploy a model.
|
||
3. Run the /connect command and search for Azure Cognitive Services. /connect
|
||
4. Enter your API key. â API keyâââ enter
|
||
5. Set your resource name as an environment variable: Terminal windowAZURE_COGNITIVE_SERVICES_RESOURCE_NAME=XXX opencode Or add it to your bash profile: ~/.bash_profileexport AZURE_COGNITIVE_SERVICES_RESOURCE_NAME=XXX
|
||
6. Run the /models command to select your deployed model. /models
|
||
|
||
---
|
||
|
||
### Baseten
|
||
|
||
1. Head over to the Baseten, create an account, and generate an API key.
|
||
2. Run the /connect command and search for Baseten. /connect
|
||
3. Enter your Baseten API key. â API keyâââ enter
|
||
4. Run the /models command to select a model. /models
|
||
|
||
---
|
||
|
||
### Cerebras
|
||
|
||
1. Head over to the Cerebras console, create an account, and generate an API key.
|
||
2. Run the /connect command and search for Cerebras. /connect
|
||
3. Enter your Cerebras API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like Qwen 3 Coder 480B. /models
|
||
|
||
---
|
||
|
||
### Cloudflare AI Gateway
|
||
|
||
Cloudflare AI Gateway lets you access models from OpenAI, Anthropic, Workers AI, and more through a unified endpoint. With Unified Billing you donât need separate API keys for each provider.
|
||
|
||
1. Head over to the Cloudflare dashboard, navigate to AI > AI Gateway, and create a new gateway. Note your Account ID and Gateway ID.
|
||
2. Run the /connect command and search for Cloudflare AI Gateway. /connect
|
||
3. Enter your Account ID when prompted. â Enter your Cloudflare Account IDâââ enter
|
||
4. Enter your Gateway ID when prompted. â Enter your Cloudflare AI Gateway IDâââ enter
|
||
5. Enter your Cloudflare API token. â Gateway API tokenâââ enter
|
||
6. Run the /models command to select a model. /models You can also add models through your opencode config. opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "cloudflare-ai-gateway": { "models": { "openai/gpt-4o": {}, "anthropic/claude-sonnet-4": {} } } }} Alternatively, you can set environment variables instead of using /connect. ~/.bash_profileexport CLOUDFLARE_ACCOUNT_ID=your-32-character-account-idexport CLOUDFLARE_GATEWAY_ID=your-gateway-idexport CLOUDFLARE_API_TOKEN=your-api-token
|
||
|
||
---
|
||
|
||
### Cloudflare Workers AI
|
||
|
||
Cloudflare Workers AI lets you run AI models on Cloudflareâs global network directly via REST API, with no separate provider accounts needed for supported models.
|
||
|
||
1. Head over to the Cloudflare dashboard, navigate to Workers AI, and select Use REST API to get your Account ID and create an API token.
|
||
2. Run the /connect command and search for Cloudflare Workers AI. /connect
|
||
3. Enter your Account ID when prompted. â Enter your Cloudflare Account IDâââ enter
|
||
4. Enter your Cloudflare API key. â API keyâââ enter
|
||
5. Run the /models command to select a model. /models Alternatively, you can set environment variables instead of using /connect. ~/.bash_profileexport CLOUDFLARE_ACCOUNT_ID=your-32-character-account-idexport CLOUDFLARE_API_KEY=your-api-token
|
||
|
||
---
|
||
|
||
### Cortecs
|
||
|
||
1. Head over to the Cortecs console, create an account, and generate an API key.
|
||
2. Run the /connect command and search for Cortecs. /connect
|
||
3. Enter your Cortecs API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like Kimi K2 Instruct. /models
|
||
|
||
---
|
||
|
||
### DeepSeek
|
||
|
||
1. Head over to the DeepSeek console, create an account, and click Create new API key.
|
||
2. Run the /connect command and search for DeepSeek. /connect
|
||
3. Enter your DeepSeek API key. â API keyâââ enter
|
||
4. Run the /models command to select a DeepSeek model like DeepSeek V4 Pro. /models
|
||
|
||
---
|
||
|
||
### Deep Infra
|
||
|
||
1. Head over to the Deep Infra dashboard, create an account, and generate an API key.
|
||
2. Run the /connect command and search for Deep Infra. /connect
|
||
3. Enter your Deep Infra API key. â API keyâââ enter
|
||
4. Run the /models command to select a model. /models
|
||
|
||
---
|
||
|
||
### Firmware
|
||
|
||
1. Head over to the Firmware dashboard, create an account, and generate an API key.
|
||
2. Run the /connect command and search for Firmware. /connect
|
||
3. Enter your Firmware API key. â API keyâââ enter
|
||
4. Run the /models command to select a model. /models
|
||
|
||
---
|
||
|
||
### Fireworks AI
|
||
|
||
1. Head over to the Fireworks AI console, create an account, and click Create API Key.
|
||
2. Run the /connect command and search for Fireworks AI. /connect
|
||
3. Enter your Fireworks AI API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like Kimi K2 Instruct. /models
|
||
|
||
---
|
||
|
||
### GitLab Duo
|
||
|
||
OpenCode integrates with the GitLab Duo Agent Platform, providing AI-powered agentic chat with native tool calling capabilities.
|
||
|
||
1. Run the /connect command and select GitLab. /connect
|
||
2. Choose your authentication method: â Select auth methodââ OAuth (Recommended)â Personal Access Tokenâ Using OAuth (Recommended) Select OAuth and your browser will open for authorization. Using Personal Access Token Go to GitLab User Settings > Access Tokens Click Add new token Name: OpenCode, Scopes: api Copy the token (starts with glpat-) Enter it in the terminal
|
||
3. Run the /models command to see available models. /models Three Claude-based models are available: duo-chat-haiku-4-5 (Default) - Fast responses for quick tasks duo-chat-sonnet-4-5 - Balanced performance for most workflows duo-chat-opus-4-5 - Most capable for complex analysis
|
||
|
||
##### Self-Hosted GitLab
|
||
|
||
For self-hosted GitLab instances:
|
||
|
||
```
|
||
export GITLAB_INSTANCE_URL=https://gitlab.company.comexport GITLAB_TOKEN=glpat-...
|
||
```
|
||
|
||
If your instance runs a custom AI Gateway:
|
||
|
||
```
|
||
GITLAB_AI_GATEWAY_URL=https://ai-gateway.company.com
|
||
```
|
||
|
||
Or add to your bash profile:
|
||
|
||
```
|
||
export GITLAB_INSTANCE_URL=https://gitlab.company.comexport GITLAB_AI_GATEWAY_URL=https://ai-gateway.company.comexport GITLAB_TOKEN=glpat-...
|
||
```
|
||
|
||
##### OAuth for Self-Hosted instances
|
||
|
||
In order to make Oauth working for your self-hosted instance, you need to create a new application (Settings â Applications) with the callback URL http://127.0.0.1:8080/callback and following scopes:
|
||
|
||
- api (Access the API on your behalf)
|
||
- read_user (Read your personal information)
|
||
- read_repository (Allows read-only access to the repository)
|
||
|
||
Then expose application ID as environment variable:
|
||
|
||
```
|
||
export GITLAB_OAUTH_CLIENT_ID=your_application_id_here
|
||
```
|
||
|
||
More documentation on opencode-gitlab-auth homepage.
|
||
|
||
##### Configuration
|
||
|
||
Customize through opencode.json:
|
||
|
||
```
|
||
{ "$schema": "https://opencode.ai/config.json", "provider": { "gitlab": { "options": { "instanceUrl": "https://gitlab.com" } } }}
|
||
```
|
||
|
||
##### GitLab Duo Agent Platform (DAP) Workflow Models
|
||
|
||
DAP workflow models provide an alternative execution path that routes tool calls through GitLabâs Duo Workflow Service (DWS) instead of the standard agentic chat. When a duo-workflow-* model is selected, OpenCode will:
|
||
|
||
1. Discover available models from your GitLab namespace
|
||
2. Present a selection picker if multiple models are available
|
||
3. Cache the selected model to disk for fast subsequent startups
|
||
4. Route tool execution requests through OpenCodeâs permission-gated tool system
|
||
|
||
Available DAP workflow models follow the duo-workflow-* naming convention and are dynamically discovered from your GitLab instance.
|
||
|
||
##### GitLab API Tools (Optional, but highly recommended)
|
||
|
||
To access GitLab tools (merge requests, issues, pipelines, CI/CD, etc.):
|
||
|
||
```
|
||
{ "$schema": "https://opencode.ai/config.json", "plugin": ["opencode-gitlab-plugin"]}
|
||
```
|
||
|
||
This plugin provides comprehensive GitLab repository management capabilities including MR reviews, issue tracking, pipeline monitoring, and more.
|
||
|
||
---
|
||
|
||
### GitHub Copilot
|
||
|
||
To use your GitHub Copilot subscription with opencode:
|
||
|
||
1. Run the /connect command and search for GitHub Copilot. /connect
|
||
2. Navigate to github.com/login/device and enter the code. â Login with GitHub Copilotââ https://github.com/login/deviceââ Enter code: 8F43-6FCFââ Waiting for authorization...
|
||
3. Now run the /models command to select the model you want. /models
|
||
|
||
---
|
||
|
||
### 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.
|
||
2. Set the required environment variables: GOOGLE_CLOUD_PROJECT: Your Google Cloud project ID VERTEX_LOCATION (optional): The region for Vertex AI (defaults to global) Authentication (choose one): GOOGLE_APPLICATION_CREDENTIALS: Path to your service account JSON key file Authenticate using gcloud CLI: gcloud auth application-default login Set them while running opencode. Terminal windowGOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json GOOGLE_CLOUD_PROJECT=your-project-id opencode Or add them to your bash profile. ~/.bash_profileexport GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.jsonexport GOOGLE_CLOUD_PROJECT=your-project-idexport VERTEX_LOCATION=global
|
||
|
||
1. Run the /models command to select the model you want. /models
|
||
|
||
---
|
||
|
||
### Groq
|
||
|
||
1. Head over to the Groq console, click Create API Key, and copy the key.
|
||
2. Run the /connect command and search for Groq. /connect
|
||
3. Enter the API key for the provider. â API keyâââ enter
|
||
4. Run the /models command to select the one you want. /models
|
||
|
||
---
|
||
|
||
### Hugging Face
|
||
|
||
Hugging Face Inference Providers provides access to open models supported by 17+ providers.
|
||
|
||
1. Head over to Hugging Face settings to create a token with permission to make calls to Inference Providers.
|
||
2. Run the /connect command and search for Hugging Face. /connect
|
||
3. Enter your Hugging Face token. â API keyâââ enter
|
||
4. Run the /models command to select a model like Kimi-K2-Instruct or GLM-4.6. /models
|
||
|
||
---
|
||
|
||
### Helicone
|
||
|
||
Helicone is an LLM observability platform that provides logging, monitoring, and analytics for your AI applications. The Helicone AI Gateway routes your requests to the appropriate provider automatically based on the model.
|
||
|
||
1. Head over to Helicone, create an account, and generate an API key from your dashboard.
|
||
2. Run the /connect command and search for Helicone. /connect
|
||
3. Enter your Helicone API key. â API keyâââ enter
|
||
4. Run the /models command to select a model. /models
|
||
|
||
For more providers and advanced features like caching and rate limiting, check the Helicone documentation.
|
||
|
||
#### Optional Configs
|
||
|
||
In the event you see a feature or model from Helicone that isnât configured automatically through opencode, you can always configure it yourself.
|
||
|
||
Hereâs Heliconeâs Model Directory, youâll need this to grab the IDs of the models you want to add.
|
||
|
||
```
|
||
{ "$schema": "https://opencode.ai/config.json", "provider": { "helicone": { "npm": "@ai-sdk/openai-compatible", "name": "Helicone", "options": { "baseURL": "https://ai-gateway.helicone.ai", }, "models": { "gpt-4o": { // Model ID (from Helicone's model directory page) "name": "GPT-4o", // Your own custom name for the model }, "claude-sonnet-4-20250514": { "name": "Claude Sonnet 4", }, }, }, },}
|
||
```
|
||
|
||
#### Custom Headers
|
||
|
||
Helicone supports custom headers for features like caching, user tracking, and session management. Add them to your provider config using options.headers:
|
||
|
||
```
|
||
{ "$schema": "https://opencode.ai/config.json", "provider": { "helicone": { "npm": "@ai-sdk/openai-compatible", "name": "Helicone", "options": { "baseURL": "https://ai-gateway.helicone.ai", "headers": { "Helicone-Cache-Enabled": "true", "Helicone-User-Id": "opencode", }, }, }, },}
|
||
```
|
||
|
||
##### Session tracking
|
||
|
||
Heliconeâs Sessions feature lets you group related LLM requests together. Use the opencode-helicone-session plugin to automatically log each OpenCode conversation as a session in Helicone.
|
||
|
||
```
|
||
npm install -g opencode-helicone-session
|
||
```
|
||
|
||
Add it to your config.
|
||
|
||
```
|
||
{ "plugin": ["opencode-helicone-session"]}
|
||
```
|
||
|
||
The plugin injects Helicone-Session-Id and Helicone-Session-Name headers into your requests. In Heliconeâs Sessions page, youâll see each OpenCode conversation listed as a separate session.
|
||
|
||
##### Common Helicone headers
|
||
|
||
| Header | Description |
|
||
|---|---|
|
||
| Helicone-Cache-Enabled | Enable response caching (true/false) |
|
||
| Helicone-User-Id | Track metrics by user |
|
||
| Helicone-Property-[Name] | Add custom properties (e.g., Helicone-Property-Environment) |
|
||
| Helicone-Prompt-Id | Associate requests with prompt versions |
|
||
|
||
See the Helicone Header Directory for all available headers.
|
||
|
||
---
|
||
|
||
### llama.cpp
|
||
|
||
You can configure opencode to use local models through llama.cppâs llama-server utility
|
||
|
||
```
|
||
{ "$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)", "limit": { "context": 128000, "output": 65536 } } } } }}
|
||
```
|
||
|
||
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.
|
||
|
||
---
|
||
|
||
### IO.NET
|
||
|
||
IO.NET offers 17 models optimized for various use cases:
|
||
|
||
1. Head over to the IO.NET console, create an account, and generate an API key.
|
||
2. Run the /connect command and search for IO.NET. /connect
|
||
3. Enter your IO.NET API key. â API keyâââ enter
|
||
4. Run the /models command to select a model. /models
|
||
|
||
---
|
||
|
||
### LM Studio
|
||
|
||
You can configure opencode to use local models through LM Studio.
|
||
|
||
```
|
||
{ "$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.
|
||
|
||
---
|
||
|
||
### Moonshot AI
|
||
|
||
To use Kimi K2 from Moonshot AI:
|
||
|
||
1. Head over to the Moonshot AI console, create an account, and click Create API key.
|
||
2. Run the /connect command and search for Moonshot AI. /connect
|
||
3. Enter your Moonshot API key. â API keyâââ enter
|
||
4. Run the /models command to select Kimi K2. /models
|
||
|
||
---
|
||
|
||
### MiniMax
|
||
|
||
1. Head over to the MiniMax API Console, create an account, and generate an API key.
|
||
2. Run the /connect command and search for MiniMax. /connect
|
||
3. Enter your MiniMax API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like M2.1. /models
|
||
|
||
---
|
||
|
||
### NVIDIA
|
||
|
||
NVIDIA provides access to Nemotron models and many other open models through build.nvidia.com for free.
|
||
|
||
1. Head over to build.nvidia.com, create an account, and generate an API key.
|
||
2. Run the /connect command and search for NVIDIA. /connect
|
||
3. Enter your NVIDIA API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like nemotron-3-super-120b-a12b. /models
|
||
|
||
#### On-Prem / NIM
|
||
|
||
You can also use NVIDIA models locally via NVIDIA NIM by setting a custom base URL.
|
||
|
||
```
|
||
{ "$schema": "https://opencode.ai/config.json", "provider": { "nvidia": { "options": { "baseURL": "http://localhost:8000/v1" } } }}
|
||
```
|
||
|
||
#### Environment Variable
|
||
|
||
Alternatively, set your API key as an environment variable.
|
||
|
||
```
|
||
export NVIDIA_API_KEY=nvapi-your-key-here
|
||
```
|
||
|
||
---
|
||
|
||
### Nebius Token Factory
|
||
|
||
1. Head over to the Nebius Token Factory console, create an account, and click Add Key.
|
||
2. Run the /connect command and search for Nebius Token Factory. /connect
|
||
3. Enter your Nebius Token Factory API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like Kimi K2 Instruct. /models
|
||
|
||
---
|
||
|
||
### Ollama
|
||
|
||
You can configure opencode to use local models through Ollama.
|
||
|
||
```
|
||
{ "$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.
|
||
|
||
---
|
||
|
||
### Ollama Cloud
|
||
|
||
To use Ollama Cloud with OpenCode:
|
||
|
||
1. Head over to 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.
|
||
4. Run the /connect command and search for Ollama Cloud. /connect
|
||
5. Enter your Ollama Cloud API key. â API keyâââ enter
|
||
6. Important: Before using cloud models in OpenCode, you must pull the model information locally: Terminal windowollama pull gpt-oss:20b-cloud
|
||
7. Run the /models command to select your Ollama Cloud model. /models
|
||
|
||
---
|
||
|
||
### OpenAI
|
||
|
||
We recommend signing up for ChatGPT Plus or Pro.
|
||
|
||
1. Once youâve signed up, run the /connect command and select OpenAI. /connect
|
||
2. Here you can select the ChatGPT Plus/Pro option and itâll open your browser and ask you to authenticate. â Select auth methodââ ChatGPT Plus/Proâ Manually enter API Keyâ
|
||
3. Now all the OpenAI models should be available when you use the /models command. /models
|
||
|
||
##### Using API keys
|
||
|
||
If you already have an API key, you can select Manually enter API Key and paste it in your terminal.
|
||
|
||
---
|
||
|
||
OpenCode Zen is a list of tested and verified models provided by the OpenCode team. Learn more.
|
||
|
||
1. Sign in to OpenCode Zen and click Create API Key.
|
||
2. Run the /connect command and search for OpenCode Zen. /connect
|
||
3. Enter your OpenCode API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like Qwen 3 Coder 480B. /models
|
||
|
||
---
|
||
|
||
### OpenRouter
|
||
|
||
1. Head over to the OpenRouter dashboard, click Create API Key, and copy the key.
|
||
2. Run the /connect command and search for OpenRouter. /connect
|
||
3. Enter the API key for the provider. â API keyâââ enter
|
||
4. Many OpenRouter models are preloaded by default, run the /models command to select the one you want. /models You can also add additional models through your opencode config. opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "openrouter": { "models": { "somecoolnewmodel": {} } } }}
|
||
5. You can also customize them through your opencode config. Hereâs an example of specifying a provider opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "openrouter": { "models": { "moonshotai/kimi-k2": { "options": { "provider": { "order": ["baseten"], "allow_fallbacks": false } } } } } }}
|
||
|
||
---
|
||
|
||
### LLM Gateway
|
||
|
||
1. Head over to the LLM Gateway dashboard, click Create API Key, and copy the key.
|
||
2. Run the /connect command and search for LLM Gateway. /connect
|
||
3. Enter the API key for the provider. â API keyâââ enter
|
||
4. Many LLM Gateway models are preloaded by default, run the /models command to select the one you want. /models You can also add additional models through your opencode config. opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "llmgateway": { "models": { "somecoolnewmodel": {} } } }}
|
||
5. You can also customize them through your opencode config. Hereâs an example of specifying a provider opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "llmgateway": { "models": { "glm-4.7": { "name": "GLM 4.7" }, "gpt-5.2": { "name": "GPT-5.2" }, "gemini-2.5-pro": { "name": "Gemini 2.5 Pro" }, "claude-3-5-sonnet-20241022": { "name": "Claude 3.5 Sonnet" } } } }}
|
||
|
||
---
|
||
|
||
### SAP AI Core
|
||
|
||
SAP AI Core provides access to 40+ models from OpenAI, Anthropic, Google, Amazon, Meta, Mistral, and AI21 through a unified platform.
|
||
|
||
1. Go to your SAP BTP Cockpit, navigate to your SAP AI Core service instance, and create a service key.
|
||
2. Run the /connect command and search for SAP AI Core. /connect
|
||
3. Enter your service key JSON. â Service keyâââ enter Or set the AICORE_SERVICE_KEY environment variable: Terminal windowAICORE_SERVICE_KEY='{"clientid":"...","clientsecret":"...","url":"...","serviceurls":{"AI_API_URL":"..."}}' opencode Or add it to your bash profile: ~/.bash_profileexport AICORE_SERVICE_KEY='{"clientid":"...","clientsecret":"...","url":"...","serviceurls":{"AI_API_URL":"..."}}'
|
||
4. Optionally set deployment ID and resource group: Terminal windowAICORE_DEPLOYMENT_ID=your-deployment-id AICORE_RESOURCE_GROUP=your-resource-group opencode
|
||
5. Run the /models command to select from 40+ available models. /models
|
||
|
||
---
|
||
|
||
### STACKIT
|
||
|
||
STACKIT AI Model Serving provides fully managed soverign hosting environment for AI models, focusing on LLMs like Llama, Mistral, and Qwen, with maximum data sovereignty on European infrastructure.
|
||
|
||
1. Head over to STACKIT Portal, navigate to AI Model Serving, and create an auth token for your project.
|
||
2. Run the /connect command and search for STACKIT. /connect
|
||
3. Enter your STACKIT AI Model Serving auth token. â API keyâââ enter
|
||
4. Run the /models command to select from available models like Qwen3-VL 235B or Llama 3.3 70B. /models
|
||
|
||
---
|
||
|
||
### OVHcloud AI Endpoints
|
||
|
||
1. Head over to the OVHcloud panel. Navigate to the Public Cloud section, AI & Machine Learning > AI Endpoints and in API Keys tab, click Create a new API key.
|
||
2. Run the /connect command and search for OVHcloud AI Endpoints. /connect
|
||
3. Enter your OVHcloud AI Endpoints API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like gpt-oss-120b. /models
|
||
|
||
---
|
||
|
||
### Scaleway
|
||
|
||
To use Scaleway Generative APIs with Opencode:
|
||
|
||
1. Head over to the Scaleway Console IAM settings to generate a new API key.
|
||
2. Run the /connect command and search for Scaleway. /connect
|
||
3. Enter your Scaleway API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like devstral-2-123b-instruct-2512 or gpt-oss-120b. /models
|
||
|
||
---
|
||
|
||
### Together AI
|
||
|
||
1. Head over to the Together AI console, create an account, and click Add Key.
|
||
2. Run the /connect command and search for Together AI. /connect
|
||
3. Enter your Together AI API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like Kimi K2 Instruct. /models
|
||
|
||
---
|
||
|
||
### Venice AI
|
||
|
||
1. Head over to the Venice AI console, create an account, and generate an API key.
|
||
2. Run the /connect command and search for Venice AI. /connect
|
||
3. Enter your Venice AI API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like Llama 3.3 70B. /models
|
||
|
||
---
|
||
|
||
### Vercel AI Gateway
|
||
|
||
Vercel AI Gateway lets you access models from OpenAI, Anthropic, Google, xAI, and more through a unified endpoint. Models are offered at list price with no markup.
|
||
|
||
1. Head over to the Vercel dashboard, navigate to the AI Gateway tab, and click API keys to create a new API key.
|
||
2. Run the /connect command and search for Vercel AI Gateway. /connect
|
||
3. Enter your Vercel AI Gateway API key. â API keyâââ enter
|
||
4. Run the /models command to select a model. /models
|
||
|
||
You can also customize models through your opencode config. Hereâs an example of specifying provider routing order.
|
||
|
||
```
|
||
{ "$schema": "https://opencode.ai/config.json", "provider": { "vercel": { "models": { "anthropic/claude-sonnet-4": { "options": { "order": ["anthropic", "vertex"] } } } } }}
|
||
```
|
||
|
||
Some useful routing options:
|
||
|
||
| Option | Description |
|
||
|---|---|
|
||
| order | Provider sequence to try |
|
||
| only | Restrict to specific providers |
|
||
| zeroDataRetention | Only use providers with zero data retention policies |
|
||
|
||
---
|
||
|
||
### xAI
|
||
|
||
1. Head over to the xAI console, create an account, and generate an API key.
|
||
2. Run the /connect command and search for xAI. /connect
|
||
3. Enter your xAI API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like Grok Beta. /models
|
||
|
||
---
|
||
|
||
### Z.AI
|
||
|
||
1. Head over to the Z.AI API console, create an account, and click Create a new API key.
|
||
2. Run the /connect command and search for Z.AI. /connect If you are subscribed to the GLM Coding Plan, select Z.AI Coding Plan.
|
||
3. Enter your Z.AI API key. â API keyâââ enter
|
||
4. Run the /models command to select a model like GLM-4.7. /models
|
||
|
||
---
|
||
|
||
### ZenMux
|
||
|
||
1. Head over to the ZenMux dashboard, click Create API Key, and copy the key.
|
||
2. Run the /connect command and search for ZenMux. /connect
|
||
3. Enter the API key for the provider. â API keyâââ enter
|
||
4. Many ZenMux models are preloaded by default, run the /models command to select the one you want. /models You can also add additional models through your opencode config. opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "zenmux": { "models": { "somecoolnewmodel": {} } } }}
|
||
|
||
---
|
||
|
||
## Custom provider
|
||
|
||
To add any OpenAI-compatible provider thatâs not listed in the /connect command:
|
||
|
||
1. Run the /connect command and scroll down to Other. Terminal window$ /connect â Add credentialââ Select providerâ ...â â Otherâ
|
||
2. Enter a unique ID for the provider. Terminal window$ /connect â Add credentialââ Enter provider idâ myproviderâ
|
||
3. Enter your API key for the provider. Terminal window$ /connect â Add credentialââ² This only stores a credential for myprovider - you will need to configure it in opencode.json, check the docs for examples.ââ Enter your API keyâ sk-...â
|
||
4. Create or update your opencode.json file in your project directory: opencode.json{ "$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 (for /v1/chat/completions). If your provider/model uses /v1/responses, use @ai-sdk/openai. 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
|
||
|
||
Hereâs an example setting the apiKey, headers, and model limit options.
|
||
|
||
```
|
||
{ "$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": { "name": "My Model Display Name", "limit": { "context": 200000, "output": 65536 } } } } }}
|
||
```
|
||
|
||
Configuration details:
|
||
|
||
- apiKey: Set using env variable syntax, learn more.
|
||
- 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.
|
||
|
||
---
|
||
|
||
## Troubleshooting
|
||
|
||
If you are having trouble with configuring a provider, check the following:
|
||
|
||
1. Check the auth setup: Run opencode auth list to see if the credentials for the provider are added to your config. This doesnât apply to providers like Amazon Bedrock, that rely on environment variables for their auth.
|
||
2. For custom providers, check the opencode config and: Make sure the provider ID used in the /connect command matches the ID in your opencode config. 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 (for /v1/chat/completions); if a model uses /v1/responses, use @ai-sdk/openai. For mixed setups under one provider, you can override per model via provider.npm. Check correct API endpoint is used in the options.baseURL field.
|