Skip to Content

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.

Paste this into your coding agent:

Help me set up the Respan gateway with the Qwen Code integration. Follow https://www.respan.ai/docs/integrations/gateway/qwen-code.md

Setup

Install Qwen Code

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

Set environment variables

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

Terminal
export OPENAI_API_KEY="YOUR_RESPAN_API_KEY" export OPENAI_BASE_URL="https://gateway.respan.ai" 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:

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

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

Run Qwen Code

Terminal
qwen

For a one-shot, non-interactive run:

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

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