Skip to main content

Providers

opencode supports 75+ LLM providers through the AI SDK and Models.dev integration. This includes major cloud AI platforms, open-source model hosts, local inference engines, and custom OpenAI-compatible endpoints.

Supported Providers

ProviderDescription
AnthropicClaude model family (Sonnet, Haiku, Opus)
OpenAIGPT-4, GPT-5, o3, o4-mini models
Google Vertex AIGemini models via Google Cloud
Amazon BedrockClaude, Llama, Mistral via AWS
Azure OpenAIOpenAI models hosted on Azure
GroqLow-latency inference for open models
DeepSeekDeepSeek-V2, DeepSeek-R1 models
OllamaLocal inference for open-source models
OpenRouterUnified API for 200+ models
Together AICloud inference for open models
xAIGrok models
GitHub CopilotCopilot-powered models
GitLab DuoGitLab's AI features
Hugging FaceHugging Face Inference Endpoints and Serverless
Deep InfraServerless GPU inference
Fireworks AIFast inference for open models
CerebrasWafer-scale AI acceleration
LM StudioLocal model server with OpenAI-compatible API
llama.cppLightweight local LLM inference
Atomic ChatLocal chat interface with model serving
Mistral AIMistral models (Large, Small, Codestral)
CohereCommand-R, Command-R+ models
PerplexityPPLX models for search-augmented generation
ReplicateCloud API for open-source models
AnyscaleRay-based model serving
AI21 LabsJamba, Jurassic-2 models
WriterPalmyra model family
OctoAICloud inference platform
Lepton AIServerless model serving
ModalCloud functions for AI workloads
Noon AIKorean language model provider
Nvidia NIMGPU-optimized model containers
SambanovaDataflow architecture for LLMs
AI/ML APIOpenAI-compatible API

And many more via Models.dev. To see the full list:

opencode providers list

Adding Credentials

The easiest way to add provider credentials is through the TUI using the /connect command:

/connect

This opens an interactive prompt where you select a provider and follow the authentication flow. Credentials are stored securely in:

~/.local/share/opencode/auth.json

Authentication Methods

Providers support different authentication mechanisms:

API Key (most common):

/connect anthropic

Then paste your API key when prompted.

Environment Variables:

Set well-known environment variables for automatic detection:

export ANTHROPIC_API_KEY=sk-ant-...
export OPENAI_API_KEY=sk-...
export GROQ_API_KEY=gsk_...
export TOGETHER_API_KEY=...

OAuth:

Some providers (GitHub Copilot, GitLab Duo) use OAuth flows. The /connect command opens a browser window for authorization.

Provider Configuration

Provider-specific options are set under the provider key in opencode.json.

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"anthropic": {
"options": {
"baseURL": "https://api.anthropic.com/v1",
"timeout": 600000,
"chunkTimeout": 30000,
"setCacheKey": true
}
},
"openai": {
"options": {
"baseURL": "https://api.openai.com/v1",
"timeout": 600000
}
}
}
}

Provider Options Reference

OptionTypeDefaultDescription
baseURLstringProvider defaultAPI endpoint base URL
timeoutnumber600000Request timeout in milliseconds
chunkTimeoutnumber30000Streaming chunk timeout in milliseconds
setCacheKeybooleanfalseEnable prompt caching (Anthropic)
reasoningEffortstringprovider defaultReasoning budget (none, low, medium, high)
thinkingobjectnullExtended thinking configuration
textVerbositystring"normal"Response verbosity level

Provider-Specific Options

Some providers have unique configuration options.

Amazon Bedrock:

{
"provider": {
"amazon-bedrock": {
"options": {
"region": "us-west-2",
"profile": "my-aws-profile",
"endpoint": "https://bedrock-runtime.us-west-2.amazonaws.com"
}
}
}
}

Google Vertex AI:

{
"provider": {
"google-vertex": {
"options": {
"projectId": "my-gcp-project",
"location": "us-central1"
}
}
}
}

Azure OpenAI:

{
"provider": {
"azure-openai": {
"options": {
"resourceName": "my-resource",
"deploymentId": "gpt-4-deployment",
"apiVersion": "2024-10-01-preview"
}
}
}
}

