RouteMux Docs
IntegrationsDev tool

Qwen Code

Point Qwen Code at RouteMux with three environment variables, or a provider entry in settings.json.

Qwen Code speaks four protocols and picks one via its auth type. The OpenAI-compatible path is the shortest route to RouteMux.

Environment variables

export OPENAI_API_KEY="sk-..."                        # your RouteMux key
export OPENAI_BASE_URL="https://api.routemux.com/v1"
export OPENAI_MODEL="openai/gpt-5.5"                  # alias: QWEN_MODEL

Then run qwen in your project. Exporting OPENAI_API_KEY is what selects the OpenAI-compatible auth type — a provider-specific key variable alone will not.

Or define a provider in settings.json

Keep it at user scope, ~/.qwen/settings.json, which the docs recommend to avoid merge conflicts:

{
  "modelProviders": [
    {
      "id": "routemux",
      "name": "RouteMux",
      "baseUrl": "https://api.routemux.com/v1",
      "envKey": "ROUTEMUX_API_KEY"
    }
  ],
  "security": { "auth": { "selectedType": "openai" } },
  "model": { "name": "routemux" }
}

model.name must match a provider id. With this saved, qwen starts without the interactive /auth step. Inside the CLI, /model switches between configured models grouped by protocol, and /doctor prints the resolved auth state.

Where the key comes from, in priority order

  1. CLI flags such as --openai-api-key — always wins
  2. The shell environment
  3. A .env file — only sets what is not already in the environment
  4. settings.jsonenv — lowest priority, and stores the key in plaintext

Only one .env file is read

Qwen Code loads the first .env it finds and does not merge across files. It walks upward from the working directory checking .qwen/.env then .env, and falls back to ~/.qwen/.env then ~/.env. Put project secrets in .qwen/.env — it avoids clashing with other tools and is easy to keep out of version control.

Other protocols

/authCustom Provider also connects Anthropic, Gemini and other compatible endpoints. If you want Claude models, that is the path you need: they are served only on Anthropic Messages here, and the base URL convention differs — see the compatibility matrix.

Verify

curl https://api.routemux.com/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/gpt-5.5","messages":[{"role":"user","content":"ping"}]}'

Troubleshooting

SymptomCause
Wrong auth type selectedA provider-specific key variable was exported instead of OPENAI_API_KEY.
Key changes have no effectSomething higher in the priority list is winning — a CLI flag or an already-exported shell variable overrides .env.
Variables in a second .env ignoredOnly the first file found is read; they are not merged.
404 on every requestOPENAI_BASE_URL is missing /v1.
400 MODEL_PROTOCOL_UNSUPPORTEDA Claude model over the OpenAI-compatible auth type. Use a Custom Provider on the Anthropic protocol.
Model rejectedId does not match GET /v1/models.
422 BILLING_INSUFFICIENT_CREDITSWallet lacks credit. Failed requests are not billed.

On this page