Qwen4-Max migration: fix the output budget before switching agents
A Qwen3.8-Max configuration can stop too early after switching to Qwen4-Max. The reason is an API contract change: an output cap sized for the visible answer now also covers thinking. Both models have a million-token con
A Qwen3.8-Max configuration can stop too early after switching to Qwen4-Max. The reason is an API contract change: an output cap sized for the visible answer now also covers thinking. Both models have a million-token context, so that familiar specification can hide the difference.
Begin with one request
The AIHubMix model guide lists qwen4-max on Chat Completions. With an API key in AIHUBMIX_API_KEY, start here:
curl -sS https://aihubmix.com/v1/chat/completions \
-H "Authorization: Bearer $AIHUBMIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen4-max",
"max_completion_tokens": 16384,
"messages": [{"role": "user", "content": "Write a Python function that returns unique items in their original order, with two tests."}]
}'
This is a documented starting request, not a measured result. AIHubMix's capability flags remain unverified; inspect the returned text, stopping reason, and usage.
Fix the inherited controls
The Chat Completions reference defines max_tokens and max_completion_tokens identically for Qwen4-Max: thinking plus answer. A 300-token cap can be consumed before the answer starts. Renaming it does not fix truncation. Check finish_reason: "length", increase the allowance, and confirm the complete answer.
The ceiling is 262,144 combined tokens in thinking mode, or 131,072 without thinking. Input and output must fit inside the 1,000,000-token context together.
Qwen4-Max's effort values are low, high, and xhigh, defaulting to high. Omitting both thinking controls selects high and a 131,072-token budget. medium maps to high, minimal to low, max to xhigh, and none disables thinking. Unlike Qwen3.8-Max, high no longer maps to xhigh.
Send either reasoning_effort or thinking_budget, never both. A budget must be positive; zero is invalid. With a budget alone, 1β4,096 selects low, 4,097β131,072 selects high, and 131,073β262,144 selects xhigh. An optional reasoning_effort: "low" follows the vendor contract; gateway forwarding has not been measured here.
Keep history and cache assumptions separate
Preserve historical reasoning_content outside content, including tool-call turns. Qwen4-Max enables preserve_thinking by default, and replayed reasoning is billed as input.
Alibaba's summary mode instead requires unchanged encrypted_content for history; the display summary cannot replace it. Enable thinking_display: "summarized" every request and retain the separate encrypted streaming frame, including frames without visible text. AIHubMix support is unverified.
Alibaba's explicit cache needs a prefix of at least 1,024 tokens. Five-minute and one-hour writes cost about 125% and 200% of ordinary input. Check actual reads, writes, and billing; these controls have not been measured through AIHubMix. Ordinary implicit caching does not guarantee hits.
Finish with one repository task
Use the Qwen Code guide, setting OPENAI_BASE_URL=https://aihubmix.com/v1, OPENAI_MODEL=qwen4-max, and OPENAI_API_KEY. Confirm the model with /status and inspect context/output settings.
In a scratch repository, fix one failing test across two files. Require a completed tool call, passing tests, and only intended edits. Ask a dependent follow-up and inspect preserved history and compaction. Repeat with your chosen effort; compare accepted patches, tokens, and retries.
Claude Code needs Messages and Codex needs Responses. Their availability for this model through AIHubMix is not established by the listed Chat endpoint. Verify the required protocol and a complete tool workflow before relying on either.
Keep reading: the Qwen4-Max series
- For the upgrade decision, read Qwen4-Max vs Qwen3.8-Max: audit the output budget before upgrading.
- For choosing a repository agent, read Qwen4-Max vs Kimi K3.1 Pro: compare cost per accepted patch.
Sources
- Alibaba Cloud: Qwen4-Max and Qwen3.8-Max.
- Alibaba Cloud: Chat Completions parameters.
- Alibaba Cloud: Thinking summary and encryption.
- Alibaba Cloud: Explicit cache for Qwen4.
- AIHubMix: Model guide and Qwen Code.
Sources checked November 17, 2026. No paid inference tests were run for this article.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.