Skip to content
RU

OpenCode

Connect OpenCode to Mixen — pay from your balance in roubles, a terminal coding agent with a catalog of 105+ models.

Terminal window
npm install -g opencode-ai

Or with Homebrew (macOS/Linux):

Terminal window
brew install anomalyco/tap/opencode

Create opencode.json in your project root (or globally at ~/.config/opencode/opencode.json):

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"mixen": {
"npm": "@ai-sdk/openai-compatible",
"name": "Mixen AI",
"options": {
"baseURL": "https://api.mixen.ai/v1",
"apiKey": "{env:MIXEN_API_KEY}"
},
"models": {
"gpt-5.6-sol": { "name": "GPT-5.6 Sol", "id": "openai/gpt-5.6-sol" },
"claude-opus-5": { "name": "Claude Opus 5", "id": "anthropic/claude-opus-5" },
"glm-5.3": { "name": "GLM 5.3", "id": "z-ai/glm-5.3" },
"glm-5.3-flash": {
"name": "GLM 5.3 Flash",
"id": "z-ai/glm-5.3-flash",
"tool_call": true
}
}
}
},
"model": "mixen/gpt-5.6-sol"
}

Key points:

  • npm: "@ai-sdk/openai-compatible" — the driver for the /v1/chat/completions protocol that Mixen speaks.
  • The key in models is a short name for OpenCode’s picker, while the id property is the identifier actually sent to the API. Mixen IDs contain a slash (openai/gpt-5.6-sol), so it goes into id, and the model field references the key: mixen/gpt-5.6-sol.
  • A model’s entry in models accepts extra properties: "tool_call": true — tool-calling support (important for agent work), "reasoning": true — a reasoning-capable model; the allowed property names are listed in the config.json schema.
  • {env:MIXEN_API_KEY} pulls the key from an environment variable, keeping it out of the git-tracked config. Alternatively run /connectOther → ID mixen → paste the key: it is stored in a local auth file and picked up by matching the provider ID.

The API key environment variable (mxn-… keys are issued in the dashboard):

Terminal window
export MIXEN_API_KEY="your-api-key" # add to ~/.bashrc or ~/.zshrc to persist
Terminal window
opencode

The default model comes from the model field; switch it any time inside the session with the /models command.

OpenCode has two work modes, toggled with the Tab key (the indicator sits in the lower-right corner):

  • Build — the main mode: the agent edits files and runs commands;
  • Plan — the agent only analyzes and proposes a change plan, without touching the project. Handy for running a complex task through Plan first, then repeating it in Build.

For routine jobs there are subagents — invoked by the primary agent or manually via @: @general for multi-step research, @explore for a fast read-only sweep of the codebase, @scout for read-only research of external docs and dependencies. Custom roles are added as files under .opencode/agents/ (project) or ~/.config/opencode/agents/ (global) — the filename becomes the agent name. Example .opencode/agents/review.md:

---
description: Review changes before a commit
model: mixen/glm-5.3-flash
mode: subagent
permission:
edit: deny
bash: ask
---
You are a strict reviewer. Check the changes for: leaked secrets,
broken error handling, non-obvious names. Answer with a list of
findings with file and line; if there are none, say so.
  • model: mixen/glm-5.3-flash — each agent can have its own model; subagents inherit the calling agent’s model by default.
  • permission allows or denies tools (edit, bash, webfetch and others; levels allow / ask / deny, with glob patterns like "git push": "ask").
  • The file body below the frontmatter is the agent’s system prompt.
Command What it does
/models Switch the model inside the session
/connect Store a provider key in the local auth file
/init Create an AGENTS.md in the project root — rules for the agent
/undo, /redo Revert and re-apply the agent’s changes
/share A link to the current conversation (conversations aren’t shared by default)

Typing @ opens a fuzzy search over the project’s files — and an image can be dragged into the terminal to add it to the context.

An agent session is dozens of turns sharing the same growing prefix: the rules, the files read, the edit history. That prefix fits the prompt cache perfectly:

  • repeated context within 5 minutes is billed at ~10% of the input price (for claude-sonnet-5 — 21.4 ₽ per 1M instead of 213.9 ₽, for glm-5.3-flash — 1.7 ₽), and every hit extends the window by another 5 minutes — a dense session stays cached from start to finish;
  • a pause longer than 5 minutes resets the cache: the next turn pays the full input price, then the discount accumulates again;
  • don’t edit AGENTS.md and rules mid-session — a prefix change resets the cache.

A typical role layout:

Role Model Price per 1M tokens
Primary agent: edits, hard tasks anthropic/claude-sonnet-5 213.9 / 1069.5 ₽
Subagents: review, search, doc research z-ai/glm-5.3-flash 8.4 ₽ input / 27.9 ₽ output

This way the subagent routine runs on a cheap model while a flagship makes the decisions. When calling the API directly, reasoning depth is regulated by reasoning_effort (from off to max; a model’s levels are in GET /v1/modelscapabilities.reasoning_efforts), and remember that reasoning spends the answer budget.

Model ID
GPT-5.6 Sol openai/gpt-5.6-sol
Claude Opus 5 anthropic/claude-opus-5
GLM 5.3 z-ai/glm-5.3
DeepSeek V4 Pro deepseek/deepseek-v4-pro
Kimi K3 moonshotai/kimi-k3

Full list — in the catalog. Add the models you need to the models section of the config as shown above.

  • 401 / Invalid API KeyMIXEN_API_KEY is not set in the session where OpenCode runs (check with echo $MIXEN_API_KEY), or the key was copied incompletely.
  • Model not found — the model field is built as mixen/<key from models>; the key is the short slash-free name, the slash stays inside id.
  • Requests go to another provider — the selected model is not from mixen/*: switch it with /models or set the model field in the config.
  • The agent doesn’t call tools — file and command support depends on tool calling in the specific model; try another one from the catalog and give it "tool_call": true in the config.
  • Plan mode makes no edits — that’s expected: Plan only proposes changes; switch to Build with the Tab key to apply them.