ERA OF MINDS

Qwen4-Max in Claude Code: how to set it up with the 1M free tokens

Short answer

Yes, you can run Qwen4-Max inside Claude Code, and the first 1 million tokens can be free. Create a QwenCloud API key in the Singapore region, point Claude Code at https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic with ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, set the model to qwen4-max, and raise CLAUDE_CODE_MAX_CONTEXT_TOKENS to 983616. Before you start, switch on Free quota only in the QwenCloud console. It is off by default, and without it Claude Code keeps going at $1.50 per million input tokens and $4.50 per million output tokens once the free tokens are gone.

Era of Minds cover: Qwen4-Max in Claude Code, free. 1M free tokens. Launched Nov 16, 1 settings file, 1M-token context, $1.50 / $4.50 per 1M tokens, free quota in Singapore. Settings panel: ANTHROPIC_BASE_URL ap-southeast-1.maas.qwencloudapi.com/apps/anthropic, ANTHROPIC_AUTH_TOKEN QwenCloud key, ANTHROPIC_DEFAULT_OPUS_MODEL qwen4-max, CLAUDE_CODE_MAX_CONTEXT_TOKENS 983616, then claude -p Hello and /status. Table: free quota 1M tokens per model, price $1.50 in and $4.50 out, 1M context, Code Arena WebDev #6 with 1750, @Alibaba_Qwen launch post 756K views.
Figure: the pay-as-you-go Claude Code settings from QwenCloud's docs, with prices, free quota and launch-day numbers checked on November 16, 2026.

Alibaba's Qwen team launched Qwen4-Max on X at 06:01 Dubai time on November 16. Four hours later the post had 756,099 views, 7,928 likes and 1,457 bookmarks (X API, about 10:25 Dubai time). The pitch is simple: a new flagship with a 1M-token context window that, in Qwen's own tests, beats Qwen3.8-Max while using up to about 50% fewer tokens, with average cost per task down more than 60%.

If you work in Claude Code, the obvious question is whether you can use it there. You can. QwenCloud speaks the Anthropic Messages format, so Claude Code does not need a plugin or a proxy. You change a few settings and it talks to Qwen instead of Anthropic. Here is the exact setup, how to claim the free tokens without a surprise bill, and what the early benchmarks do and don't tell you.

What is Qwen4-Max?

Qwen4-Max is the first model in Alibaba's Qwen4 family. According to the QwenCloud model guide, it combines reasoning, native image and video understanding and long-running agent work. The model ID is qwen4-max. The numbers that matter for Claude Code users:

  • Context: 1,000,000 tokens. Max input is 991,808 tokens without thinking and 983,616 with thinking.
  • Output: up to 131,072 tokens without thinking, or 262,144 for thinking plus the final answer.
  • Thinking: on by default, reasoning_effort=high, thinking budget 131,072 tokens. You can pick low, high or xhigh.
  • APIs: OpenAI Chat Completions, Responses, Anthropic Messages and DashScope. Tool calling, structured output, web search and MCP are supported. Batch and fine-tuning are not.
  • Price (Singapore): $1.50 per million input tokens, $4.50 per million output tokens, $0.075 per million cached input tokens, per the model page. Thinking and non-thinking cost the same.

Qwen also says open weights for smaller Qwen4 models are coming. Qwen4-Max itself is available through the API and Qwen's apps.

Is Qwen4-Max free to use?

Partly. The QwenCloud price table lists a free quota of 1 million tokens for qwen4-max, and the free quota rules come with fine print you should read before you plug it into an agent:

  • Singapore only. The quota covers real-time calls made with a Singapore API key to the Singapore endpoint. Other regions bill from the first token.
  • Payment details first. You activate the quota by completing your payment information. It is a free quota on a paid account, not a free plan.
  • Input and output share one pool. Every call takes both from the same 1M total.
  • About 90 days. If your account existed before the model came out, the clock starts on the model's release date. Unused tokens expire, and a new account does not get a fresh quota.
  • Per model. Each model has its own quota. When qwen4-max runs out, requests are not moved to another model that still has free tokens.
  • Not covered: batch calls, built-in tool fees such as web search, fine-tuning and deployment.

