Providers
OpenCode includes a built-in catalog of providers and models from models.dev. You can also add a custom provider to your configuration.
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"acme": {
"name": "Acme",
"env": ["ACME_API_KEY"],
"package": "@opencode/ai/providers/openai-compatible",
"settings": {
"baseURL": "https://llm.acme.example/v1",
},
"models": {
"qwen3-coder": {
"name": "Qwen 3 Coder",
},
},
},
},
}The providers object is keyed by provider ID. Each provider accepts these fields:
| Field | Purpose |
|---|---|
name | Display name. |
env | Ordered environment variable names that provide a connection. |
package | Runtime provider package. |
settings | JSON settings passed to the runtime package, such as baseURL. |
headers | String-valued HTTP headers added to requests. |
body | JSON fields merged into request bodies. |
models | Models to add or override, keyed by catalog model ID. |
OpenCode Go
OpenCode Go is an optional subscription that provides access to coding models tested by the OpenCode team.
Subscribe in the console, copy your API key, then run /connect in the TUI and select
OpenCode Go:
/connect
Paste your API key, then run /models to select a Go model. See the Go guide for setup, usage limits,
endpoints, and privacy details.
Azure OpenAI and Microsoft Foundry
Azure supports either an API key or your existing Microsoft Entra ID session from the Azure CLI.
-
Install the Azure CLI and sign in:
az loginIf the resource belongs to another tenant or subscription, select them first:
az login --tenant TENANT_ID az account set --subscription NAME_OR_ID -
Find your Azure resource name in the Azure portal or Microsoft Foundry: open the Azure OpenAI or Foundry resource and copy its Resource name. It is also the first part of the endpoint:
my-modelsinhttps://my-models.openai.azure.com/orhttps://my-models.services.ai.azure.com/.If your identity can list resources, the Azure CLI can display the names and resource groups:
az cognitiveservices account list \ --query "[].{name:name,resourceGroup:resourceGroup}" \ --output table -
In OpenCode, run
/connect, select Azure, and choose Microsoft Entra ID (Azure CLI). Enter the Azure resource name when prompted. IfAZURE_RESOURCE_NAMEis already set, OpenCode uses it without prompting. -
Select a deployed model with
/models.
OpenCode does not query Azure management APIs or discover deployments. Select a model whose catalog name matches your deployment, or configure the deployment name explicitly:
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"azure": {
"models": {
"gpt-5-mini": {
"modelID": "gpt-production",
},
},
},
},
}Your identity needs the Cognitive Services OpenAI User role for Azure OpenAI models or the Cognitive Services User
role for other Foundry models. If a request fails because the token belongs to another tenant, sign in again with
az login --tenant TENANT_ID.
WebSocket transport
OpenAI, xAI, and supported Azure Responses models keep one WebSocket connection open per session and send each step
over it instead of opening a new HTTP request. While the request prefix is unchanged, consecutive steps only transmit
what was added since the previous response, which cuts upload volume on long sessions. OpenAI provider compaction runs
over the same connection. xAI continues a chain only from stored responses, so with its default store: false each step
is sent in full over the reused connection.
The connection is transparent. When the provider closes the socket, the next step reconnects; when a connection cannot
be opened at all, the session continues over HTTP. Plugins that register http.request or http.response hooks for a
provider keep it on HTTP so the hooks observe every request.
WebSockets are opt-in per built-in provider. Set websocket: true to enable a supported provider or model, or false
to disable a built-in opt-in; a model policy overrides the provider policy:
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"openai": {
"websocket": false,
"models": {
"gpt-5.5": { "websocket": true },
},
},
},
}Endpoint
Override settings.baseURL to send an existing provider through a proxy or compatible endpoint. Its existing package,
models, and connection continue to apply:
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"anthropic": {
"settings": {
"baseURL": "https://llm-proxy.example.com/anthropic",
},
},
},
}settings is package-specific. A field only has an effect when the selected package supports it.
Headers and body
Use headers to add HTTP headers to provider requests. Use body to merge additional JSON fields into each request
body:
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"openai": {
"headers": {
"X-Gateway-Tenant": "engineering",
},
"body": {
"metadata": {
"application": "opencode",
},
},
},
},
}Package
The package field selects the runtime used to communicate with a provider. For an OpenAI-compatible API, use the
built-in compatible package:
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"acme": {
"package": "@opencode/ai/providers/openai-compatible",
"settings": {
"baseURL": "https://llm.acme.example/v1",
},
"models": {
"qwen3-coder": {
"name": "Qwen 3 Coder",
},
},
},
},
}Native package options:
@opencode/ai/providers/openai@opencode/ai/providers/openai/chat@opencode/ai/providers/openai/responses@opencode/ai/providers/openai-compatible@opencode/ai/providers/openai-compatible/responses@opencode/ai/providers/anthropic@opencode/ai/providers/anthropic-compatible@opencode/ai/providers/google@opencode/ai/providers/google-vertex@opencode/ai/providers/google-vertex/gemini@opencode/ai/providers/google-vertex/chat@opencode/ai/providers/google-vertex/responses@opencode/ai/providers/google-vertex/messages@opencode/ai/providers/azure@opencode/ai/providers/azure/chat@opencode/ai/providers/azure/responses@opencode/ai/providers/amazon-bedrock@opencode/ai/providers/amazon-bedrock/mantle@opencode/ai/providers/amazon-bedrock/mantle/chat@opencode/ai/providers/amazon-bedrock/mantle/responses@opencode/ai/providers/openrouter@opencode/ai/providers/xai
You can also use an npm package such as @acme/opencode-provider or an absolute file:// URL for a local package.
Use settings for options supported by the selected package.
Models
Add a model under a provider’s models map. The object key is the model ID used in OpenCode; modelID is the ID sent to
the provider:
{
"$schema": "https://opencode.ai/config.json",
"model": "openai/coding",
"providers": {
"openai": {
"models": {
"coding": {
"modelID": "gpt-5.2",
"name": "GPT-5.2 Coding",
},
},
},
},
}See Models for model selection, defaults, capabilities, limits, costs, and variants.