# Qwen Code

> Open-source AI coding agent that lives in your terminal, tuned for Qwen models

- Category: AI Coding / Autonomous Coding Agents
- Language: TypeScript
- Licence: Apache-2.0
- Repository: https://github.com/QwenLM/qwen-code
- Website: https://qwenlm.github.io/qwen-code-docs/en/users/overview
- Canonical page: https://ai-tldr.dev/tools/qwen-code/

## In short

Qwen Code is an open-source AI coding agent that runs in your terminal. It sits in the Autonomous Coding Agents category of the AI Coding tools and is open-source, written in TypeScript and licensed Apache-2.0. To get started: install with npm.

## Overview

Qwen Code is an open-source AI coding agent that runs in your terminal. It is built and tuned for the Qwen series of models, and it helps you understand large codebases, automate repetitive work, and write and refactor code without leaving the command line. It is a fork of Google's Gemini CLI, with parser-level changes that make it work better with Qwen-Coder models.

It is flexible about which model you connect to. You can use OpenAI-, Anthropic-, or Gemini-compatible APIs, the Alibaba Cloud Coding Plan, providers like OpenRouter or Fireworks AI, or your own API key. You can also point it at a local model running through Ollama or vLLM, so no cloud account is required. Models, keys, and defaults are all configured in a single settings file at ~/.qwen/settings.json.

Beyond the interactive terminal UI, Qwen Code can run headless for scripts and CI, integrate with VS Code, Zed, and JetBrains IDEs, run as a shared local daemon, and be driven from TypeScript, Python, and Java SDKs.

## What it does

- Terminal-first agent that understands large codebases, refactors functions, and generates tests through chat
- Works with many providers: OpenAI-, Anthropic-, and Gemini-compatible APIs, OpenRouter, Fireworks AI, the Alibaba Cloud Coding Plan, or your own key
- Runs local models through Ollama or vLLM with no cloud account or API key needed
- Headless mode (qwen -p) for scripts, automation, and CI/CD pipelines
- IDE integration for VS Code, Zed, and JetBrains, plus TypeScript, Python, and Java SDKs
- Daemon mode (qwen serve) exposes one shared agent over HTTP+SSE so several clients reuse the same session

## Getting started

Qwen Code needs Node.js 22 or later. Install the CLI, start an interactive session, and pick an authentication method on first run.

1. Install with npm

   Install the package globally. On macOS or Linux you can also use Homebrew (brew install qwen-code), or the standalone install script from the docs.

```bash
npm install -g @qwen-code/qwen-code@latest
```

2. Start an interactive session

   Move into your project folder and launch the terminal UI. On first use you will be prompted to sign in; run /auth at any time to switch authentication methods. Use @ to reference local files, for example @src/main.ts.

```bash
cd your-project/
qwen
```

3. Configure a model provider

   The recommended setup is to edit ~/.qwen/settings.json, where you declare your models, API keys, and the default model. Inside a session, /model switches between configured models and /help lists available commands.

```json
{
  "modelProviders": {
    "openai": [
      {
        "id": "qwen3.6-plus",
        "name": "qwen3.6-plus",
        "baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
        "envKey": "DASHSCOPE_API_KEY"
      }
    ]
  },
  "env": { "DASHSCOPE_API_KEY": "sk-xxxxxxxxxxxxx" },
  "security": { "auth": { "selectedType": "openai" } },
  "model": { "name": "qwen3.6-plus" }
}
```

4. Run headless for scripts and CI

   Use the -p flag to run a single prompt without the interactive UI, which is handy for automation and CI/CD.

```bash
cd your-project/
qwen -p "your question"
```

## When to use it

- Explore an unfamiliar codebase by asking what the project does and how its structure is laid out
- Refactor functions and generate unit tests directly from the terminal
- Automate code tasks in CI/CD pipelines with headless single-prompt runs
- Run a fully local coding agent against Qwen models served by Ollama or vLLM, with no cloud account
- Drive the agent programmatically from TypeScript, Python, or Java SDKs in your own tools