At list price, 1M tokens is worth between $1.50 (if it were all input) and $4.50 (all output). That is enough to try Qwen4-Max on a real repo for an afternoon, not to replace a subscription. Claude Code sends the conversation and tool results back on every turn, so input tokens add up faster than you expect. Check your usage in the console after the first session.

If you only want to chat with it, the launch post says you can also try Qwen4-Max in Qwen Studio, QwenWork and Qoder. Qwen has not published Qwen4-Max limits for those free accounts, so we won't guess them.

How do you set up Qwen4-Max in Claude Code?

This follows QwenCloud's Claude Code page for pay-as-you-go keys, with the model set to qwen4-max as that page says.

  1. Create a QwenCloud account and add payment details so the free quota activates.
  2. Turn on Free quota only. In the console, open the Free Tier page and toggle it for qwen4-max (or click Enable all models). This is the step that keeps it at $0.
  3. Create an API key in Singapore. Keys are region-specific. A pay-as-you-go key starts with sk-.
  4. Add this to ~/.claude/settings.json (on Windows: C:\Users\<you>\.claude\settings.json):
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-your-qwencloud-key",
    "ANTHROPIC_BASE_URL": "https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic",
    "ANTHROPIC_MODEL": "qwen4-max",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen4-max",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen4-max",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen4-max",
    "CLAUDE_CODE_SUBAGENT_MODEL": "qwen4-max",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "983616"
  }
}
  1. Skip the Anthropic login. In ~/.claude.json, set "hasCompletedOnboarding": true. QwenCloud's troubleshooting notes say that without it Claude Code tries Anthropic's login on startup.
  2. Open a new terminal and test: claude -p "Hello". Then start a normal session and run /status to confirm the base URL points at QwenCloud.

Why every slot is set to qwen4-max: QwenCloud's own examples map the Haiku and Sonnet slots to smaller Qwen models, which is cheaper on a paid plan. With the free quota, though, each model has its own 1M pool and Free quota only blocks calls per model. Pointing all slots at one model makes it easy to see exactly what you have left. That part is our suggestion, not QwenCloud's. If you prefer their split, it works too, just watch more than one quota.

If long answers get cut off, add "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "64000". Want to keep your normal Claude setup? Put the same env block in a project's .claude/settings.local.json instead, so only that folder uses Qwen.

Can you use Qwen4-Max in Claude Code through OpenRouter or Token Plan instead?

OpenRouter: OpenRouter added it on launch day as qwen/qwen4-max at $1.50 / $4.50 per million tokens, with a 1M context and up to 393,216 output tokens. Its model list shows an Anthropic-style /api/v1/messages endpoint. OpenRouter's Claude Code guide uses:

export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="your-openrouter-key"
export ANTHROPIC_API_KEY=""
export ANTHROPIC_DEFAULT_OPUS_MODEL="qwen/qwen4-max"

Two catches. It is paid from your OpenRouter credits, with no 1M free tokens. And OpenRouter's guide says Claude Code is only guaranteed to work with Anthropic's own models, so treat other models there as "may work".

Token Plan: Alibaba's subscription for coding tools. The pricing page says Lite and Essential plans normally start from $6 a month, with new users from $3 during the current event. It uses a different base URL (https://token-plan.maas.qwencloudapi.com/apps/anthropic) and a different key. QwenCloud's docs say a 401 invalid_api_key means the key type does not match the base URL, so don't mix a Token Plan key with the pay-as-you-go URL.

How good is Qwen4-Max compared with Claude?

Launch-day numbers from third-party leaderboards, all posted within an hour of the release:

  • LMArena Code Arena WebDev: #6 with 1750 points (preliminary), 74 points above Qwen3.8-Max.
  • LMArena Agent Arena: #14 overall, a +7.5% net improvement across 14.7k real agent sessions, which makes Alibaba the #5 lab overall behind Anthropic, Google, OpenAI and Meta.
  • Artificial Analysis Intelligence Index: 43 at xhigh effort, 9 points above Qwen3.8 Max and 3 behind Kimi K3.1 Pro (46), at $3.27 per index task versus $10.02 for Qwen3.8 Max.
  • Vals Index: #11 overall and the top Chinese model, with the biggest gains on coding and finance.

So it is a big jump for Qwen and a cheap one, but it is not at the very top. Anthropic's and Google's best models still score higher on these boards. The fair use case in Claude Code is the bulk work where price matters: reading a large codebase, refactors with tests, first drafts of front-end pages. Keep your hardest tasks on whatever model you trust most.

