"Qwen CLI" is Qwen Code, a coding agent that runs in your terminal, much like the Activepieces crowd's favorite automation tools live in a browser tab.
It sends your prompts to the Qwen model API, which you reach through Alibaba Cloud Model Studio or Qwen's own sign-in. Everything below dates from 2026-12-06.
Understand Qwen CLI components
What Qwen Code does in the terminal
Qwen Code is an agent, not a chat box. You start it inside a project folder, describe a task, and it reads files, proposes edits and runs shell commands, asking before it changes anything.

The program on your machine holds no model. Every answer comes from a model served elsewhere.
That matters the first time something fails. A rejected key, a retired model name or a rate-limit message isn't a bug in the terminal program. It's the API refusing the request, and the fix lives in your account, not in your install.
CLI versus calling the API directly
Treat the CLI and the API as separate products with separate documentation:
- The CLI handles the conversation loop, the file access and the permission prompts
- The API handles authentication, model selection, billing and limits
Calling the API directly skips the agent entirely, and the Model Studio key travels with your requests. Activepieces supports secret managers on its Ultimate and Enterprise control plans, so that key can be held centrally per project instead of sitting on individual laptops.
Expect four details to change without notice, because they belong to the API side:
- The key
- The model name
- The price
- The rate limit
Expect four details to change without notice, because they belong to the API side:
Install Qwen Code CLI on macOS, Linux, Windows
Before you install, make sure Node.js and npm are already present, because Qwen Code ships as an npm package. The same command runs in a macOS or Linux shell and in Windows PowerShell:
npm install -g @qwen-code/qwen-code@latest
Then start it from inside a project folder:
qwen
If the shell says qwen isn't found, the usual cause is that npm's global bin folder is missing from your PATH. Open a new terminal window first, since an already-open one won't see the change.
Everything below works on Activepieces' free plan. Start without code or a credit card.
Get access and an API key for Qwen
You either sign in through Qwen's OAuth flow, which no longer carries a free allowance, or create a Model Studio API key and export it as an environment variable.
Sign in to Qwen Code with OAuth
At launch, signing in with a Qwen account gave you 2,000 requests a day at no cost, so a script that looped over a repository never noticed a ceiling.
That was cut to 1,000 a day, then to 100, and then Qwen discontinued the free tier: 0 requests a day, which means anyone relying on free access is shut out completely.
Create an API key in Model Studio
Model Studio is Alibaba Cloud's console for the Qwen models. Create the key there, and note which region you created it in.
International and mainland China accounts use different endpoints, and each rejects the other's keys with an authentication error that looks like a typo in the key.
Set environment variables and the settings file
Qwen Code reads an OpenAI-compatible configuration, so three variables carry the whole setup:
OPENAI_API_KEY, the key from Model StudioOPENAI_BASE_URL, the compatible-mode endpoint for your regionOPENAI_MODEL, the model name you copied from the console
Export them in your shell profile and the setting follows you into every terminal. Persistent preferences go in ~/.qwen/settings.json, which means a CI runner needs the variables set explicitly because it has no home directory carrying that file.
If a run reports an invalid key, check the region of the endpoint before regenerating the key.
Review Qwen models, endpoints, and pricing
Each key is tied to one region, and each region has its own OpenAI-compatible endpoint. The model you pick and the endpoint you call have to match the key you hold.

