Skip to content
Qwen Code logo (Qwen / Alibaba)

Qwen Code via Tokonomix

Declare Tokonomix as an OpenAI provider in Qwen Code’s settings.json — 130+ models and consensus on one key, from the terminal.

OpenAI-compatible (modelProviders.openai)Agentic coding CLIApache-2.0 · open sourcemacOS · Windows · Linux
Qwen Code — agentic coding CLI, via Tokonomix

What is Qwen Code?

Qwen Code is an open-source agentic command-line coding tool (adapted from Gemini CLI) by the Qwen team. It reads your repo, edits files, runs commands and iterates — and although it ships tuned for Qwen models, it speaks the OpenAI protocol, so any OpenAI-compatible endpoint works.

  • A terminal coding agent: explore, edit, run and iterate over your project.
  • Declares models in ~/.qwen/settings.json under modelProviders, keyed by API protocol (openai, anthropic, …).
  • Reads API keys from an envKey reference (or .env / shell export, which take priority).
  • Open source and model-agnostic via the openai protocol.

Why route Qwen Code through Tokonomix?

Qwen Code already speaks the OpenAI protocol, so Tokonomix slots in as one more openai provider — except this one unlocks 130+ models and a consensus option, not just one vendor.

  • One openai provider entry, 130+ models — switch by changing model.name.
  • Use tokonomix-consensus for the hard reasoning turns, a fast slug for routine edits.
  • Per-call spend caps keep an agentic CLI within budget.
  • Pin by hosting_region / origin_country for regulated code.

Connect Tokonomix in settings.json

Add a Tokonomix entry under modelProviders.openai with the Tokonomix baseUrl and an envKey, then point model.name at the slug you want.

{
  "modelProviders": {
    "openai": [
      {
        "id": "tokonomix-consensus",
        "name": "Tokonomix Consensus",
        "baseUrl": "https://tokonomix.ai/api/v1",
        "envKey": "TOKONOMIX_API_KEY"
      }
    ]
  },
  "env": { "TOKONOMIX_API_KEY": "tok_live_your-key" },
  "security": { "auth": { "selectedType": "openai" } },
  "model": { "name": "tokonomix-consensus" }
}
Keys: prefer .env or export

Per the docs, the env block is the lowest-priority fallback — a shell export TOKONOMIX_API_KEY=… or a .env file overrides it, which is the safer place for the secret.

Verify it works

  • Save ~/.qwen/settings.json and start Qwen Code in a scratch repo.
  • Run a small edit and confirm the model used is your Tokonomix slug.
  • Check the call and token usage in your Tokonomix dashboard.

Model selection

Which model and endpoint should my agent use?

Pick by what your agent does, then swap the model id any time — every model in the catalog works through the same key.

What your agent doesUse this
Edits files / calls tools and streams responses (most coding agents)An Anthropic model via the Anthropic endpoint (tools + streaming both work)
Calls tools but does not need streaming (any model)The OpenAI-compatible endpoint with a single model id
Wants tools and streaming on a non-Anthropic modelRun non-streaming for now — streaming tool-calls on other providers is not enabled yet
Plain chat, no toolsEither endpoint; streaming is fine
Wants a cross-model verdict (consensus) on a high-stakes answerSet model to tokonomix-consensus on the OpenAI-compatible endpoint — note: consensus rejects tool requests (no tool-calling)
Endpoint & API reference (technical)

anthropic-messages → https://tokonomix.ai/api/anthropic — tools ✓, streaming ✓ (use an Anthropic model). openai-completions → https://tokonomix.ai/api/v1 — tools ✓ (single-model passthrough), streaming with tools not yet enabled. Plain chat: streaming works on both. Consensus: openai-completions, model tokonomix-consensus, no tools. Swap the model id to any slug returned by GET /api/v1/models.

Browse all models →

Related agents