Upstream now fingerprints the client on every tier. The gateway's request shape
no longer passes, so both the keyless free tier and the keyed lanes come back as
403 {"type":"error","error":{"type":"FreeTierError","message":"OpenCode's
free tier can only be used from within OpenCode..."}}
Reproduced by replaying the gateway's exact request against the live endpoint,
and cross-checked by capturing what the official client (@opencode/cli@2.0.29)
puts on the wire.
Three things are checked, and each one alone is enough to fail the request:
1. Endpoint. Keyless traffic moved off /zen onto https://opencode.ai/inference.
Keyed traffic still uses /zen (or /inference/openai), so the anonymous lane
gets its own `upstream.anonymous` base instead of sharing `upstream.zen`.
2. Header shape. Upstream wants the client's own headers: a
"opencode/<channel>/<version>/cli" User-Agent, x-opencode-session-id, a bare
40-character hex x-opencode-project, and no x-opencode-request. The previous
legacy set — "opencode/1.18.31 (<os> <arch>; <runtime>)" User-Agent, a
"prj_" prefixed project, and the gateway's x-opencode-request — is rejected
on both the keyless and the keyed lanes.
3. Tool definitions. Every tool whose name upstream recognises must carry the
genuine OpenCode definition; a synthesised stub that only reuses the name is
rejected. The gateway now embeds the real definitions captured from the
official client and uses them for the tools it injects, and rewrites any
downstream tool that happens to reuse a recognised name. Unrecognised tool
names still pass through untouched, so downstream function calling keeps
working. `anonymousCoreTools` also drops "bash" in favour of "shell", since
"bash" is a recognised name whose genuine definition the gateway does not
have.
Verified against the live endpoint on both lanes: non-streaming, streaming,
function calling with a downstream tool, /v1/messages and /v1/responses all
return 200. Unit tests cover the request headers, the genuine tool definitions
and the tool rewrite.
Preserve request parameters, tool-call completion reasons and retry session
affinity. Bound upstream header waits, stop expired-context scans and add
opt-in redacted request-body diagnostics.
Isolate Playground diagnostics from production pools, report stream failures
accurately, align readiness with discoverable models and honor Docker listen
configuration.
Split Go and WebUI modules by responsibility, add regression tests and CI,
standardize formatting and rewrite the English and Chinese READMEs.
Refs: #6, #18, #19, #20, #21, #22, #23, #24, #25
Add a top-level "prefer" config field ("zen" or "go", default "go") that
controls which upstream is used when a model is available in both pools,
including during the temporary model-discovery fallback. Previously Zen
was always preferred.