Skip to navigation

Qwen Code (gateway)

Route Qwen Code’s LLM calls through the Respan gateway for automatic logging, caching, and model switching. Qwen Code supports any OpenAI-compatible endpoint, so only your RESPAN_API_KEY is needed.

Setup

1

Install Qwen Code

npm install -g @qwen-code/qwen-code@latest
2

Set environment variables

Add to your shell profile (.bashrc, .zshrc, or PowerShell $PROFILE), or to ~/.qwen/.env:

export OPENAI_API_KEY="YOUR_RESPAN_API_KEY"
export OPENAI_BASE_URL="https://api.respan.ai/api"
export OPENAI_MODEL="gpt-4o"

Then tell Qwen Code to use the OpenAI-compatible auth type without the interactive /auth prompt. Add to ~/.qwen/settings.json:

{
"security": {
"auth": {
"selectedType": "openai"
}
}
}

No separate provider key needed. The Respan gateway handles provider authentication.

3

Run Qwen Code

qwen

For a one-shot, non-interactive run:

qwen -p "your prompt"

All LLM calls now route through Respan.

Switch models

Change OPENAI_MODEL to use any of the 1000+ models available through the gateway.

export OPENAI_MODEL="gpt-4o"
# export OPENAI_MODEL="claude-sonnet-4-5-20250929"
# export OPENAI_MODEL="gemini/gemini-3.5-flash"

See the full model list.