providers
overlays from your configuration. A provider needs both a usable runtime package and, when required, an
active connection.
Connect a provider
Run/connect in the TUI, choose an integration, and complete one of the methods it offers:
/connect are stored by the OpenCode service in its database. Run /connect again to replace
or remove a stored credential.
Providers from Models.dev also declare their standard environment variables. A non-empty declared variable is exposed
as an environment connection automatically, so common providers usually need no config:
env declares the variables that can supply its key:
opencode.jsonc
env, then settings.apiKey. Use config substitution instead of committing a literal key:
opencode.jsonc
Configure
Theproviders 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. |
settings and body are deep-merged. Headers are
merged case-insensitively. At request time, provider values are inherited by the model, model values override them, and
the selected variant is applied last.
Endpoint
Overridesettings.baseURL to send an existing provider through a proxy or compatible endpoint. Its existing package,
models, and connection continue to apply:
opencode.jsonc
settings is package-specific. A field only has an effect when the selected package supports it.
Headers and body
Headers and body fields can be set at provider, model, or variant scope:opencode.jsonc
/connect, env, or settings.apiKey for
provider credentials unless the endpoint explicitly requires a custom header.
Provider packages
For an OpenAI-compatible service, use the V2 native compatible package. The model map is explicit because a custom provider has no Models.dev catalog entries:opencode.jsonc
env for an endpoint that does not require authentication. The native compatible package requires
settings.baseURL and uses bearer authentication when a key is available.
The package field supports two runtime contracts:
| Form | Contract |
|---|---|
"@opencode-ai/llm/providers/openai-compatible" | A V2 native package exporting model(modelID, settings). An npm specifier or absolute file:// URL may use the same contract. |
"aisdk:@ai-sdk/openai-compatible" | An AI SDK provider package. The aisdk: prefix is required. |
settings plus the resolved apiKey, headers, body, and limits. AI SDK
packages receive their merged provider options. Use a package’s own documentation for accepted settings; OpenCode does
not validate package-specific keys.
package may also be set on one model to override the provider package for that model.
Models
Add a model under a provider’smodels map. The object key is the model ID used in OpenCode; modelID is the ID sent to
the provider:
opencode.jsonc