Custom Providers

Any OpenAI-compatible API endpoint can be added as a custom provider using the @ai-sdk/openai-compatible package.

{
"provider": {
"my-custom-provider": {
"npm": "@ai-sdk/openai-compatible",
"name": "My Internal Provider",
"options": {
"baseURL": "https://api.internal.company.com/v1",
"headers": {
"X-API-Key": "{env:INTERNAL_API_KEY}",
"X-Organization": "engineering"
}
},
"models": {
"internal-llama-3": {
"name": "llama-3-70b-instruct"
},
"internal-mixtral": {
"name": "mixtral-8x22b-instruct"
}
}
}
}
}

Custom Provider Fields

FieldRequiredDescription
npmYesThe npm package implementing the provider interface
nameNoHuman-readable display name in the TUI
optionsNoProvider options including baseURL, headers, timeout
modelsYesMap of model IDs to model definitions

Custom Headers

Use custom headers for authentication or routing to internal proxy services:

{
"provider": {
"internal-proxy": {
"npm": "@ai-sdk/openai-compatible",
"name": "Internal Proxy",
"options": {
"baseURL": "https://ai-gateway.company.com/v1",
"headers": {
"Authorization": "Bearer {env:GATEWAY_TOKEN}",
"X-Tenant-ID": "engineering"
}
}
}
}
}

Local Model Providers

Local inference engines can be configured as OpenAI-compatible providers by pointing baseURL to the local server.

Ollama

{
"provider": {
"ollama": {
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"llama3.2": { "name": "llama3.2" },
"mistral": { "name": "mistral" },
"codellama": { "name": "codellama" }
}
}
}
}

LM Studio

{
"provider": {
"lm-studio": {
"npm": "@ai-sdk/openai-compatible",
"name": "LM Studio",
"options": {
"baseURL": "http://localhost:1234/v1"
},
"models": {
"local-model": { "name": "local-model" }
}
}
}
}

llama.cpp

{
"provider": {
"llamacpp": {
"npm": "@ai-sdk/openai-compatible",
"name": "llama.cpp",
"options": {
"baseURL": "http://localhost:8080/v1"
}
}
}
}

Atomic Chat

Atomic Chat provides a built-in local inference server. Configure it like any OpenAI-compatible endpoint:

{
"provider": {
"atomic": {
"npm": "@ai-sdk/openai-compatible",
"name": "Atomic Chat",
"options": {
"baseURL": "http://localhost:1337/v1"
}
}
}
}

Base URL Customization

Customizing baseURL is useful for:

  • Internal proxy or gateway services
  • Load balancers that distribute across provider regions
  • Air-gapped environments with a local API mirror
  • Provider compatibility layers (e.g., running Anthropic models through a proxy)
{
"provider": {
"anthropic": {
"options": {
"baseURL": "https://internal-ai-gateway.company.com/anthropic/v1"
}
}
}
}

Troubleshooting

Check Stored Credentials

List all configured authentication entries:

opencode auth list

This shows which providers have credentials stored and when they were added.

Verify Provider ID

Provider IDs in the config must match the IDs used by opencode. Run the following to see exact provider IDs:

opencode providers list

Common provider IDs:

Config KeyProvider ID
anthropicanthropic
openaiopenai
google-vertexgoogle-vertex
amazon-bedrockamazon-bedrock
azure-openaiazure-openai
groqgroq
deepseekdeepseek
ollamaollama
openrouteropenrouter

Testing Provider Connectivity

opencode models anthropic

If the models list fails to load, check:

  • Network connectivity to the provider
  • API key validity
  • Base URL correctness
  • Proxy settings that might interfere

Error Messages

ErrorLikely Cause
authentication failedMissing or invalid API key
model not foundIncorrect model ID or unavailable model
rate limit exceededToo many requests, wait and retry
connection refusedLocal server not running or wrong port
timeoutRequest exceeded configured timeout
chunk timeoutStreaming response stalled

Provider Configuration Inheritance

When multiple models from the same provider share options, you can set provider-level defaults that apply to all models:

{
"provider": {
"anthropic": {
"options": {
"timeout": 300000,
"setCacheKey": true
}
}
}
}

Individual model configurations can override provider-level options.