Qwen coding models and their endpoints
Look at context first, because that's where the three models differ most. models.dev lists Coder Plus at 1,048,576 tokens and Coder Flash at 1,000,000.
Max holds 262,144, so a repository that fits in Plus may have to be split before Max will accept it.
In the table below, "Not published" means none of the pages checked gave a figure, so check the vendor's docs before you budget on it.
| Model | Context | Max output | Input / output per 1M | Free quota | Rate limit | Regional endpoint |
|---|---|---|---|---|---|---|
| qwen3-coder-flash | 1,000,000 | Not published | $0.30 / $1.50 | Not published | Not published | Not published |
| qwen3-coder-plus | 1,048,576 | Not published | Not published | Not published | Not published | Not published |
| qwen3-max | 262,144 | Not published | Not published | Not published | Not published | Not published |
Qwen API price per million tokens
Per million tokens, Anotherwrapper puts Qwen3-Coder-Flash at $0.30 input and $1.50 output, so output tokens will dominate your costs. GPT-5 mini, an older OpenAI model, was listed at $0.25 and $2. According to Anotherwrapper, Claude Sonnet 5.5 is $2 and $10.
On input, Flash cost about the same as the older GPT-5 mini did, and less on output.
I found no published price for Plus or Max, so their cost is unknown until you read the pricing page.
Qwen rate limits and free quota by tier
Before you put a model into CI, read the limits for your own account and region on the day you test, and write that date next to them.
Send Qwen requests and use commands
A minimal API request
To make a first request, send one POST to your region's compatible-mode chat/completions URL, with your key as a Bearer token and the model name in the body.
- Export the key:
export DASHSCOPE_API_KEY=... - Choose the base URL for your region. The international endpoint is
https://dashscope-intl.aliyuncs.com/compatible-mode/v1, and the mainland China one drops-intl. - Set the header
Authorization: Bearer $DASHSCOPE_API_KEY. - Set the
modelfield to a name copied from the vendor's model list on the day you run this. - POST to
/chat/completions. - Read
choices[0].message.content.
curl "$BASE_URL/chat/completions" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"'"$QWEN_MODEL"'","messages":[{"role":"user","content":"Say hello"}]}'
In Python, you use the OpenAI SDK pointed at the same URL: OpenAI(api_key=..., base_url=...), then client.chat.completions.create(model=..., messages=[...]), then resp.choices[0].message.content.
Once that returns text, the key, region and model are confirmed together, and any later failure in the agent is about the agent.
Qwen Code slash commands and flags
Inside a session, /help lists what your installed version supports, and that list outranks anything written here. The ones people reach for first are:
/authto change how you sign in/clearto wipe the conversation/compressto summarize history when it grows long/toolsto see what the agent may call/mcpto see connected MCP servers/memoryto inspect loaded context
For scripts, -p "your prompt" runs a single prompt and exits instead of opening the interactive screen. -m selects a model for that run, so you can test a second model without editing the config.
Config file and project context file
Settings live in settings.json inside a .qwen directory, either in your home directory for every project or in the repository for one. The project-level file wins, so a teammate's checkout can pin a model without touching your defaults.
The agent also reads a QWEN.md file from the project and loads it into every session. Put build commands, test commands and conventions there, and the agent stops asking you for them.
Easier to see it running than to read about it: set it up free, no card.
Fix Qwen CLI errors in production
When a Qwen CLI run fails, it almost always traces to a key, a region, a model name or a quota, and the tool retries only a few of them for you.
Read the last column first: a "no" means the same command will fail the same way every time.
| Symptom | Cause | Fix | Retry? |
|---|---|---|---|
| 401 | Key missing, expired or revoked | Issue a new key in the vendor console and re-export it | No |
| Wrong region | Key belongs to one region's endpoint, request goes to another | Point the base URL at the region that issued the key | No |
| Model not found | Misspelt or retired model name | Copy the current name from the vendor's model page | No |
| 429 | Rate limit or quota hit | Back off, then resend; raise the limit if it recurs | Yes, with backoff |
| Context exceeded | Prompt plus history is larger than the model's window | Trim files, clear the session or split the task | No |
| Node/Windows install | Node version too old, or a path or permission problem | Check the required Node version in the docs, then reinstall | No |
When you get a 401, the vendor has refused the credential, and resending it changes nothing. A region mismatch looks nearly identical, because a key valid in one region is simply unknown in another.

