Opencode
Overview
Section titled “Overview”Opencode exposes two OpenAI-compatible AI gateways that share a single DeepIntShield implementation, differing only in default base URL and provider key:
| Provider Key | Gateway | Default Base URL | Billing |
|---|---|---|---|
opencode-zen | Opencode Zen | https://opencode.ai/zen | Pay-as-you-go |
opencode-go | Opencode Go | https://opencode.ai/zen/go | Subscription |
Key features:
- Full OpenAI compatibility - Identical request/response format
- Streaming support - Server-Sent Events with delta-based updates
- Tool calling - Complete function definition and execution support
- Opencode-aware errors - Parses Opencode’s
{"type":"error","error":{...}}envelope
Supported Operations
Section titled “Supported Operations”| Operation | Non-Streaming | Streaming | Endpoint |
|---|---|---|---|
| Chat Completions | ✅ | ✅ | /v1/chat/completions |
| Responses API | ✅ | ✅ | /v1/chat/completions |
| List Models | ✅ | - | /v1/models |
| Text Completions | ❌ | ❌ | - |
| Embeddings | ❌ | ❌ | - |
| Image Generation | ❌ | ❌ | - |
| Speech (TTS) | ❌ | ❌ | - |
| Transcriptions (STT) | ❌ | ❌ | - |
| Files | ❌ | ❌ | - |
| Batch | ❌ | ❌ | - |
Configuration
Section titled “Configuration”Add Opencode as a provider with a single API key. Choose the provider key for the gateway you subscribe to:
{ "provider": "opencode-zen", "keys": [{ "value": "env.OPENCODE_API_KEY", "models": [], "weight": 1.0 }]}For the subscription gateway use "provider": "opencode-go". Both default base URLs can be overridden per workspace.
1. Chat Completions
Section titled “1. Chat Completions”Request Parameters
Section titled “Request Parameters”Opencode supports the standard OpenAI chat completion parameters. For full parameter reference and behavior, see OpenAI Chat Completions.
2. Responses API
Section titled “2. Responses API”The Responses API is converted internally to Chat Completions and the chat response is mapped back to the Responses shape.
3. List Models
Section titled “3. List Models”Opencode’s model listing endpoint returns available models at /v1/models.
Error Handling
Section titled “Error Handling”Opencode returns errors in a custom envelope rather than the OpenAI shape:
{ "type": "error", "error": { "type": "...", "message": "..." } }DeepIntShield parses this envelope so the surfaced error message and type reflect Opencode’s response while preserving the HTTP status code.