> ## Documentation Index
> Fetch the complete documentation index at: https://gomodel-feat-guardrails.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode Go

> Configure OpenCode Zen (Go subscription) in GoModel using an OpenAI-compatible endpoint.

[OpenCode Zen](https://opencode.ai/docs/zen/) exposes its "Go" subscription
models behind an OpenAI-compatible API. GoModel ships a native `opencode_go`
provider that defaults the base URL, so you only need an API key.

## Configure

```bash theme={null}
OPENCODE_GO_API_KEY=sk-...
```

Or in `config.yaml`:

```yaml theme={null}
providers:
  opencode_go:
    type: opencode_go
    api_key: "${OPENCODE_GO_API_KEY}"
    # Optional: override the default endpoint.
    # base_url: "https://opencode.ai/zen/go/v1"
```

The default base URL is `https://opencode.ai/zen/go/v1`. Authentication uses
`Authorization: Bearer <api_key>` with the key generated in the OpenCode Zen
console.

## Models

`GET /v1/models` proxies OpenCode Zen's model list, exposing IDs such as
`glm-5.1`, `kimi-k2.7-code`, `deepseek-v4-pro`, and `mimo-v2.5-pro`. Restrict the
advertised set with a configured list when you only want a subset:

```bash theme={null}
OPENCODE_GO_MODELS=glm-5.1,kimi-k2.7-code,deepseek-v4-pro
```

## Endpoints

OpenCode Zen serves most models on OpenAI-style `/chat/completions` (Bearer
auth) and a few models only on the Anthropic-native `/messages` endpoint
(`x-api-key` auth). GoModel routes per model:

* **OpenAI-style models** (GLM, Kimi, DeepSeek, MiMo, MiniMax, most Qwen) go to
  `/chat/completions`. `/models` and `/v1/responses` (translated to chat
  completions) use the same path.
* **Anthropic-only models** are translated to the Anthropic Messages dialect and
  sent to `/messages`, mirroring how GoModel already serves native Anthropic.
  Both paths normalize to the same OpenAI-compatible response, so clients see
  one consistent surface regardless of which model they pick — whether they call
  `/v1/chat/completions` or `/v1/messages`.

The set of `/messages`-only models is currently maintained manually (default:
`qwen3.7-max`) because OpenCode Zen does not yet expose per-model endpoint
metadata. Override it when needed:

```bash theme={null}
OPENCODE_GO_MESSAGES_MODELS=qwen3.7-max
```

<Note>
  This manual split is temporary and will be replaced by metadata-driven routing
  once the upstream model list distinguishes endpoints.
</Note>

## Session header

OpenCode Zen asks every client to send an `x-opencode-session` header so it
can route one conversation to the same upstream and keep its prompt cache
warm. Upstream has announced that requests without it may start failing.
GoModel adds the header to every OpenCode Go request by default, on both the
`/chat/completions` and `/messages` paths, using the first available value:

1. An `x-opencode-session` header sent by the client (OpenCode itself, pi, and
   other tools that speak OpenCode Zen's dialect) is forwarded verbatim.
2. Otherwise the session GoModel detected through
   [session keeping](/features/session-keeping): OpenCode's `X-Session-Id`,
   Claude Code's session id, a session body field, or the content-derived
   `auto-…` id for agents that send no signal at all.

A request with no detectable session is sent without the header. GoModel also
identifies itself with `x-opencode-client` (forwarding the client's own value
when present, `gomodel` otherwise) and a `gomodel/<version>` User-Agent, as
the upstream [usage guidelines](https://opencode.ai/docs/go/#where-can-i-use-it)
require.

Disable session forwarding only if upstream asks you to:

```bash theme={null}
OPENCODE_GO_SESSION_HEADER=false
```

## Reasoning

Some OpenCode Zen models always think and reject requests that leave the
reasoning parameter out:

```text theme={null}
[1210] This model always engages in thinking and cannot be disabled; please use low, high, or max
```

GoModel therefore sends `reasoning_effort: "low"` on `/chat/completions` when a
request carries no reasoning parameter at all. Models that ignore the parameter
are unaffected. Raise the default per deployment:

```bash theme={null}
OPENCODE_GO_DEFAULT_REASONING_EFFORT=high
```

Set it to `none` (or `off`) to inject nothing and forward requests untouched.

Clients keep control when they ask for reasoning themselves: nothing is injected
over an explicit `reasoning.effort` or a top-level `reasoning_effort`. GoModel's
recognized effort levels are mapped to their nearest equivalent in the low /
high / max set OpenCode Zen accepts:

| Requested effort         | Sent upstream |
| ------------------------ | ------------- |
| `none`, `minimal`, `low` | `low`         |
| `medium`                 | `low`         |
| `high`                   | `high`        |
| `xhigh`, `max`           | `max`         |

Any other value (`turbo`, say) is forwarded unchanged for the upstream to judge.
`reasoning.effort` is GoModel's canonical field, so a request that sets both it
and a top-level `reasoning_effort` is sent with the mapped `reasoning.effort` —
the same precedence every other GoModel provider applies.

Models routed to `/messages` use the Anthropic thinking dialect instead and are
not affected by this mapping.

## Not supported

* Embeddings (returns `invalid_request_error`).
