> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://respan.ai/docs/integrations/gateway/qwen-code/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/_mcp/server. # Qwen Code (gateway) > Set up Qwen Code with the Respan gateway. Route [Qwen Code](https://github.com/QwenLM/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 #### Install Qwen Code ```bash 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`: ```bash 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`: ```json { "security": { "auth": { "selectedType": "openai" } } } ``` No separate provider key needed. The Respan gateway handles provider authentication. #### Run Qwen Code ```bash qwen ``` For a one-shot, non-interactive run: ```bash 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. ```bash 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](https://platform.respan.ai/platform/models). > Set up Qwen Code with the Respan gateway.