Overview
OpenCode provides two AI gateway providers — OpenCode Zen (pay-as-you-go) and OpenCode Go (subscription-based). Both expose an OpenAI-compatible API that proxies to a curated set of models from multiple underlying providers (OpenAI, Anthropic, Google, DeepSeek, xAI, Kimi, Qwen, MiniMax, GLM, and more). Bifrost implements both providers through a shared codebase, differing only in default base URL and provider key. Key features:- Full OpenAI compatibility — Standard Chat Completions
/v1/chat/completionsformat - Multi-model access — GPT, Claude, Gemini, DeepSeek, Grok, Kimi, Qwen, and more through a single API key
- Curated quality — Models are tested and verified by the OpenCode team for coding agent performance
- Two gateways — Zen (pay-as-you-go with per-token billing) and Go (subscription-based)
- Streaming support — Server-Sent Events with delta-based updates
- Reasoning — Chat models return
reasoningcontent andreasoning_tokensin usage
Supported Operations
| Operation | Non-Streaming | Streaming | Endpoint |
|---|---|---|---|
| Chat Completions | ✅ | ✅ | /v1/chat/completions |
| Responses API | ✅ | ✅ | /v1/chat/completions (converted) |
| List Models | ✅ | - | /v1/models |
| Embeddings | ❌ | ❌ | - |
| Image Generation | ❌ | ❌ | - |
| Speech (TTS) | ❌ | ❌ | - |
| Transcriptions (STT) | ❌ | ❌ | - |
| Files | ❌ | ❌ | - |
| Batch | ❌ | ❌ | - |
Unsupported Operations (❌): Embeddings, Image Generation, Speech, Transcriptions, Files, and Batch are not supported by the OpenCode API. These return
UnsupportedOperationError.Setup & Configuration
Choosing a Gateway
| OpenCode Zen | OpenCode Go | |
|---|---|---|
| Billing | Pay-as-you-go (per token) | Subscription-based |
| Base URL | https://opencode.ai/zen | https://opencode.ai/zen/go |
| Provider key | opencode-zen | opencode-go |
| API key | From opencode.ai/auth | From OpenCode Go subscription |
| Models | Full catalog (~50 models) | Curated subset |
- Web UI
- config.json (Zen)
- config.json (Go)
- Go SDK
- Navigate to Models > Model Providers. Look for OpenCode Zen or OpenCode Go under Configured Providers. If missing, click Add New Provider and select the desired provider.
- Click Add Key or edit an existing key.
- Set a name for your key.
- Paste your OpenCode API key directly or use an environment variable (for example,
env.OPENCODE_API_KEY). - Set Allowed Models to All Models (default) or the specific model allowlist you want this key to serve.
- Save the provider configuration.
1. Chat Completions
OpenCode Zen and Go use standard OpenAI Chat Completions format. For full parameter reference and behavior, see OpenAI Chat Completions.Request Parameters
All standard OpenAI chat completion parameters are supported, including:model— Model ID (e.g.,deepseek-v4-flash,gpt-5.5,claude-sonnet-4-6)messages— Standard message array withroleandcontentmax_tokens— Maximum output tokenstemperature,top_p,frequency_penalty,presence_penaltystream— Enable SSE streamingtools,tool_choice— Function calling supportreasoning_effort— Control reasoning depth ("none","minimal","low","medium","high","max")
Provider-specific parameters: Not all parameters are forwarded to the underlying model. Bifrost applies standard OpenAI normalization through the OpenAI-compatible handler. Model-specific features (e.g., thinking mode, prompt caching) depend on the underlying provider serving the model.
Responses
All chat models return standard OpenAI response format:Usage & Token Tracking
OpenCode returns comprehensive token usage data:| Field | Description |
|---|---|
usage.prompt_tokens | Input tokens consumed |
usage.completion_tokens | Output tokens generated |
usage.total_tokens | Total tokens for the request |
usage.prompt_tokens_details.cached_tokens | Tokens served from cache (if caching is active) |
usage.completion_tokens_details.reasoning_tokens | Tokens consumed for reasoning/thinking |
prompt_cache_hit_tokens and prompt_cache_miss_tokens fields. Bifrost maps these into the standard cached_tokens field for pricing calculations.
Error Format
OpenCode uses a custom error format that differs from standard OpenAI errors:| Error Type | HTTP Status | Description |
|---|---|---|
AuthError | 401 | Invalid or missing API key |
ModelError | 400/404 | Requested model is not available |
insufficient_quota | 429 | Quota exceeded |
server_error | 5xx | Internal server error |
context_length_exceeded | 400/413 | Input exceeds model context window |
2. Responses API
The Responses API is converted internally to Chat Completions:3. List Models
OpenCode’s model listing endpoint returns the available models for your gateway tier. Model IDs are prefixed with the provider key in Bifrost (e.g.,opencode-go/deepseek-v4-flash).
Zen typically exposes 50+ models across all supported providers. Go exposes a curated subset focused on coding agent performance. Available models are discovered automatically at startup via the /v1/models endpoint.
Pricing
OpenCode Zen pricing is publicly available at opencode.ai/docs/zen. OpenCode Go pricing is subscription-based. Bifrost does not yet include OpenCode entries in the central pricing datasheet.Pricing Overrides
Until central datasheet entries are available, usepricing_overrides in your configuration to set per-model rates. These take precedence over the datasheet:
pricing_url and model_parameters_url to local JSON files with per-model entries. See the Pricing & Model Parameters guide for details.
Unsupported Features
| Feature | Reason |
|---|---|
| Embedding | Not offered by OpenCode API |
| Image Generation | Not offered by OpenCode API |
| Speech/TTS | Not offered by OpenCode API |
| Transcription/STT | Not offered by OpenCode API |
| Batch Operations | Not offered by OpenCode API |
| File Management | Not offered by OpenCode API |
| WebSocket Responses | Not offered by OpenCode API |
Caveats
No Central Datasheet Entries Yet
No Central Datasheet Entries Yet
Severity: Low
Behavior: OpenCode models do not yet have entries in the central Bifrost pricing datasheet. Cost tracking and context window awareness require local overrides.
Resolution: Use
pricing_overrides in config.json (see Pricing section) for per-model rates. Use pricing_url and model_parameters_url for context window sizes and capability metadata.Error Format Differs from OpenAI
Error Format Differs from OpenAI
Severity: Low
Behavior: OpenCode returns
{"type":"error","error":{"type":"...","message":"..."}} instead of OpenAI’s {"error":{...}} envelope. Bifrost’s custom error converter handles this transparently.
Impact: No user impact — error messages are correctly extracted and presented.Go Models Are a Subset of Zen
Go Models Are a Subset of Zen
Severity: Low
Behavior: OpenCode Go exposes fewer models than Zen. Attempting to use a Zen-only model on Go (e.g.,
big-pickle) returns a model-not-found error.
Resolution: Check opencode.ai/docs/zen for the current Go model list, or query /v1/models on your Go endpoint.Cache Behavior Varies by Underlying Model
Cache Behavior Varies by Underlying Model
Severity: Low
Behavior: Prompt caching support depends on the underlying provider serving the model. Some models report
cached_tokens in usage; others (e.g., DeepSeek V4 Flash on Go) may not cache at all.
Impact: Cache-aware pricing only applies when cache tokens are reported. Verify model-specific cache behavior if you depend on cache cost savings.
