Using Agent Router with Qwen Code
Install Qwen Code
bash
pnpm install -g @qwen-code/qwen-codebash
npm install -g @qwen-code/qwen-codebash
yarn global add @qwen-code/qwen-codeConfigure Environment Variables
Enter the following commands in your terminal to set environment variables (Environment Variable Setup Tutorial) for using AgentRouter's OpenAI API:
bash
# Set your AgentRouter API key, available at https://agentrouter.org/console/token
export OPENAI_API_KEY="sk-xxx"
# Set AgentRouter's API base URL
export OPENAI_BASE_URL="https://agentrouter.org/v1" # Optional
export OPENAI_MODEL="gpt-5" # Optional, model namepowershell
# Set your AgentRouter API key, available at https://agentrouter.org/console/token
$env:OPENAI_API_KEY="sk-xxx"
# Set AgentRouter's API base URL
$env:OPENAI_BASE_URL="https://agentrouter.org/v1" # Optional
$env:OPENAI_MODEL="gpt-5" # Optional, model namebash
# Set your AgentRouter API key, available at https://agentrouter.org/console/token
set OPENAI_API_KEY="sk-xxx"
# Set AgentRouter's API base URL
set OPENAI_BASE_URL="https://agentrouter.org/v1" # Optional
set OPENAI_MODEL="gpt-5" # Optional, model nameIMPORTANT
Make sure to replace sk-xxx with the Token provided by AgentRouter. You can get your API Key from the AgentRouter Console.
Launch Directly
After configuring the environment variables, use your terminal to open the project directory you want to work with, then run the following command to start Qwen Code:
bash
# Navigate to project directory
cd my-project
# Launch Qwen Code directly
qwenTIP
You can add the environment variable configuration to your shell configuration file to avoid manual setup each time:
bash
# Add to ~/.bashrc or ~/.zshrc file
# Set your AgentRouter API key, available at https://agentrouter.org/console/token
export OPENAI_API_KEY="sk-xxx"
# Set AgentRouter's API base URL
export OPENAI_BASE_URL="https://agentrouter.org/v1" # Optional
export OPENAI_MODEL="gpt-5" # Optional, model namepowershell
# Add to PowerShell profile ($PROFILE)
# Set your AgentRouter API key, available at https://agentrouter.org/console/token
$env:OPENAI_API_KEY="sk-xxx"
# Set AgentRouter's API base URL
$env:OPENAI_BASE_URL="https://agentrouter.org/v1" # Optional
$env:OPENAI_MODEL="gpt-5" # Optional, model namebash
# Set your AgentRouter API key, available at https://agentrouter.org/console/token
set OPENAI_API_KEY="sk-xxx"
# Set AgentRouter's API base URL
set OPENAI_BASE_URL="https://agentrouter.org/v1" # Optional
set OPENAI_MODEL="gpt-5" # Optional, model name