Skip to content

Using New API with Qwen Code

Install Qwen Code

bash
pnpm install -g @qwen-code/qwen-code
bash
npm install -g @qwen-code/qwen-code
bash
yarn global add @qwen-code/qwen-code

Configure Environment Variables

Enter the following commands in the terminal to set environment variables (Environment Variable Setup Tutorial) to use New API's OpenAI API:

bash
# Set your New API API key, available from https://model.imkk.us/console/token
export OPENAI_API_KEY="sk-xxx"
# Set New API's API base URL
export OPENAI_BASE_URL="https://model.imkk.us/v1"  # Optional
export OPENAI_MODEL="gpt-4.1-mini" # Optional, model name, can also be changed to glm-4.6 or gemini-3-pro-high and other models
powershell
# Set your New API API key, available from https://model.imkk.us/console/token
$env:OPENAI_API_KEY="sk-xxx"
# Set New API's API base URL
$env:OPENAI_BASE_URL="https://model.imkk.us/v1"  # Optional
$env:OPENAI_MODEL="gpt-4.1-mini" # Optional, model name, can also be changed to glm-4.6 or gemini-3-pro-high and other models
cmd
# Set your New API API key, available from https://model.imkk.us/console/token
set OPENAI_API_KEY=sk-xxx
# Set New API's API base URL
set OPENAI_BASE_URL=https://model.imkk.us/v1
set OPENAI_MODEL=gpt-4.1-mini # Optional, model name, can also be changed to glm-4.6 or gemini-3-pro-high and other models
fish
# Set your New API API key, available from https://model.imkk.us/console/token
set -gx OPENAI_API_KEY "sk-xxx"
# Set New API's API base URL
set -gx OPENAI_BASE_URL "https://model.imkk.us/v1"  # Optional
set -gx OPENAI_MODEL "gpt-4.1-mini" # Optional, model name, can also be changed to glm-4.6 or gemini-3-pro-high and other models

IMPORTANT

Please make sure to replace sk-xxx with the Token provided by New API. You can get the API Key from the New API Console.

Direct Launch and Use

After configuring the environment variables, use the terminal to open the project directory you want to work on, then run the following command to start Qwen Code

bash
# Enter project directory
cd my-project

# Launch Qwen Code directly
qwen

TIP

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 New API API key, available from https://model.imkk.us/console/token
export OPENAI_API_KEY="sk-xxx"
# Set New API's API base URL
export OPENAI_BASE_URL="https://model.imkk.us/v1"  # Optional
export OPENAI_MODEL="gpt-4.1-mini" # Optional, model name, can also be changed to glm-4.6 or gemini-3-pro-high and other models
powershell
# Add to PowerShell profile ($PROFILE)
# Set your New API API key, available from https://model.imkk.us/console/token
$env:OPENAI_API_KEY="sk-xxx"
# Set New API's API base URL
$env:OPENAI_BASE_URL="https://model.imkk.us/v1"  # Optional
$env:OPENAI_MODEL="gpt-4.1-mini" # Optional, model name, can also be changed to glm-4.6 or gemini-3-pro-high and other models
cmd
# Add to batch file or system environment variables
# Set your New API API key, available from https://model.imkk.us/console/token
set OPENAI_API_KEY=sk-xxx
# Set New API's API base URL
set OPENAI_BASE_URL=https://model.imkk.us/v1
set OPENAI_MODEL=gpt-4.1-mini # Optional, model name, can also be changed to glm-4.6 or gemini-3-pro-high and other models
fish
# Add to ~/.config/fish/config.fish file
# Set your New API API key, available from https://model.imkk.us/console/token
set -gx OPENAI_API_KEY "sk-xxx"
# Set New API's API base URL
set -gx OPENAI_BASE_URL "https://model.imkk.us/v1"  # Optional
set -gx OPENAI_MODEL "gpt-4.1-mini" # Optional, model name, can also be changed to glm-4.6 or gemini-3-pro-high and other models