Share feedback
Answers are generated based on the documentation.

OpenCode Go

Use OpenCode Go models with Docker Agent.

Overview

OpenCode Go is a low-cost subscription service ($5 first month, then $10/month) that provides reliable access to popular open-source coding models. It serves models through both OpenAI-compatible and Anthropic-compatible APIs from globally distributed endpoints.

Docker Agent includes built-in support for OpenCode Go as an alias provider.

Setup

  1. Subscribe to OpenCode Go at opencode.ai/auth

  2. Copy your API key from the console

  3. Set the environment variable:

    export OPENCODE_API_KEY=your-api-key

Usage

Inline Syntax

The simplest way to use OpenCode Go:

agents:
  root:
    model: opencode-go/deepseek-v4.1-flash
    description: Assistant using OpenCode Go
    instruction: You are a helpful assistant.

Named Model

For more control over parameters:

models:
  my_model:
    provider: opencode-go
    model: deepseek-v4-pro
    temperature: 0.7
    max_tokens: 8192

agents:
  root:
    model: my_model
    description: Assistant using OpenCode Go
    instruction: You are a helpful assistant.

Available Models

You can retrieve the full, up-to-date model list at any time:

curl https://opencode.ai/zen/go/v1/models

OpenAI-Compatible

These models use the /v1/chat/completions endpoint and work directly with the opencode-go alias:

ModelDescription
deepseek-v4.1-flashFast and cost-effective DeepSeek model
deepseek-v4-proMost capable DeepSeek model
kimi-k2.7-codeKimi K2.7 optimized for code
kimi-k2.6Kimi K2.6 model
kimi-k2.5Kimi K2.5 model
glm-5.2GLM 5.2 flagship model
glm-5.1GLM 5.1 model
glm-5GLM 5 model
mimo-v2.5MiMo V2.5 efficient model
mimo-v2.5-proMiMo V2.5 Pro model
mimo-v2-proMiMo V2 Pro model
mimo-v2-omniMiMo V2 Omni model
hy3-previewHY3 preview model

Anthropic-Compatible

These models use the /v1/messages endpoint and require a custom provider definition:

ModelDescription
minimax-m3MiniMax M3 model
minimax-m2.7MiniMax M2.7 model
minimax-m2.5MiniMax M2.5 model
qwen3.7-maxQwen 3.7 Max model
qwen3.7-plusQwen 3.7 Plus model
qwen3.6-plusQwen 3.6 Plus model
qwen3.5-plusQwen 3.5 Plus model

To use an Anthropic-compatible model, define a custom provider:

providers:
  opengo-ant:
    provider: anthropic
    base_url: https://opencode.ai/zen/go
    token_key: OPENCODE_API_KEY

models:
  qwen:
    provider: opengo-ant
    model: qwen3.7-max

agents:
  root:
    model: qwen
    description: Assistant using Qwen through OpenCode Go
    instruction: You are a helpful assistant.

How It Works

OpenCode Go is implemented as a built-in alias in Docker Agent:

  • API Type: OpenAI-compatible (openai_chatcompletions)
  • Base URL: https://opencode.ai/zen/go/v1
  • Token Variable: OPENCODE_API_KEY

This alias uses the OpenAI Chat Completions client, not the custom Messages configuration above. Reusing a client does not guarantee every upstream feature; Messages signatures, beta support, caching and pricing do not carry over by default. See Claude access paths.

For Anthropic-compatible models (MiniMax, Qwen), Docker Agent uses a custom provider pointing to the Anthropic client at https://opencode.ai/zen/go with the same token.

Session Header

OpenCode asks clients to send an x-opencode-session header carrying one stable ID per conversation, which it uses to optimise routing and prompt caching. Docker Agent sends it on every direct request to opencode.ai, whether the model goes through the built-in alias or a custom provider on the OpenAI, Anthropic or Google client, deriving an opaque value from the agent session so each conversation keeps the same ID, including in serve api / serve chat deployments that multiplex many conversations. Requests routed through a models gateway carry the gateway's own session header instead, and the OpenAI client's opt-in transport: websocket setting is ignored for OpenCode models, which stay on SSE so the header is always sent. On the OpenAI client you can pin your own value through provider_opts.http_headers.x-opencode-session; the Anthropic and Google clients do not read http_headers.

Example: Code Assistant

agents:
  coder:
    model: opencode-go/deepseek-v4.1-flash
    description: Expert code assistant
    instruction: |
      You are an expert programmer using DeepSeek V4.1 Flash.
      Write clean, efficient, well-documented code.
      Explain your reasoning when helpful.
    toolsets:
      - type: filesystem
      - type: shell
      - type: think

Usage Limits

OpenCode Go subscriptions include the following limits:

  • 5-hour rolling limit — $12 of usage
  • Weekly limit — $30 of usage
  • Monthly limit — $60 of usage

Limits are defined as dollar values. More expensive models allow fewer requests per limit period. You can also add Zen balance to continue usage beyond the limits.