DEV Community

HopBase
HopBase

Posted on Originally published at hop-base.com

Qwen4 Max API Pricing, 1M Context & Integration Guide: 16.7% Below Qwen3.8 Max

The short answer: Alibaba's flagship Qwen4 Max API (model ID qwen4-max) is live on HopBase at the official list price of $1.471 input, $0.07353 cached input, and $4.412 output per 1M tokens—16.7% lower than qwen3.8-max ($1.765 / $5.294) on fresh tokens and 66.7% lower on cached reads, with one flat single-tier rate across the entire 1,000,000-token context window. Built for multimodal reasoning and production agents, qwen4-max natively reads text, image, and video input, doubles maximum output to 262,144 tokens when thinking is enabled, and reliably executes forced tool calling (tool_choice) during thinking mode where earlier Qwen models required enable_thinking: false. One API key in the Qwen 4 / 3.8 / 3.7 Series group calls qwen4-max, qwen3.8-max, and qwen3.8-flash natively over OpenAI Chat Completions (POST /v1/chat/completions), OpenAI Responses (POST /v1/responses), and Anthropic Messages (POST /v1/messages). Confirm qwen4-max in GET /v1/models before sending traffic.

Alibaba Qwen 4 API Pricing & 1M Context Comparison: Qwen4 Max vs Qwen3.8 Max vs Qwen3.8 Flash

Within the single Qwen 4 / 3.8 / 3.7 Series key group on HopBase, qwen4-max anchors complex coding, multimodal video understanding, and tool-heavy agent loops; qwen3.8-max remains online for pinned regression baselines; and qwen3.8-flash handles high-throughput multimodal routing at one-tenth the cost (replacing qwen3.7-flash, which retired on 2026-11-17). Here is how Alibaba's published official list prices (USD per 1M tokens) and verified limits compare across the lineup:

Specification qwen4-max qwen3.8-max qwen3.8-flash qwen3.7-plus
Role in Qwen family Qwen 4 flagship (multimodal + agentic reasoning) Previous 3.8 multimodal flagship High-speed 3.8 multimodal flash tier 3.7 general chat (tiered above 262K)
Input modalities Text, image, video Text, image, video Text, image, video Text, image, video
Context window (input ceiling) 1,000,000 (991,808; 983,616 thinking on) 1,000,000 (991,808) 1,000,000 (991,808) 1,000,000 (3× tier step above 262K)
Max output (max_tokens) 131,072 (262,144 with thinking on) 131,072 131,072 131,072
Forced tool_choice in thinking mode Reliably invokes forced tools Send enable_thinking: false Send enable_thinking: false Send enable_thinking: false
Native protocols Chat Completions, Responses, Messages Chat Completions, Responses, Messages Chat Completions, Responses, Messages Chat Completions, Responses, Messages
Official list · Input $1.471 / 1M tokens (−16.7% vs 3.8 Max) $1.765 / 1M tokens $0.1471 / 1M tokens $0.2941 / 1M tokens (>262K: ×3)
Official list · Cached input $0.07353 / 1M tokens (5% of input) $0.2206 / 1M tokens (12.5% of input) $0.01471 / 1M tokens (10% of input) $0.05882 / 1M tokens
Official list · Output (incl. thinking) $4.412 / 1M tokens (−16.7% vs 3.8 Max) $5.294 / 1M tokens $0.4412 / 1M tokens $1.176 / 1M tokens (>262K: ×3)

Billing governance notes: all figures above are Alibaba Qwen's standard official list prices (published on the HopBase pricing page and machine-readable via GET https://api.hop-base.com/api/v1/models/pricing). While Alibaba's domestic catalog includes limited-time or off-peak promotional windows, HopBase quotes and bills a predictable all-day rate derived from the standard list price. Tailored enterprise pricing is quoted per customer by our sales team via the pricing page, and your exact account rate is always visible in the signed-in console catalog.

