File size: 1,628 Bytes
a0764ea | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # Providers (OpenCode V2)
OpenCode includes a provider and model catalog from models.dev. For most providers, connect an account first, then select a model.
## Setup
Run /connect, choose a provider, and enter its credentials. Then run /models to select one of its models.
## Custom
Add a provider when its API is not already in the catalog. This OpenAI-compatible example defines the credential, runtime package, endpoint, and first model together.
Example:
{
"$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 the provider ID used in model references, such as acme/qwen3-coder.
Fields: name, env, package, canonical, compatibility, settings, headers, body, models.
## Endpoint
Override settings.baseURL to send a catalog provider through a proxy or compatible endpoint.
## Packages
Native package options include openai, openai-compatible, anthropic, google, azure, amazon-bedrock, openrouter, xai, etc. You can also use npm packages or file:// URLs.
## Errors
- No model is available for session: no enabled model selectable.
- Model unavailable: provider/model: provider inactive, model ID absent/disabled, or discovery no longer returns it.
- Cannot initialize provider/model: a placeholder remains in baseURL. Set that variable on the OpenCode server or replace the template with a complete endpoint.
|