Check the base URL before regenerating anything.
Fix Qwen 429 errors and quota exhaustion
Qwen Code's retry logic retries three error codes automatically and doesn't retry two. In practice, a transient failure may heal itself, while the rest end your run and wait for a person.
Add your own exponential backoff around the whole command, and cap the attempts.
The OAuth allowance behaves differently: once it is spent, waiting inside the job won't help, so fail fast and switch to an API key.
Fix Qwen context and model-not-found errors
"Context exceeded" is a budget problem. Set a token ceiling for each scheduled run, and keep prompts to the files that matter.
A model-not-found error usually arrives after a vendor retires a name. Check the model page on the day you deploy, not the name saved in last quarter's config, and pin that name in one environment variable so a fix touches one line.
What Activepieces does about this
The problem in this article is that the key, model name, price and rate limit live on the API side and move without warning. Activepieces doesn't fix that, and nothing can.
What it does is put those four facts where you change them once, so the re-check you do on a dated day touches one place instead of every laptop and job.
The first integration is the key. On the Ultimate and Enterprise control plans, Activepieces supports secret managers, so the Model Studio key can be held centrally per project.
When a key is revoked or a region changes, you replace it in one spot, not in each developer's shell profile.
The second integration is the scheduled job. A workflow can call the Qwen API through its HTTP step, with the model name set in one field you can read at a glance.

A run costs 1 credit however many steps it has, and the free plan allows unlimited flows and 1,000 credits a month. You still own the request body and the error handling, so the 429 and model-not-found advice above applies unchanged.
The third integration is the agent. Activepieces runs an MCP server, cloud or self-hosted, at https://www.activepieces.com/mcp, drawing on the 751 integrations in its open source monorepo. Qwen Code can connect to it, though you should take the exact configuration keys from the Qwen Code docs.
Decide which apps to expose first, because each one is something the agent can change.
Frequently asked questions
Each answer below is only as good as the day you read it, so check the vendor's docs before acting on any of them.
Is Qwen CLI free to use?
The Qwen Code tool is free to install, but the model calls behind it aren't guaranteed to be. The free tier tied to OAuth sign-in has been discontinued, so a setup that relied on it will start failing authentication or quota checks.
New API accounts may get a free allowance for a limited period and region. Read the current terms on the model provider's pricing page before you build a budget on it.
Can Qwen Code run in CI or a scheduled job?
Yes, provided it authenticates with an API key held in your CI secret store instead of an interactive login. A browser-based sign-in has nobody to click it in a pipeline, and the job will hang or fail.
Pin the model name in one environment variable, as above, so a rename breaks one line instead of every job.
On a scheduled job, rate limits matter more than on a laptop, because a job that fans out many calls is the likeliest thing to hit them.
If you don't need the agent itself, a scheduled workflow in Activepieces can call the Qwen API directly through its HTTP step, and a run costs 1 credit however many steps it has, on a free plan that allows unlimited flows and 1,000 credits a month.
The cost is that you own the request body, the model name and the error handling, so the same re-check applies.
Can Qwen Code use MCP servers?
Yes. Qwen Code can connect to MCP servers, which is how you give the agent tools beyond the files in front of it.
Take the exact configuration keys and commands from the Qwen Code docs, not from memory or a blog post, because the settings format is the sort of thing that changes between releases.
Activepieces runs an MCP server, cloud or self-hosted, at https://www.activepieces.com/mcp. It exposes the team's connected apps as tools, drawn from the 751 integrations in its open source monorepo, so the agent can act in them.
Treat that as a permissions decision first: every app you expose is something the agent can change.
Can I point Qwen Code at a different model provider?
Generally yes, since the tool speaks a common API style and can be pointed at a compatible endpoint through its key, base URL and model settings.
Whether a given provider works well depends on tool-calling support and on the model name matching what that provider lists. Confirm the setting names in the docs, then test one small task before moving real work over.
How often do Qwen prices and limits change?
Often enough that you shouldn't store them anywhere. Model names, prices, rate limits and free allowances all sit on the vendor's pages and have moved before.
Put a recurring dated check in the calendar, and record the date next to any number you write down so the next reader knows how old it is.