What Changed in Qwen4 Max: 95% Context Caching Savings, 262K Thinking Output & Forced Tool Calling

  • $0.07353 / 1M implicit context caching (95% savings vs fresh input): qwen4-max uses automatic prefix caching with zero manual cache-breakpoint markup, cutting cached input reads to 0.05× the fresh input rate ($0.07353 vs $1.471 per 1M tokens—and 66.7% cheaper than qwen3.8-max's $0.2206 cache read). In production multi-turn Claude Code benchmarks, automatic prefix caching hit 89%–97% of prompt tokens from turn 2 onward. Across a 20-turn coding session holding a 200,000-token repository prefix in cache, 19 cached reads cost just 3.8M × $0.07353 ≈ $0.279 instead of $5.590 uncached, with no long-context surcharge even at 900K+ tokens.
  • Reliable forced tool_choice with reasoning enabled: On qwen3.8-max, qwen3.8-flash, and qwen3.7-plus, setting tool_choice to "required" (or "any" on /v1/messages, or a specific function name) while thinking is on is accepted syntactically, yet the model may still reply in plain text unless you pass "enable_thinking": false. qwen4-max fixes this: it reasons in reasoning_content and still honors forced tool selection reliably, making deterministic schema extraction and state-machine agents straightforward.
  • 262,144-token output ceiling & HTTP 400 parameter guards: Standard output caps at 131,072 tokens across the Qwen family, and sending max_tokens > 131072 returns HTTP 400 on every Qwen model except qwen4-max, which unlocks up to 262,144 output tokens when thinking is active. Do not send thinking_budget and reasoning_effort (low / high / max) in the same request—combining them returns HTTP 400. To turn thinking off on qwen4-max, use POST /v1/chat/completions with "enable_thinking": false (on /v1/messages, thinking: {"type": "disabled"} has no effect on qwen4-max or qwen3.8-flash).
  • Multimodal video & Responses stateless routing: Both image (sides > 10 px) and video inputs work on POST /v1/chat/completions. On POST /v1/responses, content blocks accept only input_text, input_image, and input_file—send video workloads over Chat Completions. Because HopBase load-balances across redundant capacity, the gateway strips previous_response_id and forces store: false on Responses requests; always send the full conversation history each turn.

Quickstart: curl, OpenAI Python SDK (Image + Video + Tool Calling), and Claude Code

Create or edit an API key in the HopBase console that includes the Qwen 4 / 3.8 / 3.7 Series group, verify qwen4-max appears in GET https://api.hop-base.com/v1/models, and connect with any of the three standard protocols:

1. OpenAI Chat Completions via curl (streaming with usage accounting):

curl https://api.hop-base.com/v1/chat/completions \
  -H "Authorization: Bearer $HOPBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen4-max",
    "reasoning_effort": "high",
    "max_tokens": 16384,
    "stream": true,
    "stream_options": {"include_usage": true},
    "messages": [
      {"role": "user", "content": "Compare PostgreSQL declarative partitioning vs ClickHouse MergeTree for 10B-row multi-tenant usage reconciliation."}
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

2. OpenAI Python SDK: Multimodal Image + Video Input and Forced Tool Calling in Thinking Mode:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.hop-base.com/v1",
    api_key=os.environ["HOPBASE_API_KEY"],
)

# Example A: Multimodal image + video analysis over Chat Completions
vision_resp = client.chat.completions.create(
    model="qwen4-max",
    max_tokens=4096,
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Cross-check the architecture diagram against the walkthrough clip and list every API call in order."},
            {"type": "image_url", "image_url": {"url": "https://hop-base.com/assets/blog/chinese-llm-api-one-key.jpg"}},
            {"type": "video_url", "video_url": {"url": "https://example.com/demo-walkthrough.mp4"}},
        ],
    }],
)
print(vision_resp.choices[0].message.content)

# Example B: Forced tool_choice with reasoning enabled (reliable on qwen4-max)
tools = [{
    "type": "function",
    "function": {
        "name": "query_slo_metrics",
        "description": "Fetch P99 latency and error rate for a microservice over the last hour",
        "parameters": {
            "type": "object",
            "properties": {
                "service": {"type": "string"},
                "region": {"type": "string", "enum": ["us-east", "ap-northeast", "eu-central"]},
            },
            "required": ["service", "region"],
        },
    },
}]

tool_resp = client.chat.completions.create(
    model="qwen4-max",
    reasoning_effort="high",
    tools=tools,
    tool_choice={"type": "function", "function": {"name": "query_slo_metrics"}},
    messages=[{"role": "user", "content": "Investigate checkout-api tail latency spikes in us-east."}],
)
print(tool_resp.choices[0].message.tool_calls)
Enter fullscreen mode Exit fullscreen mode

3. Direct Claude Code CLI Integration over Anthropic Messages (POST /v1/messages):

export ANTHROPIC_BASE_URL="https://api.hop-base.com"
export ANTHROPIC_AUTH_TOKEN="$HOPBASE_API_KEY"
export ANTHROPIC_MODEL="qwen4-max"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen3.8-flash"
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000
claude
Enter fullscreen mode Exit fullscreen mode

Setting CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000 tells Claude Code the true 1M context window so it does not prematurely compact conversations at 200K tokens. For complete parameter bounds, usage reconciliation fields, and Codex CLI Responses setup, see the Qwen protocol guide, the Qwen4 Max model card, and the HopBase model catalog.

FAQ

How much does the Qwen4 Max API cost compared with Qwen3.8 Max, and is there a long-context surcharge?

qwen4-max carries an official list price of $1.471 input, $0.07353 cached input, and $4.412 output per 1M tokens—16.7% lower than qwen3.8-max ($1.765 input / $5.294 output) and 66.7% lower on cached reads ($0.2206 on qwen3.8-max). Unlike qwen3.7-plus (which triples input and output rates above 262K prompt tokens), qwen4-max bills a flat single-tier rate across its entire 1,000,000-token context window.

How do I disable thinking on qwen4-max, and how are reasoning tokens billed?

Send "enable_thinking": false on POST /v1/chat/completions whenever you want non-reasoning responses; note that on POST /v1/messages, thinking: {"type": "disabled"} is ignored by qwen4-max. When thinking is active, usage.completion_tokens already includes reasoning tokens (completion_tokens_details.reasoning_tokens is reported as an informational subset) and bills once at the $4.412 / 1M output list rate.

Why did my qwen4-max request return HTTP 400 on video input or thinking parameters?

Two common checks resolve HTTP 400 errors: first, video inputs are supported on POST /v1/chat/completions, whereas POST /v1/responses accepts only input_text, input_image, and input_file. Second, thinking_budget and reasoning_effort cannot be sent in the same request—pick one parameter to control reasoning depth.

Top comments (0)