# Qwen4 Max API

Qwen's flagship for coding, multimodal understanding, and long-context reasoning.

Canonical page: https://routerhub.si/models/qwen4-max

- ID: `qwen4-max`
- Details and setup: https://routerhub.si/models/qwen4-max
- Provider: Qwen
- Variant: Standard
- Protocols: chat (OpenAI-compatible Chat Completions API, https://routerhub.si/v1/chat/completions)
- Availability: preview
- Input per million tokens: $0.4
- Output per million tokens: $1.2
- Cached input per million tokens (cache hit): $0.02
- Cache write per million tokens: $0.5
- Context limit: 1,000,000 tokens
- Maximum output: 131,072 tokens
- Compatible tools: OpenCode, VS Code + Continue, VS Code + Cline, Hermes Agent, cURL / Python

## RouterHub vs Qwen API pricing

USD per 1 million tokens.

| Token type | RouterHub | Official API |
| --- | ---: | ---: |
| Input | $0.4 | $1.5 |
| Output | $1.2 | $4.5 |
| Cached input | $0.02 | $0.075 |
| Cache write | $0.5 | $1.875 |

RouterHub costs 73% less at 1,000 input and 500 output tokens, before caching.

[Official pricing source](https://docs.qwencloud.com/developer-guides/run-and-scale/explicit-cache-qwen4#billing) · Checked 2026-11-19 · QwenCloud Singapore retail; 5-minute cache-write tier.


## cURL

```bash
curl --connect-timeout 30 --max-time 600 https://routerhub.si/v1/chat/completions \
  -H "Authorization: Bearer $ROUTERHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"qwen4-max","messages":[{"role":"user","content":"Write a short noir scene set in a lighthouse."}],"max_tokens":256}'
```

## Python

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["ROUTERHUB_API_KEY"],
    base_url="https://routerhub.si/v1",
    timeout=600.0,
    max_retries=0,
)
response = client.chat.completions.create(
    model="qwen4-max",
    messages=[{"role": "user", "content": "Write a short noir scene set in a lighthouse."}],
    max_tokens=256,
)
print(response.choices[0].message.content)
```

## Setup guides

- OpenCode: https://routerhub.si/guides/opencode
- VS Code + Continue: https://routerhub.si/guides/vscode-continue
- VS Code + Cline: https://routerhub.si/guides/vscode-cline
- Hermes Agent: https://routerhub.si/docs/tools/hermes-agent
- cURL / Python: https://routerhub.si/docs/tools/api-request
