Qwen4-Max passed 63 of 66 graded DevOps runs and billed $0.054 for our full 11-task suite at its default high reasoning effort. Qwen3.8 Max billed $0.275 for the same eleven tasks two months earlier, so the per-suite bill fell to about a fifth. We called the model through OpenRouter (tested November 2026 on Ubuntu 26.04), ran every task three times at low and three times at high effort, and graded each artifact with the tool that would consume it in production.
The three misses were real failures, not formatting slips: a Puppet heredoc the parser rejected twice and a systemd unit that refused to start on a host without an /efi directory. This guide gives the graded numbers first, then the working setups we captured: curl, the OpenAI Python SDK and Claude Code. It ends with the two token traps that cost us money during testing.
Qwen4-Max results on 11 DevOps tasks
Each row averages three runs per task and per effort level, all at temperature 0. Cost is what OpenRouter billed per run at $1.50 per million input tokens and $4.50 per million output tokens, and latency is the full request time measured from our workstation, reasoning included. The Qwen3.8 Max column carries the per-task grade Qwen3.8 Max earned at its default setting in our DeepSeek V4 vs Qwen3.8 Max scorecard.
| Task | Qwen3.8 Max (default) | Pass (low / high) | Reasoning tokens (low / high) | Cost per run (low / high) | Latency (low / high) |
|---|---|---|---|---|---|
| OpenTofu AWS VPC | Pass | 3/3 / 3/3 | 133 / 170 | $0.0069 / $0.0068 | 18.9 s / 17.7 s |
| Kubernetes Deployment, HPA, PDB | Pass | 3/3 / 3/3 | 841 / 1,561 | $0.0095 / $0.0142 | 27.8 s / 42.6 s |
| Ansible nginx and ufw playbook | Pass | 3/3 / 3/3 | 114 / 85 | $0.0019 / $0.0018 | 6.3 s / 5.4 s |
| Puppet class with inline EPP | Pass | 2/3 / 2/3 | 1,341 / 1,360 | $0.0074 / $0.0075 | 28.1 s / 28.5 s |
| GitHub Actions Go matrix and GHCR push | Pass | 3/3 / 3/3 | 214 / 254 | $0.0034 / $0.0038 | 10.4 s / 12.3 s |
| Argo CD Application | Pass | 3/3 / 3/3 | 165 / 19 | $0.0018 / $0.0011 | 4.9 s / 3.2 s |
| FastAPI multi-stage Dockerfile | Pass | 3/3 / 3/3 | 101 / 85 | $0.0022 / $0.0021 | 6.8 s / 7.7 s |
| Idempotent PostgreSQL schema | Pass | 3/3 / 3/3 | 111 / 90 | $0.0018 / $0.0017 | 5.6 s / 4.9 s |
| Hardened systemd unit | Pass | 2/3 / 3/3 | 957 / 1,779 | $0.0074 / $0.0116 | 26.0 s / 41.6 s |
| Fix a broken nginx server block | Pass | 3/3 / 3/3 | 64 / 69 | $0.0011 / $0.0011 | 3.3 s / 3.3 s |
| awk log aggregation one-liner | Pass | 3/3 / 3/3 | 639 / 380 | $0.0039 / $0.0027 | 13.2 s / 9.1 s |
| Suite per run | 11 of 11 | 31/33 / 32/33 | 4,679 / 5,853 | $0.047 / $0.054 | 151 s / 176 s |
Against the older model, accuracy at the default setting slipped from 33 of 33 runs to 32 of 33. One caveat applies to the systemd row: our grader also starts each unit, which the earlier test did not, so the single /efi miss would have passed under the old method. Two more things stand out. High effort cost only 15% more than low across the suite, where Qwen3.8 Max showed a fivefold gap between its default and low settings on the same battery. And the extra spend did not buy accuracy: high effort fixed the one systemd miss but repeated the Puppet failure, which means the Puppet bug is a knowledge gap, not a thinking-time gap. For most DevOps generation work we would leave the effort at the default and stop worrying about the dial.
How the battery was run and graded
Every task asked for one artifact and nothing else, with a system prompt that banned explanations and markdown fences. No output in 66 runs came back fenced, which matters when a pipeline writes the reply straight to disk. Grading ran on a separate Ubuntu 26.04 VM named bench01, and a run passed only when the artifact cleared every check below.
- OpenTofu, Ansible, Puppet, GitHub Actions: the native validator (
tofu validate,ansible-playbook --checkagainst localhost,puppet parser validate,actionlint). - Kubernetes and Argo CD:
kubectl apply --dry-run=serveragainst a kind cluster, so the API server checked field names and versions, not just YAML syntax. A dry run cannot see a Namespace created in the same stream, so the grader createdshopfirst. - Dockerfile, PostgreSQL, systemd, nginx: the artifact had to work, not just parse. The image had to build and answer
/healthzas a non-root user. The SQL had to apply twice without an error, the unit had to start and score undersystemd-analyze security, andnginx -thad to pass. - awk: the one-liner ran against a fixed access log with shuffled field order, and its output was diffed against a known-good file.
The tool versions on the grading VM were captured with the results:
tofu: OpenTofu v1.13.9 (hashicorp/aws v5.100.0 resolved by init)
kubectl: Client Version: v1.37.0 Server Version: v1.37.0
kind: kind v0.33.0 go1.26.8 linux/amd64
ansible-core: ansible [core 2.20.1]; community.general 12.1.0
puppet: 8.10.0 (Ubuntu puppet-agent package; openvox not used)
actionlint: 1.7.12
docker: Docker version 29.1.3, build 29.1.3-0ubuntu4.1
postgres: psql (PostgreSQL) 18.6 (Ubuntu 18.6-0ubuntu0.26.04.1)
nginx: nginx version: nginx/1.28.3 (Ubuntu)
systemd: systemd 259 (259.9-0ubuntu0.1)
os: Ubuntu 26.04.1 LTS, kernel 7.0.0-1017-gcp
One caveat on the comparison. The earlier DeepSeek V4 vs Qwen3.8 Max DevOps test described its tasks but did not publish the exact prompts, so our prompts are reconstructions from those descriptions. The task shapes match, the wording does not, and token counts can move with wording. Treat the cost ratio as a strong signal rather than a lab-exact delta.
What changed from Qwen3.8 Max
Singapore list prices fell by a quarter, Beijing by about 14%, and the reasoning control got simpler. The figures below come from the Alibaba Model Studio documentation and the OpenRouter model page, read on 16 November 2026, plus our own Qwen3.8 Max run for the measured row.
| Item | Qwen3.8 Max | Qwen4-Max | Source |
|---|---|---|---|
| Price per 1M tokens, Singapore (input / output) | $2.00 / $6.00 | $1.50 / $4.50 | Model Studio pricing |
| Price per 1M tokens, Beijing (input / output) | $1.65 / about $4.95 | $1.413 / $4.24 | Model Studio pricing |
| Cached input read | not compared | $0.075 per 1M | Model Studio pricing, OpenRouter |
| Context window | 1M tokens (our earlier test) | 1M tokens (983,616 input in thinking mode) | Model Studio model page |
| Max output | not compared | 131,072 without thinking; 262,144 thinking plus answer | Model Studio model page |
| Reasoning effort values | default and low tested | low, high (default), xhigh | Model Studio model page |
| Suite cost at default effort, our battery | $0.275 | $0.054 | Measured |
| awk task at default effort | 14,600 reasoning tokens, just under 7 min, $0.091 | 380 reasoning tokens, 9.1 s, $0.0027 | Measured |
| Open weights | No | No | Qwen launch blog, our earlier test |
The awk row is the clearest change in behaviour. Qwen3.8 Max talked itself into a seven-minute deliberation. Qwen4-Max spent 380 reasoning tokens and returned a correct one-liner in nine seconds. In the launch post, Alibaba claims token use on agentic benchmarks dropped by 24% to 49% against Qwen3.8 Max, depending on benchmark and effort. Strip out the 25% price cut and our 5x cost drop is still about a 3.8x drop in tokens on short generation tasks, which fits a model that now skips thinking it does not need. Pricing also differs by region: the Model Studio pricing page lists the Singapore international rate at $1.50 and $4.50, while Beijing, Hong Kong, Frankfurt, Virginia and Tokyo sit at $1.413 and $4.24.
Is Qwen4-Max open source?
No. The Qwen4-Max launch post offers it through the API, the Token Plan, QwenStudio, QwenWork and Qoder, and lists no weights to download. It says smaller models in the family will follow as open source, without giving dates. If you need a Qwen model on your own hardware today, the open releases are the route: we measured VRAM and speed when we ran Qwen3.8-27B locally, and the MoE Qwen3.8 Flash-Next under llama.cpp and Ollama fits a single consumer GPU.
Step 1: Get API access
Two routes serve the model: OpenRouter, where it is listed as qwen/qwen4-max with Alibaba as the only provider, and Alibaba Cloud Model Studio directly. We tested through OpenRouter. It takes one key, bills per request in dollars, and returns the cost of every call in the response, which is how the per-task figures above were collected.
- OpenRouter: create a key under Keys in your OpenRouter account, add credit, and export it as
OPENROUTER_API_KEY. Our whole test, 66 graded runs plus the trap and Claude Code experiments, used about $0.47. - Model Studio: activate Model Studio in the Singapore region of an Alibaba Cloud international account and create an API key in that workspace. The OpenAI-compatible base URL is workspace-specific, in the form
https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1, and the model name is plainqwen4-max.
We did not have a Model Studio account for this test, so every command in this guide runs against OpenRouter. The OpenAI-compatible request body is the same on both, so moving later is a base URL and key change, plus dropping the qwen/ prefix from the model name.
Is there a free Qwen4-Max tier?
The Model Studio pricing page lists a free quota of 1 million tokens for Qwen4-Max in the Singapore region only. It is valid for 90 days from activation, model release or approval, whichever comes later. We could not confirm the grant through a signup of our own, so treat it as an offer stated by the vendor. The OpenRouter model list carried only the paid qwen/qwen4-max when we checked, with no free variant, and every call we made there was billed.
Step 2: Make the first call with curl
A one-line question at low effort is the cheapest way to confirm the key, the model slug and the billing path. The jq filter keeps the answer, the finish reason and the usage block, which includes the cost OpenRouter charged:
curl -s https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"qwen/qwen4-max","reasoning_effort":"low","messages":[{"role":"user","content":"Which systemctl command shows why a unit failed? One line."}]}' \
| jq '{model, provider, content: .choices[0].message.content, finish: .choices[0].finish_reason, usage: .usage}'
Alibaba served the request and returned a correct answer, 117 reasoning tokens and a bill of $0.000807:

