Facebook iconHow to Set Up Qwen Code and Use It for Free?
F22 logo
Blogs/AI

How to Set Up Qwen Code and Use It for Free?

Written by Sharmila Ananthasayanam
Dec 30, 2025
4 Min Read
How to Set Up Qwen Code and Use It for Free? Hero

Have you ever wished for a powerful coding assistant right inside your terminal, without paying for expensive subscriptions? That’s where Qwen Code comes in. In this article, we’ll explore how to set up Qwen Code in just a few minutes and show you how to use it for free. 

You’ll see how it helps you analyze large codebases, generate and refactor code, automate git workflows, and even debug security issues. The best part? Qwen Code offers free models on OpenRouter with generous daily quotas, making it a zero-cost alternative to expensive AI coding tools. 

By the end, you’ll know exactly how to turn your terminal into an AI-powered coding partner. Ready to supercharge your workflow without spending a dime? Go ahead and read more to discover how Qwen Code can transform your development process.

What Is Qwen Code?

Qwen Code is a powerful, terminal-based AI coding assistant developed by Alibaba. It’s designed to integrate directly into your workflow, giving you intelligent coding support without leaving the command line. Unlike most paid coding tools, Qwen Code is available for free through multiple providers, including OpenRouter, making it accessible to developers at every level.

With Qwen Code, you can:

  • Analyze large codebases (up to 256K tokens)
  • Generate and refactor code with natural language commands
  • Automate git workflows and documentation
  • Debug and audit code for security issues

Key Advantage: Unlike paid alternatives, Qwen Code offers enterprise-level capabilities completely free through multiple providers.

How to Install Qwen Code in 2 Minutes?

Before setting up Qwen Code, you’ll need Node.js installed on your machine. Node.js powers the Qwen CLI, making it run directly in your terminal.

How to install Qwen code Infographic

Prerequisites

Install Node.js 20+:

Qwen Code works smoothly on macOS, Linux, and Windows (via WSL). Make sure you’re running Node.js 20 or higher.

curl -qL https://www.npmjs.com/install.sh | sh 

Then, verify your installation by running the following commands:

node -v
npm -v 

Install Qwen Code

npm install -g @qwen-code/qwen-code@latest  
qwen --version 

(This ensures npm itself is updated, which avoids common installation issues.)

Getting Started with Qwen Code
Learn how to install, configure, and use Qwen Code locally. Covers context window tuning and prompt optimization for coders.
Murtuza Kutub
Murtuza Kutub
Co-Founder, F22 Labs

Walk away with actionable insights on AI adoption.

Limited seats available!

Calendar
Saturday, 17 Jan 2026
10PM IST (60 mins)

If you face permission issues, try 

sudo npm install -g @qwen-code/qwen-code@latest

And provide your password.

That’s it! Qwen Code is now installed on your system.

Setup Method 1: Qwen OAuth (Easiest)

If you just want to get started quickly without managing API keys or extra setup, the Qwen OAuth method is the best option. It takes less than a minute and requires almost no configuration.

# Just run this command  
qwen

Use the arrows and Enter to choose your desired options. 

What happens:

  1. Your browser will open automatically.
  2. Log in with your qwen.ai account.
  3. Click Confirm to authorize access.

Free Benefits You Get:

  • 2,000 requests/day
  • 60 requests/minute
  • No API key management
chat.qwen.ai login confirmation

Click on Confirm to login.

Authentication successful

After Authorization you can come back to the CLI and start asking questions to the qwen3-coder-plus model.

Setup Method 2: OpenRouter 

If you want more stable performance and global access, the OpenRouter setup is the ideal choice. It requires creating an API key, but once done, you get smooth usage across regions.

Step 1: Get an OpenRouter API Key

  1. Go to openrouter.ai
  2. Sign up (takes less than 30 seconds)
  3. Generate your personal API key
Getting Started with Qwen Code
Learn how to install, configure, and use Qwen Code locally. Covers context window tuning and prompt optimization for coders.
Murtuza Kutub
Murtuza Kutub
Co-Founder, F22 Labs

Walk away with actionable insights on AI adoption.

Limited seats available!

Calendar
Saturday, 17 Jan 2026
10PM IST (60 mins)

Step 2: Configure Environment

Set the following environment variables in your terminal:

export OPENAI_API_KEY="your_openrouter_api_key"  
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"  
export OPENAI_MODEL="qwen/qwen3-max" 

Run these commands to confirm your environment variables are set correctly:

echo $OPENAI_MODEL 
echo $OPENAI_BASE_URL 
echo $OPENAI_API_KEY

Step 3: Launch

Once your environment is configured, you can launch Qwen Code:

qwen

In the Auth Settings, choose OpenAI.

Type / in the terminal to see all available options and commands.

If you ever need to remove Qwen Code:

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

Qwen Code is now fully set up and ready to use. Whether you went with the quick Qwen OAuth method or the flexible OpenRouter setup, you can now start writing code, refactoring, debugging, and automating your workflows directly from the terminal. Dive in, explore the features, and let Qwen Code simplify your development process.

And if you’re curious about what else the Qwen ecosystem can do, don’t miss our upcoming Complete Guide to Fine-tuning Qwen2.5 VL Model, where we’ll dive into customizing Qwen for powerful vision-language applications.

Need Expert Help?

While Qwen Code is perfect for getting started with AI-assisted coding, scaling these solutions for enterprise use often requires professional expertise. If your business is looking to build custom AI solutions, integrate models like Qwen, or fine-tune advanced systems for production, you may want to hire AI developers who can bring your vision to life faster and more effectively.

Author-Sharmila Ananthasayanam
Sharmila Ananthasayanam

I'm an AIML Engineer passionate about creating AI-driven solutions for complex problems. I focus on deep learning, model optimization, and Agentic Systems to build real-world applications.

Share this article

Phone

Next for you

Self-Consistency Prompting: A Simple Way to Improve LLM Answers Cover

AI

Jan 9, 20266 min read

Self-Consistency Prompting: A Simple Way to Improve LLM Answers

Have you ever asked an AI the same question twice and received two completely different answers? This inconsistency is one of the most common frustrations when working with large language models (LLMs), especially for tasks that involve math, logic, or step-by-step reasoning. While LLMs are excellent at generating human-like text, they do not truly “understand” problems. They predict the next word based on probability, which means a single reasoning path can easily go wrong. This is where self

What Is Prompt Chaining? How To Use It Effectively Cover

AI

Jan 9, 20267 min read

What Is Prompt Chaining? How To Use It Effectively

Picture this: It’s 2 AM. You’re staring at a terminal, fighting with an LLM. You’ve just pasted a 500-word block of text, a "Mega-prompt" containing every single instruction, formatting rule, and edge case you could think of. You hit enter, praying for a miracle. And what do you get? A mess. Maybe the AI hallucinated the third instruction. Maybe it ignored your formatting rules entirely. Or maybe it just gave you a polite, confident, and completely wrong answer. Here’s the hard truth nobody

What is Directional Stimulus Prompting? Cover

AI

Jan 9, 20268 min read

What is Directional Stimulus Prompting?

What’s Actually Going On Inside an AI “Black Box”? Have you ever noticed that you can ask an AI the same thing in two slightly different ways and get completely different replies? That’s not your imagination. Large Language Model systems like ChatGPT, Claude, or Gemini are often described as “black boxes,” and there’s a good reason for that label. In simple terms, when you send a prompt to an LLM, your words travel through an enormous network made up of billions of parameters and layered mathe