A 300-token max_tokens used to be a safe cap for a short answer. On Qwen4-Max-Preview it returned HTTP 200 with an empty content. Alibaba changed what max_tokens covers: on this model it limits the thinking and the answer together, so the reasoning can use up the budget before the answer starts.
This post reproduces that on AIHubMix, shows the fixes, and covers the settings that matter when you point a coding agent at the model.
Background
Alibaba opened Qwen4-Max-Preview on November 11, 2026, as the next-generation flagship of its Qwen family. Alibaba itself offers it only through Token Plan, a Credits-billed subscription for coding tools, with no pay-as-you-go option. The preview runs until 24:00 on November 25, 2026 (UTC+8), which is 16:00 UTC, and Alibaba retires the model after that.
AIHubMix is the first platform to offer it as a per-token API. It has served the model since launch day as coding-qwen4-max-preview on the OpenAI-compatible endpoint. AIHubMix labels the channel a preview service that "may be unstable and is recommended for testing and evaluation."
Prerequisites
- An AIHubMix API key in
AIHUBMIX_API_KEY - Base URL
https://aihubmix.com/v1 - Model ID
coding-qwen4-max-preview
Reproducing the empty reply
AIHubMix ran this request on November 11, 2026:
curl -s https://aihubmix.com/v1/chat/completions \ -H "Authorization: Bearer $AIHUBMIX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "coding-qwen4-max-preview", "max_tokens": 300, "messages": [{"role": "user", "content": "How many pairs of positive integers (x, y) with x > y satisfy x^2 - y^2 = 2024? List them."}] }' The response, trimmed to the relevant fields:
{ "finish_reason": "length", "content": "", "usage": { "prompt_tokens": 56, "completion_tokens": 300, "completion_tokens_details": {"reasoning_tokens": 300} } } All 300 tokens went to reasoning, and the answer never started. Nothing errors, so a client that only reads content sees an empty string and may treat it as a valid reply. With max_tokens: 16384, the same prompt finished normally: 1,206 completion tokens, 608 of them reasoning, and the correct answer (four pairs).
The same check with the OpenAI Python SDK:
import os from openai import OpenAI client = OpenAI(base_url="https://aihubmix.com/v1", api_key=os.environ["AIHUBMIX_API_KEY"]) resp = client.chat.completions.create( model="coding-qwen4-max-preview", max_tokens=300, messages=[{"role": "user", "content": "How many pairs of positive integers (x, y) with x > y satisfy x^2 - y^2 = 2024? List them."}], ) choice = resp.choices[0] if choice.finish_reason == "length" and not choice.message.content: print("Budget used up before the answer started: raise the limit or lower reasoning_effort") else: print(choice.message.content) Why it happens
Alibaba's API compatibility notice, dated November 2, announced the change, and the model page repeats it:
Starting with qwen4-max-preview, max_tokens is equivalent to max_completion_tokens. Both limit the combined tokens for thinking and the final answer. Thinking consumes part of the same budget, so a limit previously sized for the answer alone may truncate output.
On Qwen3.8-Max, max_tokens limits the answer only; thinking sits outside it. The other differences on Alibaba's published specs:
| Qwen3.8-Max | Qwen4-Max-Preview | |
|---|---|---|
| Context window | 1M | 1M |
| Maximum output | 131,072 | 393,216 |
| What max_tokens limits | Answer only | Thinking + answer |
| Thinking default | On, xhigh | On, xhigh |
| Effort levels | low, medium, xhigh | low, medium, xhigh |
| Input | Text, image, video | Text, image, video |
| Official access | Pay-as-you-go, Token Plan | Token Plan only |
| Status | Available | Retires after Nov 25 |
Qwen4-Max-Preview's output limit is shared by thinking and the final answer. Thinking controls keep the same names and levels, so code that already sets reasoning_effort for Qwen3.8 carries over. Alibaba's launch page lists no benchmark scores, and we found no independent benchmark of this preview as of November 11.
Fixes
- Size limits for thinking plus answer. Remove old answer-only caps, or raise them well above what the answer needs. Alibaba marks
max_tokensas "to be deprecated" and recommendsmax_completion_tokensfor new integrations. On this model the two mean the same thing, so renaming alone fixes nothing:max_completion_tokens: 300returned the same empty reply on AIHubMix. - Cap thinking directly when you need a short reply. Set
reasoning_efforttolow, or tononeto turn thinking off. In AIHubMix's test,noneanswered a short coding prompt in 43 completion tokens with no reasoning. - Check
finish_reasonon every call. Treat"length"with an emptycontentas a failure to retry with a larger budget, not as an answer.
Thinking controls
Thinking is on by default. Alibaba's Chat Completions reference documents the details:
- Levels:
low,medium, andxhigh(the default).maxandhighbecomexhigh,minimalbecomeslow, andnoneturns thinking off. Any other value returns an error. - Budgets: if you don't set
thinking_budget, the levels map to thinking budgets of 4,096 (low), 16,384 (medium), and 262,144 (xhigh) tokens. If you set neither, the same page says the default isxhighwith a 131,072-token budget. By that mapping, sendingxhighexplicitly allows up to twice the default thinking budget. This is how the docs describe it; AIHubMix hasn't measured it. - Don't combine: Alibaba documents setting
reasoning_effortandthinking_budgettogether as an error. One AIHubMix test that sent both returned normally, so the channel may not reject the pair, but nothing documents which setting takes effect. Send only one. - Multi-turn: return earlier thinking in each assistant message's
reasoning_contentfield, never insidecontent. Leaving it out doesn't cause an error, but sending it back is billed as input.
Through AIHubMix, low and none were accepted, and the thinking arrived in reasoning_content.
What a session costs
Alibaba publishes no per-token price for Qwen4-Max-Preview: its only official route is Token Plan, billed in Credits. On AIHubMix the channel bills per token: $0.353 per million input tokens, $1.059 per million output tokens, and $0.0441 per million cached input tokens.
One coding-agent session, with assumptions rather than measurements: 40 turns, each sending 60,000 input tokens, of which 50,000 are a cached repository prefix, and each writing 3,000 output tokens, thinking included.
| One session on AIHubMix | Tokens | Price per 1M | Cost |
|---|---|---|---|
| Uncached input | 400,000 | $0.353 | $0.141 |
| Cached input | 2,000,000 | $0.0441 | $0.088 |
| Output, thinking included | 120,000 | $1.059 | $0.127 |
| Total | 2,520,000 | $0.356 |
Cache hits aren't guaranteed, and AIHubMix hasn't measured them on this channel. With no cache hits, the same session costs about $0.974.
Two details move this number in practice. Thinking counts as output: in AIHubMix's usage data, reasoning tokens are part of completion_tokens, and thinking runs at xhigh by default. And Alibaba turns on preserve_thinking by default for this model: earlier thinking that your client sends back in reasoning_content "is included in the input token count and is billed," so long agent sessions grow their input faster than the visible conversation suggests.
Coding tools
- Claude Code uses the Anthropic Messages API. The AIHubMix model page lists only
/v1/chat/completions, but one test request to AIHubMix's/v1/messageswith this model ID returned a normal response with separate thinking and text blocks. That was a single request without tools, not a Claude Code session. For running Claude Code on non-Claude models, AIHubMix documents a separate setup, Claude Code with any LLM: install its@aihubmix/claude-codepackage, setdefault,think, andlongContextunderRouterin~/.aihubmix-claude-code/config.jsontocoding-qwen4-max-preview, then runacc startandacc code. We haven't run that setup with this model, so try the smoke test below first. Anthropic's documentation doesn't support routing non-Claude models to Claude Code through a gateway, so this setup is unsupported on Anthropic's side. - Qwen Code connects through the OpenAI-compatible endpoint:
OPENAI_BASE_URL=https://aihubmix.com/v1andOPENAI_MODEL=coding-qwen4-max-preview. Its context-size table gives IDs that start withqwen4a 1M window. Our ID starts withcoding-, matches no row, and falls back to the 200,000-token default. That is a reading of the code, not a measured run. Expect Qwen Code to compact the conversation long before 1M. If you need the full length, setmodel.generationConfig.contextWindowSizeto 1000000 in~/.qwen/settings.json. - OpenCode, Cline, Cursor and other OpenAI-compatible tools: add a custom model with the same base URL and ID. Check the context window, which tools often don't know for new IDs, and any default
max_tokensthe tool sends. A small default will now cut into thinking.
A 15-minute smoke test
- Send one Chat Completions request and confirm
reasoning_contentand a non-emptycontentcome back. - Give the agent a small task in a scratch repository: fix one failing unit test across two files. Success means the tests pass and the diff touches only what it should.
- Watch for
finish_reason: "length"in your tool's logs or its usage view. If it shows up, raise the output limit or lowerreasoning_effort. - Repeat the task at
reasoning_effort: "low"and compare time and output tokens. This tells you which level to run day to day.
What wasn't verified
- Tool calling and structured outputs: Alibaba documents both for this model, but AIHubMix hasn't published capability flags for this channel yet, and its model guide says their absence means "unverified, not unsupported." Step 2 of the smoke test is your tool-calling check.
- Claude Code end to end: only one bare Messages request was tested.
- Cache hit rates on this channel.
- The Qwen Code 200,000-token fallback comes from reading the source, not from a run.
For production work, Qwen3.8-Max has the same 1M context, an official pay-as-you-go price, and no announced retirement date, and your max_tokens settings keep their old meaning there. If you test both, the side-by-side comparison on AIHubMix lists their specs and prices; only the model ID changes.
Sources
- Alibaba Cloud Model Studio: Qwen4-Max-Preview (accessed November 11, 2026)
- Alibaba Cloud Model Studio: Chat Completions API reference
- Alibaba Cloud Model Studio: Token Plan (Personal Edition) (accessed November 11, 2026)
- Alibaba Cloud Model Studio: Qwen3.8-Max (accessed November 11, 2026)
- AIHubMix: Coding Qwen4 Max Preview (prices checked November 11, 2026; live tests run 10:22–10:48 UTC)


