Since 10-13 Zen answers 403 FreeTierError ("OpenCode's free tier can only
be used from within OpenCode") to a free-model request that isn't
OpenCode's. npm still serves 0.1.1, which gets that 403 on every model;
0.1.5's OpenCode-form session id (9074723) fixed it but never reached npm.
The owner allows mimicking OpenCode's client on this route (client
mimicry is allowed for every vendor but Claude Code), so this reverses
643ef50's README note.
Diffed against the release binary itself: OpenCode 1.19.0
(anomalyco/opencode v1.19.0) run in a sandbox HOME with the opencode
provider's baseURL pointed at a local capture server, on chat, responses
and messages. It sends accept */*, content-type, user-agent
"opencode/1.19.0 ai-sdk/provider-utils/<v> runtime/bun/1.3.14" (4.0.23
chat, 4.0.40 responses, 4.0.46 messages), x-opencode-project, -session,
-request, -client, -session-id, and the key (authorization, or x-api-key
with anthropic-version). It sends no x-session-id or x-session-affinity
to its own gateway (session/llm/request.ts). 0.1.5 differed in: those two
extra headers, accept text/event-stream, the chat UA on every protocol,
and every header the caller sent going on (through magpie: the agent's
own User-Agent, x-stainless-*, anthropic-beta...).
0.1.6 builds the upstream headers from that list alone: the caller's are
read only for the session and project, anthropic-version/-beta kept on
messages. The new per-protocol test checks the exact set and fails on
0.1.5 (4 fails); the forced-streaming test now expects no
x-session-id/x-session-affinity.
Run:
- bun test in packages/zen-free: 169 pass, 3 runs; bun scripts/check.mjs
zen-free passes.
- Real opencode.ai, anonymous key "public": npm's 0.1.1 gets 403
FreeTierError on big-pickle, mimo-v2.6-flash-free and
muse-spark-1.3-contributor-free, streamed and not. 0.1.6's
tools-smoke.mjs: 200 with a Bash call on all three streamed and on
big-pickle not streamed; muse non-streamed 200 without a call;
mimo non-streamed timed out at 90s, the same on 0.1.5.
- magpie 0.1.1208 in a sandbox HOME (scripts/try.sh zen-free): sign-in
with public, then `provider test opencode-zen-free`: chat (big-pickle)
and responses (muse-spark) both pass.
Not tried: a messages-protocol free model (Zen has none free now), Windows.
OpenCode Zen Free
OpenCode Zen's free models in magpie and OpenCode. Provider id:
opencode-zen-free.
Since 2026-10-13 Zen's free tier answers 403 FreeTierError ("can only be used from within OpenCode") to a request that isn't OpenCode's. From 0.1.6 the plugin sends a free-model request with exactly the headers OpenCode 1.19.0 sends to Zen, and a session id of OpenCode's own form. Older versions (0.1.1 on npm before it) get the 403: update the plugin.
Install
magpie plugin add @magpie-community/opencode-zen-free-auth
magpie plugin login opencode-zen-free
Sign in
Enter public in the key field. No personal API key is needed.
The credential is kept in OpenCode's auth.json or magpie's
plugin-auth.json.
Models
The plugin discovers Zen's current free models, including their context
windows and reasoning levels. Use opencode-zen-free/<model>, for example
opencode-zen-free/big-pickle.
Retired models and SystemOne models are excluded. The list is asked again each time the host lists models (magpie does this on start and every hour): a model Zen no longer gives free leaves it, and a new free one joins it. When Zen's list can't be read, the last list is kept. A request for a model that isn't free now gets a 404 naming the free ones; one made free since the last list is served after the list is asked again (at most once a minute). Availability and rate limits are set by Zen; the plugin has no remaining-quota data.
Requests
Requests go to https://opencode.ai/zen/v1 using each model's native
Chat Completions, Responses or Anthropic Messages API. Streaming and
ordinary JSON replies are supported.
The agent's tools are preserved. Zen's models often call OpenCode's own
tool names; such a call is given the agent's tool whose name differs only
in case (bash to Bash), or else only in case and _/- (todowrite
to todo_write, webfetch to web_fetch), when exactly one does. A
call with no such tool (or with no name) is left out of the reply, and
the reply's text says which name was left out; a turn whose every call
was left out ends as an ordinary answer. Tools run in the agent.
Zen's free tier only answers a request that carries tools, so a request
is sent with the five core OpenCode tools the agent doesn't declare
itself (bash, edit, glob, grep, read), described as not
available. A call of one of them the agent doesn't have is left out like
any other.
Now and then Zen closes a streamed Chat Completions reply before its
[DONE]. When the reply has said something and no tool call of it is
unfinished, it ends there as an ordinary answer, and its text says it was
cut short; asking again goes on. A reply cut short with a tool call
unfinished, with nothing said, or collapsed for a client that doesn't
stream fails with an error naming the reply's id and how much of it came.
An Anthropic Messages or Responses reply cut short fails too: magpie
tells it from a whole one and, where the model can, goes on with it.