Qwen Code
Connect Qwen Code — the terminal agent from the Qwen team (a Gemini CLI fork) — to Mixen: pay from your balance in roubles, with streaming and tool calling over our OpenAI-compatible /v1/chat/completions.
Installation
Section titled “Installation”npm install -g @qwen-code/qwen-code@latestNode.js 22+ is required. Alternatives — Homebrew (brew install qwen-code) and standalone scripts for Linux/macOS and Windows in the official repository.
Configuration
Section titled “Configuration”Qwen Code speaks several protocols (openai, anthropic, gemini, vertex-ai), and Mixen plugs in as a provider on the openai protocol — the CLI supports any OpenAI-compatible endpoint, with each model entry carrying its own baseUrl.
Create ~/.qwen/settings.json (user scope is the recommended place for modelProviders):
{ "security": { "auth": { "selectedType": "openai" } }, "modelProviders": { "openai": [ { "id": "openai/gpt-5.6-sol", "name": "GPT-5.6 Sol (Mixen)", "envKey": "MIXEN_API_KEY", "baseUrl": "https://api.mixen.ai/v1" }, { "id": "z-ai/glm-5.3-flash", "name": "GLM 5.3 Flash (Mixen)", "envKey": "MIXEN_API_KEY", "baseUrl": "https://api.mixen.ai/v1" } ] }, "model": { "name": "openai/gpt-5.6-sol" }}Key points:
security.auth.selectedType: "openai"— which protocol to use at startup; without it the CLI stays on its default provider and never reaches Mixen.idis the Mixen model ID, sent to the API as is;model.namemust match one of theids in the list.envKeyis the name of the environment variable holding the key, not the key itself. If omitted, theopenaiprotocol falls back toOPENAI_API_KEY— but then a real OpenAI key on the same machine gets in the way, so a dedicated name is cleaner.- Entries are told apart by
id+baseUrl— keep as many Mixen models in the list as you need.
The API key environment variable (mxn-… is issued in the dashboard):
export MIXEN_API_KEY="your-api-key" # add to ~/.bashrc or ~/.zshrc to persistThe CLI looks for .env in this order: .qwen/.env → .env → ~/.qwen/.env → ~/.env (the first file found wins; variables are not merged). Source priority: CLI flags → shell variables → .env → the env block of settings.json.
Running
Section titled “Running”qwenUseful session commands: /auth — switch provider/protocol, /model — switch model (the choice persists across sessions), /effort — reasoning level.
A quick trial without touching the config — the two credential flags (the only ones that exist):
qwen --auth-type openai --model z-ai/glm-5.3-flash \ --openai-api-key your-api-key --openai-base-url https://api.mixen.ai/v1Verifying the connection
Section titled “Verifying the connection”The key and balance are checked with a minimal generating request:
curl https://api.mixen.ai/v1/chat/completions \ -H "Authorization: Bearer your-api-key" \ -H "Content-Type: application/json" \ -d '{"model":"z-ai/glm-5.3-flash","messages":[{"role":"user","content":"ping"}],"max_tokens":5}'200 — the key and balance work; 401 — the key was copied incompletely or it is not a Mixen API key; 402 — the balance is empty. GET /v1/models does not check the key — it answers without one.
Picking a model per task
Section titled “Picking a model per task”Every agent turn resends the accumulated context, so input price matters more than it seems. Prices are per 1M tokens, input/output; full tables with cache columns — in the catalog.
| Task | Model | Input / output |
|---|---|---|
| Code questions, review, small edits | GLM 5.3 Flash (z-ai/glm-5.3-flash) |
8.4 / 27.9 ₽ |
| Multi-file edits in familiar code | GLM 5.3 (z-ai/glm-5.3) |
156 / 490.2 ₽ |
| Complex agentic tasks, unfamiliar codebase | GPT-5.6 Sol (openai/gpt-5.6-sol) |
213.9 / 1069.5 ₽ |
All three are reasoning models: thinking works without extra setup; tool calling support for a specific model is visible in its catalog card.
Tips and specifics
Section titled “Tips and specifics”- Cache savings. Repeated context within 5 minutes is billed at ~10% of the input price (21.4 ₽ per 1M for gpt-5.6-sol instead of 213.9 ₽, 1.7 ₽ for glm-5.3-flash), and every hit extends the window by another 5 minutes — a dense session stays cached from start to finish. Don’t edit project rules (
QWEN.md,AGENTS.md) mid-session: changing the prefix resets the cache. - The limit is 60 RPM per key. That is plenty for dense agent work; on 429 errors reduce the parallelism of subtasks in the client.
- Reasoning eats the response budget — on simple tasks it pays to dial it down.
Troubleshooting
Section titled “Troubleshooting”- 401 / Invalid API Key —
MIXEN_API_KEYis not set in the session running the CLI (checkecho $MIXEN_API_KEY), or the key was copied incompletely. - “Model not found” —
model.namemust match theidof amodelProvidersentry, not itsnamefield. - Requests go somewhere other than Mixen —
security.auth.selectedTypeis missing (check/auth), or/modelhas a different provider’s model selected. - Variables from .env are not picked up — only the first
.envfound in the search chain applies; variables from different files are not merged.