Read the usage block before anything else. Of the 168 completion tokens, 117 were reasoning, so even at low effort 70% of the output bill went on thinking the reader never sees. That ratio is normal for short questions and falls on longer artifacts, where the answer itself dominates. OpenRouter accepts the OpenAI-style top-level reasoning_effort used here; its reasoning docs show the nested "reasoning": {"effort": "low"} form.
Step 3: Call it from the OpenAI Python SDK
Any OpenAI-compatible client works by swapping the base URL. We installed the openai package into a virtual environment and saved this as qwen_sdk.py:
import os
from openai import OpenAI
client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=os.environ["OPENROUTER_API_KEY"])
resp = client.chat.completions.create(
model="qwen/qwen4-max",
reasoning_effort="low",
max_tokens=4000,
messages=[
{"role": "system", "content": "Answer with one shell command and nothing else."},
{"role": "user", "content": "List the 5 largest directories under /var, human readable."},
],
)
choice = resp.choices[0]
print("finish_reason:", choice.finish_reason)
print("answer:", choice.message.content)
print("prompt_tokens:", resp.usage.prompt_tokens)
print("completion_tokens:", resp.usage.completion_tokens)
print("reasoning_tokens:", resp.usage.completion_tokens_details.reasoning_tokens)
Run it with the key exported in the same shell:
python3 qwen_sdk.py
The script prints the finish reason first, because that is the field that tells you whether the answer is complete:

Qwen4-Max returned a correct command but chose head -6 for a top five, because the first line of du output for /var is /var itself. That is a sensible call a quick reader might flag as a bug. Note the max_tokens=4000: it is there on purpose, and Step 7 shows what happens when it is set too low.
Step 4: Point Claude Code at Qwen4-Max
Claude Code speaks the Anthropic Messages API, and OpenRouter exposes that API at https://openrouter.ai/api. Eight environment variables route the Opus, Sonnet, Haiku and subagent slots to Qwen4-Max. ANTHROPIC_API_KEY must be set to an empty string, otherwise Claude Code tries the Anthropic login first:
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
export ANTHROPIC_API_KEY=""
export ANTHROPIC_MODEL="qwen/qwen4-max[1m]"
export ANTHROPIC_DEFAULT_OPUS_MODEL="qwen/qwen4-max[1m]"
export ANTHROPIC_DEFAULT_SONNET_MODEL="qwen/qwen4-max[1m]"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen/qwen4-max"
export CLAUDE_CODE_SUBAGENT_MODEL="qwen/qwen4-max[1m]"
The [1m] suffix matters. Without it, Claude Code assumes a 200,000-token window, so it compacts the conversation five times earlier than it needs to. With the suffix, a one-turn check reported "contextWindow":1000000 in its JSON result; that run is saved as text only, so the screenshot below still shows the earlier 200,000 window. Our runs set ANTHROPIC_MODEL; the Opus, Sonnet and subagent slots follow the OpenRouter Claude Code guide, and OpenRouter strips the suffix before routing. If you were logged in to an Anthropic account before, run /logout inside Claude Code once, then confirm the endpoint with /status. For the rest of the setup, pinning and hooks, our Claude Code cheat sheet on installing, pinning and configuring MCP, plugins and hooks covers it with output from Ubuntu, AlmaLinux and Rocky.
To see whether Qwen4-Max can drive an agent loop, we gave it a broken log-pruning script in a scratch directory. The script had an unquoted cd $LOG_DIR and an off-by-one in tail -n +$KEEP, so it broke on a path with a space and kept one archive too few:
claude -p "prune-logs.sh is supposed to keep the newest KEEP archives in a directory and delete the rest, but it fails on a directory name with a space and keeps the wrong number. Find both bugs, fix the script, and prove the fix by running it on 'logs dir' with KEEP=3." --max-turns 12 --allowedTools "Read" "Edit" "Write" "Bash" --output-format json > result.json
It found both bugs, rewrote the deletion around NUL-delimited find -printf and sort -z, and proved the fix on a directory with a space in its name:

