Skip to content
RU

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.

Terminal window
npm install -g @qwen-code/qwen-code@latest

Node.js 22+ is required. Alternatives — Homebrew (brew install qwen-code) and standalone scripts for Linux/macOS and Windows in the official repository.

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.
  • id is the Mixen model ID, sent to the API as is; model.name must match one of the ids in the list.
  • envKey is the name of the environment variable holding the key, not the key itself. If omitted, the openai protocol falls back to OPENAI_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):

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

The 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.

Terminal window
qwen

Useful 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):

Terminal window
qwen --auth-type openai --model z-ai/glm-5.3-flash \
--openai-api-key your-api-key --openai-base-url https://api.mixen.ai/v1

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.

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.

  • 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.
  • 401 / Invalid API KeyMIXEN_API_KEY is not set in the session running the CLI (check echo $MIXEN_API_KEY), or the key was copied incompletely.
  • “Model not found”model.name must match the id of a modelProviders entry, not its name field.
  • Requests go somewhere other than Mixensecurity.auth.selectedType is missing (check /auth), or /model has a different provider’s model selected.
  • Variables from .env are not picked up — only the first .env found in the search chain applies; variables from different files are not merged.