What should you watch out for?

  • Claude Code is tuned for Claude. Tool calls, thinking blocks and long sessions can behave differently on another model. Start with one bounded task that has a test, not your production branch.
  • Your code goes to Alibaba Cloud. Prompts, files the agent reads and outputs are processed by QwenCloud. Keep secrets and client code out of a trial repo.
  • The free quota is easy to blow through. Free quota only is the safety net. Without it, calls keep going and bill pay-as-you-go.
  • Benchmarks are a day old. The Arena scores are preliminary and the "50% fewer tokens" figure is Qwen's internal evaluation.
  • We did not run it ourselves. This guide is built from QwenCloud's and OpenRouter's docs as of November 16, 2026. If a URL or variable in your console differs, the console wins.

What we'd do first

Make a copy of a small project, turn on Free quota only, paste the settings above into that project's .claude/settings.local.json, and give Qwen4-Max one job you have already done with Claude, like "add tests for this module and make them pass". Compare the result, the time and the token count in the QwenCloud console. That one comparison tells you more than any leaderboard. If you are trying to stretch tokens further, our Headroom test covers context compression in Claude Code, and the coding tools comparison lists the other agents you can point at the same API.

FAQ: Qwen4-Max in Claude Code, free tokens and price

Can I use Qwen4-Max in Claude Code?

Yes. QwenCloud has an Anthropic-compatible endpoint, so you point Claude Code at it with ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN and set the model to qwen4-max. For pay-as-you-go in Singapore the base URL is https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic. Test it with claude -p "Hello" and check /status.

Is Qwen4-Max free?

There is a free quota, not a free plan. QwenCloud gives 1 million free tokens for qwen4-max on pay-as-you-go calls in the Singapore region, input and output combined. You have to add payment details to activate it, and it is typically valid for 90 days. Qwen Studio, QwenWork and Qoder also let you try the model in an app.

How do I avoid being charged after the free tokens run out?

Turn on Free quota only on the Free Tier page of the QwenCloud console before your first session. It is off by default. With it on, calls are blocked when the quota is used up instead of being billed at $1.50 per million input tokens and $4.50 per million output tokens.

What does Qwen4-Max cost?

On QwenCloud's Singapore (international) region: $1.50 per million input tokens, $4.50 per million output tokens and $0.075 per million cached input tokens, the same in thinking and non-thinking mode. OpenRouter lists the same $1.50 and $4.50. Beijing and Global regions are slightly cheaper at $1.413 and $4.24.

Can I use Qwen4-Max in Claude Code through OpenRouter?

OpenRouter lists qwen/qwen4-max with an Anthropic-style messages endpoint, and its Claude Code guide uses ANTHROPIC_BASE_URL=https://openrouter.ai/api with your OpenRouter key as ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY set to empty. It is paid from your OpenRouter credits, and OpenRouter says Claude Code is only guaranteed to work with Anthropic's own models.

What is the context window of Qwen4-Max?

1,000,000 tokens. Max output is 131,072 tokens without thinking and 262,144 tokens for thinking plus the final answer. In Claude Code, QwenCloud says to set CLAUDE_CODE_MAX_CONTEXT_TOKENS to 983616, and CLAUDE_CODE_MAX_OUTPUT_TOKENS to 64000 if long answers get cut off.

Is Qwen4-Max better than Claude?

Not across the board. On launch day LMArena put it at #6 in Code Arena WebDev (1750, preliminary) and #14 overall on Agent Arena. Artificial Analysis scored it 43 on its Intelligence Index, 3 points behind Kimi K3.1 Pro, and Agent Arena ranks Alibaba as the #5 lab behind Anthropic, Google, OpenAI and Meta. Its pitch is price and token efficiency.

Why does Claude Code still ask me to log in to Anthropic?

QwenCloud's troubleshooting page says to set hasCompletedOnboarding to true in ~/.claude.json. Without it, Claude Code tries to reach Anthropic's login on startup. If you get a 401 invalid_api_key error, your key type does not match the base URL: Token Plan keys and pay-as-you-go keys use different endpoints.

Sources

FREE WEEKLY AI BRIEF

Free. Unsubscribe anytime. Free gift: 50 AI prompts that actually work, sent the moment you join. More about Decoded