Last updated: · Applies to: Qwen4-Max on QwenCloud; Claude Code, Codex, Cline and Qwen Code
Qwen4-Max for coding
Status as of 16 Nov 2026: use qwen4-max for the GA Qwen4 flagship, available through QwenCloud Token Plan and the pay-as-you-go API. It has a 1,000,000-token context and closed weights. Singapore API rates are $1.50 input / $4.50 output per million tokens, including thinking in output. Choose your billing plan before copying a client configuration: the endpoints and keys differ.
What is Qwen4-Max?
Alibaba describes Qwen4-Max as the first and flagship Qwen4 model and its most capable Qwen model to date. It uses a mixture-of-experts (MoE) architecture with 2.4 trillion total parameters and 71 billion activated per token. Alibaba reports 25% fewer activated parameters than Qwen3.8-Max at the same 2.4T scale.
Weights are closed and cannot be downloaded. Alibaba says smaller open-weight models in the Qwen4 series will be released later; a schedule is not officially published. Access includes QwenCloud, QwenWork and QwenStudio. The official model changelog lists qwen4-max on November 16, 2026.
The QwenCloud specification lists native vision, image, video and PDF understanding, text generation, thinking, function calling, structured output, web search, MCP, explicit cache and CoT Summary. The code interpreter requires thinking. Batch inference, fine-tuning and model deployment are not supported.
| Limit | Tokens |
|---|---|
| Context length | 1,000,000 |
| Maximum input, non-thinking | 991,808 |
| Maximum input, thinking | 983,616 |
| Maximum output, non-thinking | 131,072 |
| Maximum thinking + final answer | 262,144 |
| Default thinking budget | 131,072 |
Regions: Singapore (International), China North 2 (Beijing, China), and Frankfurt, Hong Kong, Tokyo and US (Virginia) (Global). Beijing and Global share prices; Singapore has separate prices.
Reported results: Alibaba’s announcement and launch blog report 6th place on Code Arena. On Work360, Alibaba’s proprietary benchmark covering 721 specialized fields, Alibaba says Qwen4-Max outperforms Qwen3.8-Max overall, uses 35% fewer tokens at High effort and lowers average task cost by around 60%. These are Alibaba’s claims, not independent tests by this site.
GA versus preview: qwen4-max is the GA flagship. qwen4-max-preview is a separate Token Plan preview model. Some official client sample blocks still select the preview; this guide selects GA and keeps the preview’s output notes separate.
For another model-specific walkthrough, see the Gemini 4 Hydrogen coding guide, covering its API, pricing and Antigravity setup. For GLM-5.4 Coding Plan setup in Claude Code and Cline, see the GLM-5.4 guide. For pricing and model comparisons, see the Gemini 4 Neon API pricing guide.
How to call the API
Pay-as-you-go: OpenAI-compatible Python quick start
Install the OpenAI SDK for Python and set DASHSCOPE_API_KEY to your Singapore QwenCloud API key. This example adapts the official quick start to a coding prompt; it uses Chat Completions.
export DASHSCOPE_API_KEY="YOUR_API_KEY"import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1",
)
response = client.chat.completions.create(
model="qwen4-max",
messages=[{"role": "user", "content": "Write a Python function that detects a cycle in a directed graph."}],
)
print(response.choices[0].message.content)For another pay-as-you-go region, replace ap-southeast-1 in the URL and use a key from that region. Keys are region-specific. Qwen4-Max also supports Responses, Anthropic Messages and DashScope. For DashScope, use its multimodal endpoint even for text-only input.
Token Plan versus pay-as-you-go
The official billing boundary is explicit: Token Plan dedicated keys start with sk-sp- and deduct from Token Plan Credits. General QwenCloud keys, described as starting with sk-, use pay-as-you-go billing. Individual, Team and pay-as-you-go keys are not interchangeable.
| Plan | OpenAI-compatible base URL | Anthropic-compatible base URL |
|---|---|---|
| Token Plan | https://token-plan.maas.qwencloudapi.com/compatible-mode/v1 | https://token-plan.maas.qwencloudapi.com/apps/anthropic |
| Pay-as-you-go, Singapore | https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1 | https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic |
To adapt the Python example for Token Plan, use the Token Plan OpenAI-compatible base URL and a matching Token Plan key. Credits and pay-as-you-go free tokens are separate balances.
Thinking controls
Thinking defaults to enable_thinking=true, reasoning_effort=high and thinking_budget=131072; preserve_thinking is also enabled by default. Chat Completions and DashScope accept low, high or xhigh for effort. To turn thinking off in the Python Chat Completions call, add extra_body={"enable_thinking": False}. See the model usage notes for API-specific controls.
Claude Code setup
The official Claude Code guide uses the Anthropic-compatible endpoint. Some third-party blogs give the wrong base URL by using /compatible-mode/v1; that is the OpenAI-compatible path.
For persistent configuration, merge this env object into ~/.claude/settings.json on macOS/Linux, or C:\Users\<user>\.claude\settings.json on Windows. Use your Token Plan key in place of the placeholder. This adapts the official Token Plan mappings to select GA Qwen4-Max as the main model and the Opus mapping.
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
"ANTHROPIC_BASE_URL": "https://token-plan.maas.qwencloudapi.com/apps/anthropic",
"ANTHROPIC_MODEL": "qwen4-max",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-flash",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-flash",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen4-max",
"CLAUDE_CODE_SUBAGENT_MODEL": "auto",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "983616"
}
}The main model and Opus mapping above select qwen4-max; Haiku, Sonnet and subagent settings retain the official sample’s values. The generic official sample uses auto as the main model and may still map Opus to qwen4-max-preview. For GA, QwenCloud specifically says to set ANTHROPIC_DEFAULT_OPUS_MODEL=qwen4-max and keep CLAUDE_CODE_MAX_CONTEXT_TOKENS=983616.
For pay-as-you-go in Singapore, use https://ap-southeast-1.maas.qwencloudapi.com/apps/anthropic and its matching regional key. Keep the model selection explicit for the model you intend to use. Verify the connection:
claude -p "Hello"If GA long output is truncated, set CLAUDE_CODE_MAX_OUTPUT_TOKENS=131072 in the environment or env object. The separate preview note uses CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000 for qwen4-max-preview.
Base URL must end at /apps/anthropic. Do not append /v1/. Combined with client model discovery, it can produce /v1/v1/models and HTTP 404. The Anthropic-compatible endpoint does not provide /v1/models.
For context errors, see Claude Code compact and context-limit help; for other client errors, browse the Claude Code troubleshooting guides.
Codex setup
If you still need the CLI, start with the Codex CLI installation guide.
For OpenAI model selection in the same client, see the GPT-6.2 Astra guide for Astra vs Sol, pricing and Codex configuration.
Use the official QwenCloud Codex configuration in ~/.codex/config.toml on macOS/Linux, or C:\Users\<user>\.codex\config.toml on Windows. Set OPENAI_API_KEY to the matching plan key.
export OPENAI_API_KEY="YOUR_API_KEY"Token Plan
The official sample uses model = "auto"; this version explicitly selects GA Qwen4-Max. You can also select it with codex -m qwen4-max.
model_provider = "Token_Plan"
model = "qwen4-max"
[model_providers.Token_Plan]
name = "Token_Plan"
base_url = "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"Pay-as-you-go, Singapore
Use your Singapore QwenCloud key for this provider. Generic official samples may show an older model ID; the GA ID here is qwen4-max.
model_provider = "QwenCloud"
model = "qwen4-max"
[model_providers.QwenCloud]
name = "QwenCloud"
base_url = "https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"QwenCloud notes that Codex 0.94.0 and later support only the Responses API. Its legacy instructions use wire_api = "chat" for older Codex or Chat Completions-only models. Use the Responses configuration above for current Codex with Qwen4-Max.
codex exec "Hello"Optional model metadata: follow the official doc to create ~/.codex/model-catalog.local.json and connect it with model_catalog_json in config.toml. Its qwen4-max entry has context_window: 1000000, reasoning levels low/high/xhigh and default high. This avoids the Model metadata ... not found warning; the official FAQ says calls still work with default metadata when it is absent.
For broader client or configuration problems, see the Codex troubleshooting hub.
Cline setup
Install the Cline VS Code extension and open its settings. The QwenCloud Cline guide says to choose OpenAI Compatible as the API Provider.
- Token Plan Base URL:
https://token-plan.maas.qwencloudapi.com/compatible-mode/v1, with your matching Individual or Team Token Plan key. - Pay-as-you-go Singapore Base URL:
https://ap-southeast-1.maas.qwencloudapi.com/compatible-mode/v1, with the Singapore QwenCloud key. - Model ID:
qwen4-max. The generic official examples often showqwen3.8-max; use the GA Qwen4 ID for this guide.
For 401 Incorrect API key, check both the key’s billing plan and, for pay-as-you-go, its region against the Base URL.
Qwen Code CLI setup
The official Qwen Code guide provides this macOS/Linux installer:
bash -c "$(curl -fsSL https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen.sh)" -s --source bailianOn Windows, follow the install-qwen.bat command in the same official guide. After installation, close and reopen cmd, then check the version:
qwen --version- Run
qwenand select Alibaba ModelStudio on first use. - Select your billing plan. The official walkthrough selects Singapore as the region.
- Enter the matching plan key; for pay-as-you-go, match the selected region too.
- Use
/modelto chooseqwen4-max, then verify:
qwen -p "Hello"On macOS/Linux, the config file is ~/.qwen/settings.json. This shortened Token Plan Individual example keeps the official field names and the GA model entry. The full official sample also includes auto and the separate qwen4-max-preview.
{
"$version": 4,
"env": {
"QWENCLOUD_TOKEN_PLAN_API_KEY": "YOUR_API_KEY"
},
"modelProviders": {
"openai": [
{
"id": "qwen4-max",
"name": "[Token Plan Individual] qwen4-max",
"baseUrl": "https://token-plan.maas.qwencloudapi.com/compatible-mode/v1",
"envKey": "QWENCLOUD_TOKEN_PLAN_API_KEY"
}
]
}
}The client’s default output limit is 32768. For longer output, set generationConfig.samplingParams.max_tokens in the model entry. GA supports at most 131,072 output tokens without thinking or 262,144 for thinking plus the final answer. If the model is missing, upgrade Qwen Code or add it manually under modelProviders.openai.
Pricing
Pay-as-you-go API
The official QwenCloud pricing page lists these USD rates per million tokens. Thinking and non-thinking use the same prices, with no input-length tiers. Thinking tokens are output tokens and incur the output rate.
| Billing item | Singapore (International) | Beijing (China) / Global |
|---|---|---|
| Input | $1.50 | $1.413 |
| Output, including thinking | $4.50 | $4.24 |
| Cache write, 5 minutes | $1.875 | $1.767 |
| Cache write, 1 hour | $3 | $2.827 |
| Explicit / implicit cache read | $0.075 | $0.071 |
Alibaba’s announcement highlights $0.075 per million input tokens on an implicit cache hit; that is the Singapore cache-read rate, not the ordinary input rate. QwenCloud lists 1 million free tokens for Singapore pay-as-you-go calls, separate from Token Plan Credits. Check the official Free quota page for eligibility and validity.
Token Plan Individual
The Individual overview lists monthly Credits, rather than a fixed number of tokens. Limited-time prices can change; check the official plan page before subscribing.
| Plan | List price | Limited-time new-user price | Monthly Credits |
|---|---|---|---|
| Lite | $6/month | $3/month | 20,000 |
| Essential | $10/month | $5/month | 45,000 |
| Standard | $18/month | — | 80,000 |
| Pro | $43/month | — | 200,000 |
Individual Credit Packs cost $15/pack/month for 20,000 Credits, with up to five at a time and an active subscription required. See Usage and quota for deduction and reset rules.
Token Plan Team
The Team overview lists Standard at $20/seat/month for 25,000 Credits, Pro at $75 for 100,000, and Max at $180 for 250,000. Pro and Max prices are also per seat per month. A shared team Credit Pack costs $700/pack for 625,000 Credits.
Common errors
Use the official Codex FAQ, Claude Code FAQ and Cline troubleshooting for the full checks.
- 401 Unauthorized / Incorrect API key: match the key to Individual, Team or pay-as-you-go and the configured endpoint. Check regional keys for pay-as-you-go, subscription status and copy errors.
- 404 Not Found in Codex: check
base_urlandwire_apiagainst the selected plan’s example. Current Qwen4-Max configuration usesresponses. - 404 in Claude Code or model discovery: end the base URL at
/apps/anthropic; remove an appended/v1/. The endpoint does not expose/v1/models. - AccessDenied / HTTP 403 in Claude Code: a mapped model may be marked Upcoming deprecation in the QwenCloud Model Gallery. Check every mapped model against the official client FAQ.
- stream disconnected before completion: the Codex FAQ lists long-thread compaction failures, network interruptions, server load and rate limits. Try a new thread, check the connection, and wait and retry for transient failures. For Codex using the official OpenAI provider, see Codex stream disconnected before completion.
- 429: distinguish request rate limits from exhausted Token Plan quota. Reduce request frequency for a rate limit; check Credits and reset timing for quota exhaustion. The official Codex FAQ explains the quota reset field and its timezone. QwenCloud Token Plan or pay-as-you-go quota is separate from the ChatGPT-plan allowance covered in Codex usage limits and the Anthropic plan limits covered in Claude Code usage limit errors.
- Long output stops early: check the client limit as well as the model limit. Claude Code’s documented GA override is
131072, its preview override is64000, and Qwen Code defaults to32768.
FAQ
What is the Qwen4-Max model ID?
The GA flagship model ID is qwen4-max. It is available through QwenCloud Token Plan and the pay-as-you-go API. qwen4-max-preview is a separate Token Plan preview model with its own output-limit notes.
Can I download Qwen4-Max weights?
No. Qwen4-Max is closed-weight and is not downloadable. Alibaba says smaller open-weight Qwen4 models will follow, but an official release schedule is not published.
Which base URL should Claude Code use?
Use the Anthropic-compatible path ending in /apps/anthropic. For Token Plan, the base URL is https://token-plan.maas.qwencloudapi.com/apps/anthropic. Do not use /compatible-mode/v1 or append /v1/ to the Anthropic base URL.
Can I reuse a Token Plan key for pay-as-you-go?
No. Token Plan Individual, Token Plan Team and pay-as-you-go keys are not interchangeable. Token Plan uses its own endpoint and Credits; pay-as-you-go uses regional endpoints and region-specific keys.
How much does the Qwen4-Max API cost?
In Singapore, input costs $1.50 and output costs $4.50 per million tokens. In Beijing and Global regions, input costs $1.413 and output costs $4.24 per million tokens. Thinking tokens are billed as output; thinking and non-thinking modes use the same prices without input-length tiers.
Is there a free Qwen4-Max quota?
QwenCloud lists 1 million free tokens for pay-as-you-go calls in Singapore, subject to the official Free quota eligibility and validity rules. This quota is separate from Token Plan Credits.
What are the Qwen4-Max context and output limits?
The context length is 1,000,000 tokens. Maximum input is 991,808 tokens without thinking or 983,616 with thinking. Maximum output is 131,072 tokens without thinking, or 262,144 tokens for thinking and the final answer combined. The default thinking budget is 131,072 tokens.
How do I turn thinking off?
Thinking is enabled by default at high effort with a thinking budget of 131072. In Chat Completions, set enable_thinking=false. The supported reasoning_effort values for Chat Completions and DashScope are low, high and xhigh.
Sources
This unofficial guide uses Alibaba and QwenCloud official sources. Examples adapt their client configurations for the GA qwen4-max model. Reported results remain attributed to Alibaba; no live API calls or independent model benchmarks were run for this article.
- Alibaba press announcement — flagship, architecture, weights and reported results
- Alibaba launch blog — model positioning and reported comparisons
- QwenCloud latest model — capabilities, limits, defaults and API quick start
- QwenCloud pricing — regional token and cache rates
- QwenCloud model changelog — GA model release
- OpenAI-compatible Chat Completions API reference
- Anthropic-compatible Messages API reference
- QwenCloud Claude Code guide — mappings, endpoints and FAQ
- QwenCloud Codex guide — Responses configuration, model catalog and FAQ
- QwenCloud Cline guide — provider, plan settings and 401 checks
- QwenCloud Qwen Code guide — installers, first run and configuration
- Token Plan Individual overview — models, plans and Credit Packs
- Token Plan usage and quota — key types, Credits and billing boundary
- Token Plan Team overview — seats and shared Credit Packs
- QwenCloud Qwen4-Max model page
- QwenCloud Free quota — eligibility and validity
Unofficial guide, not affiliated with or endorsed by Alibaba, Qwen or OpenAI. Check the official sources for current model availability, prices and client settings.