Skip to main content
Configure Qwen Code to use Nordlys’s Mixture of Models model for coding tasks.
Mixture of Models model with prompt‑activated specialists. Works as a drop-in replacement for Qwen Code’s API backend with lab-grade quality and cost control.

Benefits of Using Qwen Code with Nordlys

When you integrate Qwen Code with Nordlys, you unlock powerful capabilities:
  • Mixture of Models Activation: The right specialists activate per prompt
  • Cost Optimization: Save 60-90% on API costs with lab‑tuned models
  • Consistent Quality: Stable output quality across coding tasks
  • Drop-in Integration: OpenAI-compatible settings with zero code changes
  • Usage Analytics: Monitor model usage, costs, and performance in real-time

Get Your Nordlys API Key

Sign up here to create an account and generate your API key.

Quick Setup

Run Automated Installer

curl -fsSL https://raw.githubusercontent.com/Nordlys-Labs/nordlys/main/scripts/installers/unix/qwen-code.sh | bash
The installer will automatically:
  • Install Qwen Code if not present (via npm)
  • Configure OpenAI-compatible environment variables for Nordlys
  • Add configuration to your shell profile (~/.bashrc, ~/.zshrc, etc.)
  • Verify the installation

Verify Configuration

qwen --version
echo $OPENAI_API_KEY
echo $OPENAI_BASE_URL

Start Using

qwen
# Or start with a prompt
qwen "help me refactor this function"
Nordlys will activate the right specialists for coding tasks.

Manual Installation

If you prefer to set up Qwen Code manually or need more control over the installation process:

Step 1: Install Qwen Code

npm install -g @qwen-code/qwen-code@latest
Qwen Code requires Node.js 20 or higher. Check your version with node --version.

Step 2: Configure Environment Variables

Qwen Code uses OpenAI-compatible API configuration:
# Qwen Code with Nordlys AI model API Configuration
export OPENAI_API_KEY="your-nordlys-api-key-here"  # qwen-code
export OPENAI_BASE_URL="https://api.nordlylabs.com/v1"  # qwen-code
export OPENAI_MODEL="nordlys/hypernova"  # qwen-code - for automatic Nordlys model

Step 3: Apply Configuration

# For Bash/Zsh
source ~/.bashrc  # or ~/.zshrc

# For Fish
source ~/.config/fish/config.fish

# Or restart your terminal

Step 4: Verify Installation

qwen --version
qwen "test connection"

Alternative Setup Methods

export NORDLYS_API_KEY='your-api-key-here'
curl -fsSL https://raw.githubusercontent.com/Nordlys-Labs/nordlys/main/scripts/installers/unix/qwen-code.sh | bash
# The installer will automatically configure your shell

Advanced Configuration

Model Selection

Use Nordlys by setting the model ID explicitly:
export OPENAI_MODEL='nordlys/hypernova'
qwen "complex algorithm optimization"
If you omit OPENAI_MODEL, Qwen Code will use its default model. Nordlys model IDs will be listed in the docs as new models ship.

Usage Examples

Code Understanding & Editing

cd your-project/
qwen

# Architecture analysis
> Describe the main pieces of this system's architecture
> What are the key dependencies and how do they interact?
> Find all API endpoints and their authentication methods

Workflow Automation

# Analyze git commits from the last 7 days, grouped by feature
> git log --since="7 days ago" --pretty=format:"%h - %s" --graph

# Create a changelog from recent commits
> Generate a CHANGELOG.md from commits since last release

# Find all TODO comments and create GitHub issues
> Find all TODO comments and create corresponding issues

Session Management

Control your token usage with configurable session limits:
# Create or edit .qwen/settings.json in your home directory
{
  "sessionTokenLimit": 32000
}
Session token limit applies to a single conversation, not cumulative API calls.

Vision Model Support

Qwen Code includes automatic vision model detection for image analysis:
# Include images in your queries
qwen "Analyze this UI screenshot and suggest improvements" --image screenshot.png

# Vision model will automatically switch when images are detected

# Configure behavior in .qwen/settings.json
{
  "experimental": {
    "vlmSwitchMode": "once" // "once", "session", "persist", or omit for interactive
  }
}

Nordlys Model Behavior

Nordlys activates the right specialists per prompt and keeps costs predictable.

Troubleshooting

Problem: Qwen Code installation failsSolutions:
  • Ensure Node.js 20+ is installed: node --version
  • Install Node.js if needed:
    # Using nvm (recommended)
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
    nvm install 22
    
  • Check npm permissions: npm config get prefix
  • Try with sudo (not recommended): sudo npm install -g @qwen-code/qwen-code
  • Clear npm cache: npm cache clean --force
Problem: “Unauthorized” or “Invalid API key” errorsSolutions:
  1. Verify your API key at nordlylabs.com/dashboard
  2. Check environment variables are set:
    echo $OPENAI_API_KEY
    echo $OPENAI_BASE_URL
    echo $OPENAI_MODEL
    
  3. Ensure variables are exported in your shell config:
    # Bash/Zsh
    source ~/.bashrc  # or ~/.zshrc
    
    # Fish
    source ~/.config/fish/config.fish
    
  4. Restart your terminal if changes were made to shell config
  5. Verify the base URL is correct: https://api.nordlylabs.com/v1
  6. Check for the # qwen-code comment to ensure correct environment variables
Problem: Cannot connect to Nordlys APISolutions:
  • Check internet connectivity
  • Verify base URL is correct: echo $OPENAI_BASE_URL
  • Test API directly:
    curl -X POST https://api.nordlylabs.com/v1/chat/completions \
      -H "Authorization: Bearer $OPENAI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "nordlys/hypernova",
        "messages": [{"role": "user", "content": "Hello"}]
      }'
    
  • Check if your network/firewall blocks the API endpoint
  • Try using a different network or VPN
Problem: Requests fail due to a model ID errorSolutions:
  1. Set the model ID explicitly:
    export OPENAI_MODEL='nordlys/hypernova'
    
  2. Confirm the value is spelled exactly and matches the docs.
Problem: Slow response times or timeoutsSolutions:
  • Verify rate limits aren’t exceeded
  • Check your network connection
  • Reduce prompt size or request complexity
  • Retry with smaller batches if processing large files
Problem: Hitting token limits in long sessionsSolutions:
  • Configure higher session limits in .qwen/settings.json:
    {
      "sessionTokenLimit": 64000
    }
    
  • Use session compression to reduce token usage:
    /compress
    
  • Clear conversation history and start fresh:
    /clear
    
  • Monitor token usage:
    /stats
    
  • Break large tasks into smaller sessions

Uninstallation

If you need to remove Qwen Code or revert configuration:
1

Remove Qwen Code

npm uninstall -g @qwen-code/qwen-code
2

Remove Environment Variables

Edit your shell config file and remove these lines:
# Qwen Code with Nordlys AI model API Configuration
export OPENAI_API_KEY="..." # qwen-code
export OPENAI_BASE_URL="..." # qwen-code
export OPENAI_MODEL="..." # qwen-code
3

Reload Shell Configuration

source ~/.bashrc # or ~/.zshrc or ~/.config/fish/config.fish

Next Steps


Was this page helpful? Contact us at [email protected] for feedback or assistance with your Qwen Code integration.