Qwen4-Max's output limit covers thinking and the final answer. That is the first setting to audit when connecting a client: a cap sized for visible text can be consumed before the answer arrives. A cheaper token rate cannot compensate for an incomplete result.
The AIHubMix model guide lists qwen4-max with Chat Completions at https://aihubmix.com/v1. Its capability flags remain unverified. Start with that listed route, then check the response before depending on additional parameters or protocols.
Size the request
Alibaba's model page lists text, image, and video input. Its limits have different scopes:
| Setting | Tokens |
|---|---|
| Total context | 1,000,000 |
| Maximum input, thinking | 983,616 |
| Maximum input, non-thinking | 991,808 |
| Maximum thinking plus answer | 262,144 |
| Maximum non-thinking output | 131,072 |
Input and output must fit the context together. The input ceiling and output ceiling are not allowances to add on top of each other.
The Chat Completions reference makes max_tokens equivalent to max_completion_tokens; both include thinking. Prefer the latter for new integrations. If finish_reason is length, inspect the incomplete result and allow more room. HTTP success alone does not establish task completion.
Pick one thinking control
Native effort levels are low, high, and xhigh. Omitting both effort and thinking budget selects high with a 131,072-token thinking budget. This is a ceiling, not expected usage.
Send either reasoning_effort or thinking_budget, never both. An explicit budget must be a positive integer; zero is invalid. Compatibility values map minimal to low, medium to high, and max to xhigh; none disables thinking. The combined output cap still applies regardless of effort.
Calculate a baseline
Official Singapore prices are $1.50 per million ordinary input tokens and $4.50 per million output tokens, including thinking. Other regions differ.
For 100,000 uncached input tokens and 10,000 output tokens, the calculation is $0.150 + $0.045 = $0.195. This is an estimate, excluding cache writes, tools, retries, and taxes.
The checked AIHubMix guide lists $1.471 input, $4.412 output, and $0.0735 cached input per million. These November 17 rates do not establish that a particular cache-control workflow works through the gateway.
Preserve history before optimizing it
Alibaba enables preserve_thinking by default. Keep historical reasoning_content separate from content, associated with its answer and tool calls. Replayed history is billed as input.
Optional summaries require thinking_display="summarized" on every request. The display summary arrives in reasoning_content; encrypted_content carries the reasoning history. Replay ciphertext unchanged, including separate streamed frames with no visible text. The summary cannot replace it. Gateway support for these controls has not been measured here.
Check cache writes and reads
Alibaba's explicit cache supports manual and automatic breakpoints, a minimum 1,024-token prefix, at most four valid breakpoints, and 5-minute or 1-hour TTLs. Writes cost approximately 125% or 200% of ordinary input, respectively.
Ordinary implicit caching offers no guaranteed hit. In the explicit interface, prompt_cache_options.mode="implicit" means an automatic breakpoint governed by explicit-cache TTL and billing rules.
Verify forwarding, read/write usage, and gateway rates before projecting savings. Then run one complete task in a disposable repository and inspect its tests and diff. Review the output budget, history handling, and client settings together before switching an existing agent. Responses and Anthropic Messages need separate route verification. No live inference test is reported here.
Sources
- Alibaba Cloud: Qwen4-Max.
- Official pricing, Singapore USD list.
- Chat Completions reference.
- Thinking summary and encryption and Qwen4 explicit cache.
- AIHubMix model guide. Sources and prices checked November 17, 2026, 02:33 UTC.
Top comments (0)