Instruct-opencode_V2 / docs /providers.md
ctaxnagomi's picture
Add providers doc
a0764ea verified
|
Raw History Blame Contribute Delete
1.63 kB
# 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.