That run took 10 turns and 77 seconds. Ignore the total_cost_usd of $0.237: Claude Code computes it from the Claude price list, not the Qwen one. OpenRouter actually charged about $0.073, measured as our credit delta. Pricing the 23,730 cache-write, 169,664 cache-read and 4,206 output tokens of that run at Qwen4-Max list rates ($1.875 per million for a 5-minute cache write, $0.075 for a cache read and $4.50 for output, from the Model Studio pricing page) gives $0.076. The capture also shows the 200,000 window, because this run predates the [1m] suffix. The fixed script Qwen4-Max wrote:
#!/usr/bin/env bash
set -euo pipefail
# Keep the newest $KEEP compressed logs in $LOG_DIR, delete the rest
LOG_DIR=${1:-./logs}
KEEP=${2:-3}
[[ $KEEP =~ ^[1-9][0-9]*$ ]] || { echo "KEEP must be a positive integer" >&2; exit 1; }
cd -- "$LOG_DIR"
# NUL-delimited mtime sort: safe for spaces/newlines in names, unlike ls | xargs
mapfile -d '' -t files < <(
find . -maxdepth 1 -type f -name '*.gz' -printf '%T@\t%f\0' |
sort -z -rn | cut -z -f2-
)
if (( ${#files[@]} > KEEP )); then
printf '%s\0' "${files[@]:KEEP}" | xargs -0 -r rm -f --
fi
echo "kept $(find . -maxdepth 1 -type f -name '*.gz' | wc -l) archives in $LOG_DIR"
That is what a careful engineer would write, including the input check on KEEP nobody asked for. When several people on a team need access, put a gateway in front instead of handing out the OpenRouter key. A self-hosted LiteLLM proxy or the Bifrost LLM gateway both issue per-user virtual keys with budgets and can fall back to another model when Alibaba has an outage.
Warning: [claude-code:unrecognized_model]
Claude Code printed [claude-code:unrecognized_model] {"model":"qwen/qwen4-max","query_source":"sdk"} to stderr on every call. It is harmless: the run completed normally. It only means Claude Code has no built-in profile for the model, which is why it falls back to the 200K window and Claude pricing described above. For the Model Studio Token Plan route, which we did not test, the Alibaba Claude Code page sets ANTHROPIC_DEFAULT_OPUS_MODEL to qwen4-max with CLAUDE_CODE_MAX_CONTEXT_TOKENS=983616, and suggests CLAUDE_CODE_MAX_OUTPUT_TOKENS=131072 if long answers get cut off.
Step 5: Pick the reasoning effort
Low effort ran the suite for $0.047 and high for $0.054, so the effort setting moves the bill by 15% on this kind of work. The per-task split is uneven. Kubernetes and systemd nearly doubled their reasoning at high effort, while Argo CD, Ansible, Dockerfile, PostgreSQL and awk spent less at high than at low. The low-effort run 1 output shows where the tokens go:

Kubernetes was the most expensive task at both levels, at $0.0095 and $0.0142 per run. Puppet and systemd came next, averaging between 950 and 1,800 reasoning tokens, and they were the two tasks that failed. Run-to-run spread at temperature 0 was wide enough to plan around:
- Kubernetes, low effort: 389 reasoning tokens in run 1 and up to 1,464 in another, for the same prompt.
- systemd, high effort: a 1,779-token average with a 2,297-token maximum. A separate multi-turn test at high effort spent 3,653 reasoning tokens on the same unit.
- Latency: followed total output tokens, reasoning included, at roughly 55 to 80 tokens per second. The slowest single request was a high-effort Kubernetes run at 55.4 seconds.
Our setting: leave it at the default high for anything that ships, since the premium is small and it cleared the systemd case low missed. Use low for interactive shell help where 40 seconds of thinking on a manifest is too slow. We did not test xhigh, the level Alibaba maps the old max value to, because the high setting already left nothing to recover except a syntax gap more thinking did not fix.
Step 6: Check what the model got right and wrong
Nine tasks passed all six runs. The OpenTofu VPC resolved the AWS provider and validated on every run:

The Kubernetes manifests passed the server-side dry run. Four of the six, all three high runs and one low run, also added a ConfigMap we never asked for, with an nginx config that moves the pid file and temp paths to /tmp so nginx can run as UID 101 on a read-only root filesystem:

We graded that as a pass because it is a working, defensible design. The prompt said a non-root setup was not required, though, so the model went past a stated scope in favour of its own hardening habit. A server dry run checks the objects, not the running pod, so we did not grade whether nginx binds port 80 under that context. In a GitOps repo that extra object would show up as drift someone has to explain in review. The systemd units were the opposite story: all six scored 1.1 on systemd-analyze security, against 2.2 for Qwen3.8 Max on the same task:

A lower exposure score is better, so Qwen4-Max locks the unit down tighter. That tightness is also what produced its one systemd failure, covered next. The Dockerfiles built 217 to 230 MB images that ran as a non-root user and answered the health check, and the nginx fix kept the alias and the PHP deny rule intact.
Error: Heredoc without end-tagged line
Two of six Puppet manifests, one at each effort level, failed the parser before Puppet could apply anything:

Both failing runs opened the template with a single-quoted heredoc tag, which Puppet does not accept. Puppet heredoc tags are either bare or double-quoted, so the parser never finds the end tag. The line the model wrote, and the fix that validated:
# generated, rejected by the parser
$chrony_conf = inline_epp(@('EPP'), { 'servers' => $servers })
# bare tag, as in the runs that validated
$chrony_conf = inline_epp(@(EPP), { 'servers' => $servers })
Puppet is the least common language in the battery, and this is the kind of syntax detail a model sees rarely in training. If you generate Puppet with any model, run puppet parser validate in CI before the code reaches a server.
Error: Failed to set up mount namespacing: /efi: No such file or directory
One low-effort systemd unit passed systemd-analyze verify but would not start. The journal on bench01 showed the cause:
metrics-agent.service: Failed to set up mount namespacing: /efi: No such file or directory
metrics-agent.service: Failed at step NAMESPACE spawning /usr/local/bin/metrics-agent: No such file or directory
metrics-agent.service: Main process exited, code=exited, status=226/NAMESPACE
The unit listed InaccessiblePaths=/root /boot /efi. Our cloud VM has no EFI partition mounted at /efi, so that path does not exist. systemd refuses to start when a listed path is missing, unless the path carries a leading -, as in InaccessiblePaths=-/efi. The other five units put the - prefix on every InaccessiblePaths entry and left /efi out entirely. A static validator cannot catch this, because the unit is valid; only starting it on the target host does.
Step 7: Avoid the two token traps
Both traps come from one design choice: reasoning tokens and answer tokens share the same budget and the same bill. The Model Studio OpenAI-compatible docs state that max_tokens limits the sum of the answer and the chain of thought. Nothing reserves room for the answer: at high effort the model can spend the whole limit on thinking.
finish_reason “length” with an empty answer
We sent the systemd task at high effort with max_tokens set to 1,200, then 2,000, then 4,000 with a reasoning budget of 1,024 tokens set through "reasoning": {"max_tokens": 1024}. The first two returned HTTP 200 with no answer at all:

At 1,200 tokens the model spent all 1,200 on reasoning, returned zero characters of content and still billed $0.0056. The 2,000-token request failed the same way for $0.0092. A client that checks only the HTTP status writes an empty file and moves on. Two fixes worked: check finish_reason on every response and treat length as a failure, and size max_tokens for reasoning plus answer. The 4,000-token request with a 1,024-token reasoning budget finished cleanly, although it used 1,761 reasoning tokens, so through OpenRouter the budget did not act as a hard cap.
Passing reasoning back multiplies input cost
On Model Studio, preserve_thinking defaults to true for Qwen4-Max, and the Model Studio docs say the earlier reasoning it keeps in the conversation is counted and billed as input. We reproduced the effect through OpenRouter by sending the reasoning from turn one back with turn two:
| Second turn | Prompt tokens | Completion tokens | Cost |
|---|---|---|---|
| Answer only in history | 901 | 1,151 | $0.0065 |
| Answer plus 3,653 reasoning tokens in history | 4,554 | 1,230 | $0.0124 |
Carrying the reasoning forward made the input of turn two five times larger and its total cost 1.9 times higher, for a follow-up answer of about the same length. In a long agent session that multiplier compounds on every turn. Keep the reasoning out of the history unless a tool-calling flow needs it, and on Model Studio set preserve_thinking to false explicitly, since the default is on.
Where Qwen4-Max fits
On our battery, Qwen4-Max is the cheaper and faster successor to Qwen3.8 Max, with a small accuracy cost. It cut suite spend by about 5x at the default setting, and its slowest request took 55 seconds where Qwen3.8 Max needed nearly seven minutes for the awk task alone. Against Qwen3.8 Max at low effort ($0.056), Qwen4-Max costs about 3% less at its default and about 16% less at low effort, so the gain is largest for teams that ran the old model at its default. Accuracy at the default dropped from 33 of 33 runs to 32 of 33, and both failure types sit in artifacts a validator or a test start catches in seconds. Use it as follows:
- Infrastructure code generation behind CI: a good fit. At about half a cent per artifact, you can afford to validate and regenerate on failure.
- Claude Code or another agent loop: works through OpenRouter with the
[1m]suffix. Budget from OpenRouter’s billing, not Claude Code’s cost line, which overstated our run about 3x. For wiring tools into that loop, see connecting Claude Code to MCP servers. - Air-gapped or data-resident work: not possible, because there are no weights. The open Qwen3.8 models are the fallback on your own hardware.
Watch two numbers in production: the share of responses ending in length, and prompt tokens per turn in multi-turn sessions. A rise in either means the shared reasoning budget is costing you money or answers.