Skip to main content

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/completions format
  • 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 reasoning content and reasoning_tokens in usage

Supported Operations

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

Configure either provider (or both) in Bifrost:
  1. 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.
  2. Click Add Key or edit an existing key.
  3. Set a name for your key.
  4. Paste your OpenCode API key directly or use an environment variable (for example, env.OPENCODE_API_KEY).
  5. Set Allowed Models to All Models (default) or the specific model allowlist you want this key to serve.
  6. 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 with role and content
  • max_tokens — Maximum output tokens
  • temperature, top_p, frequency_penalty, presence_penalty
  • stream — Enable SSE streaming
  • tools, tool_choice — Function calling support
  • reasoning_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: Cache tracking depends on the underlying model. Some providers report 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:
Bifrost’s custom error converter parses this format transparently. Error types include:

2. Responses API

The Responses API is converted internally to Chat Completions:
Same parameter mapping and message conversion as 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, use pricing_overrides in your configuration to set per-model rates. These take precedence over the datasheet:
For context window sizes and model capability metadata, point pricing_url and model_parameters_url to local JSON files with per-model entries. See the Pricing & Model Parameters guide for details.

Unsupported Features


Caveats

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.
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.
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.
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.