How to Use Claude Code with Qwen models for Free (Linux)

Published: (January 3, 2026 at 03:27 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

Prerequisites

  • Qwen CLI installed and authenticated

  • Node.js v18+ installed

  • Install the Qwen Code CLI:

    npm install -g @qwen-code/qwen-code@latest
  • Install Claude Code and the router:

    npm install -g @anthropic-ai/claude-code @musistudio/claude-code-router

Configuration

  1. Replace LINUX_USER with your Linux username.

  2. Open the Qwen OAuth credentials file:

    cat /home/LINUX_USER/.qwen/oauth_creds.json

    It should look similar to:

    {
      "access_token": "YOUR_QWEN_ACCESS_TOKEN_HERE",
      "token_type": "Bearer",
      "refresh_token": "YOUR_QWEN_REFRESH_TOKEN_HERE",
      "resource_url": "portal.qwen.ai",
      "expiry_date": 1764876220290
    }
  3. Copy the access_token value.

  4. Create the Claude Code Router configuration:

    cat > ~/.claude-code-router/config.json > ~/.zshrc
    source ~/.zshrc

Verify Installation

claude --version        # Should show: Claude Code v2.x.x
ccr version             # Should show the version number
echo $QWEN_ACCESS_TOKEN # Should display your token

Run the Router

Restart the router server:

ccr restart

Use Claude Code with Qwen Models

Start Claude Code:

ccr code

Test the setup:

> hi

Refreshing an Expired OAuth Token

If your token expires:

  1. Delete the existing OAuth credentials file to force re‑authentication:

    rm /home/LINUX_USER/.qwen/oauth_creds.json
    qwen   # Run the Qwen CLI to log in again
  2. Copy the new access_token from the regenerated oauth_creds.json.

  3. Update the api_key in ~/.claude-code-router/config.json with the new token (e.g., using nano or your preferred editor).

  4. Restart the router:

    ccr restart

Hopefully this helps you get Claude Code running for free on Linux! 💖

Back to Blog

Related posts

Read more »

The RGB LED Sidequest 💡

markdown !Jennifer Davishttps://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%...

Mendex: Why I Build

Introduction Hello everyone. Today I want to share who I am, what I'm building, and why. Early Career and Burnout I started my career as a developer 17 years a...