# Qwen3.7 Max

> Alibaba's closed, large-context reasoning model with tool calling. Its standout result is software repair on SWE-bench Verified, near the top of the tested models.

Use it with Pydantic AI as `openrouter:qwen/qwen3.7-max`.

## Spec sheet

- **Family:** Qwen
- **Released:** 21 May 2026
- **Weights:** closed
- **Context window:** 1,000,000 tokens
- **Largest response:** 131,072 tokens
- **Accepts:** text
- **Tool calling:** yes
- **Knowledge cutoff:** unknown
- **Intelligence index:** 65.9 (rank 36)
- **Price:** $1.48 input, $4.42 output, $2.21 blended per 1M tokens
- **Index points per $:** 29.8 (rank 66)
- **Speed:** 72 tokens/sec (rank 82)
- **Popularity:** rank 141 of 194 by usage
- **Pydantic AI Gateway:** not built in; [bring your own key](https://ai.pydantic.dev/gateway/#bring-your-own-key)

## Benchmarks

| Benchmark | Score | Rank among models tested | What it measures | Source |
| --- | --- | --- | --- | --- |
| Intelligence index | 65.9 | 37 | Our composite of the benchmarks below, 0-100 | Pydantic, from the sources credited below |
| GPQA Diamond | 90.9% | 35 | Graduate-level science questions, multiple choice | Epoch AI (CC BY 4.0) |
| OTIS Mock AIME | 95.6% | 40 | Competition mathematics problems with exact answers | Epoch AI (CC BY 4.0) |
| FrontierMath | 64.6% | 41 | Original research-level mathematics problems, tiers 1 to 3 | Epoch AI (CC BY 4.0) |
| SimpleQA Verified | 55.8% | 27 | Short factual questions answered from memory, without search | Epoch AI (CC BY 4.0) |
| SWE-bench Verified | 77.3% | 6 | Real GitHub issues resolved, run by Epoch with one fixed scaffold | Epoch AI (CC BY 4.0) |
| SciCode | 49.5% | 54 | Scientific programming problems written by researchers | SciCode, via Epoch AI (CC BY 4.0) |
| WebDev Arena | 1517.1 | 39 | Rating from human votes on web apps the models built | LMArena, via Epoch AI (CC BY 4.0) |
| Epoch Capabilities Index | 154.6 | 48 | Epoch AI's own composite across about 40 benchmarks; shown for comparison, not part of our index | Epoch AI (CC BY 4.0) |

## Providers and prices

US dollars per million tokens.

| Provider | Gateway | Pydantic AI string | Input | Cached input | Output |
| --- | --- | --- | --- | --- | --- |
| Novita | BYOK | – | $1.25 | $0.25 | $3.75 |
| OpenRouter | BYOK | `openrouter:qwen/qwen3.7-max` | $1.48 | $0.29 | $4.42 |
| Together AI | BYOK | `together:Qwen/Qwen3.7-Max` | $2.5 | $0.5 | $7.5 |

## Example code

### hello.py

Ask Qwen3.7 Max a question with a Pydantic AI agent and print the answer. Run it with uv run hello.py.

```python
# /// script
# dependencies = ["pydantic-ai"]
# ///
import os

from pydantic_ai import Agent

os.environ['OPENROUTER_API_KEY'] = '...'

agent = Agent('openrouter:qwen/qwen3.7-max', instructions='Be concise, reply with one sentence.')

result = agent.run_sync('Where does "hello world" come from?')
print(result.output)
```

### structured_output.py

Get validated, typed output from Qwen3.7 Max by giving the agent a Pydantic model. Run it with uv run structured_output.py.

```python
# /// script
# dependencies = ["pydantic-ai"]
# ///
import os

from pydantic import BaseModel
from pydantic_ai import Agent

os.environ['OPENROUTER_API_KEY'] = '...'


class CityLocation(BaseModel):
    city: str
    country: str


agent = Agent('openrouter:qwen/qwen3.7-max', output_type=CityLocation)

result = agent.run_sync('Where were the olympics held in 2012?')
print(result.output)
#> city='London' country='United Kingdom'
```

### tools.py

Give Qwen3.7 Max two tools to call, one of which reads the agent's dependencies. Run it with uv run tools.py.

```python
# /// script
# dependencies = ["pydantic-ai"]
# ///
import os
import random

from pydantic_ai import Agent, RunContext

os.environ['OPENROUTER_API_KEY'] = '...'

agent = Agent(
    'openrouter:qwen/qwen3.7-max',
    deps_type=str,
    instructions="You're a dice game, roll the die and see if it matches the user's guess.",
)


@agent.tool_plain
def roll_dice() -> str:
    """Roll a six-sided die and return the result."""
    return str(random.randint(1, 6))


@agent.tool
def get_player_name(ctx: RunContext[str]) -> str:
    """Get the player's name."""
    return ctx.deps


result = agent.run_sync('My guess is 4', deps='Anne')
print(result.output)
```

### streaming.py

Stream Qwen3.7 Max's reply to the terminal as it is generated. Run it with uv run streaming.py.

```python
# /// script
# dependencies = ["pydantic-ai"]
# ///
import asyncio
import os

from pydantic_ai import Agent

os.environ['OPENROUTER_API_KEY'] = '...'

agent = Agent('openrouter:qwen/qwen3.7-max')


async def main():
    async with agent.run_stream('Explain prompt caching in three bullet points.') as response:
        async for text in response.stream_text(delta=True):
            print(text, end='', flush=True)


asyncio.run(main())
```

### pax.sh

Chat with Qwen3.7 Max in your terminal using pax, the TUI for pydantic-ai-harness. Coming soon.

```sh
export OPENROUTER_API_KEY='...'

uvx pax --model 'openrouter:qwen/qwen3.7-max'
```

### pi.sh

Use Qwen3.7 Max as the model behind the pi coding agent, with your own Novita key.

```sh
# npm install -g @earendil-works/pi-coding-agent
export OPENROUTER_API_KEY='...'

pi --model 'openrouter/qwen/qwen3.7-max'
```

### codex.sh

Run OpenAI's Codex CLI on Qwen3.7 Max, which Novita serves over an OpenAI-compatible API.

```sh
# npm install -g @openai/codex
export OPENROUTER_API_KEY='...'

codex --model 'qwen/qwen3.7-max' \
  -c model_provider='openrouter' \
  -c model_providers.openrouter.name='Novita' \
  -c model_providers.openrouter.base_url='https://api.openrouter.example/v1' \
  -c model_providers.openrouter.env_key='OPENROUTER_API_KEY'
```

### ai_sdk.ts

Call Qwen3.7 Max from TypeScript with the Vercel AI SDK.

```ts
// npm install ai @ai-sdk/openai-compatible
import { createOpenAICompatible } from '@ai-sdk/openai-compatible'
import { generateText } from 'ai'

process.env.OPENROUTER_API_KEY = '...'

const openrouter = createOpenAICompatible({
  name: 'openrouter',
  baseURL: 'https://api.openrouter.example/v1',
  apiKey: process.env.OPENROUTER_API_KEY,
})

const { text } = await generateText({
  model: openrouter('qwen/qwen3.7-max'),
  system: 'Be concise, reply with one sentence.',
  prompt: 'Where does "hello world" come from?',
})
console.log(text)
```

## About Qwen3.7 Max

Qwen3.7 Max is a closed-weight model from Alibaba, released May 2026, and it accepts text input only. It offers a 1M token context window, responses up to 131k tokens, reasoning mode, tool calling and structured output. It is available through Novita, OpenRouter and Together AI.

Its overall intelligence index of 65.9 sits above the registry median of 59.5, and its SWE-bench Verified score of 77.3% ranks sixth of 23 tested. Results elsewhere are mostly close to the median: GPQA Diamond at 90.9%, OTIS Mock AIME at 95.6% and FrontierMath at 64.6% are all within about a point or two of it, while SciCode at 49.5% is slightly below. Its blended price of $2.21 per million tokens is well above the median of $1.01, so cost is the main trade-off.

**Strengths**

- SWE-bench Verified 77.3%, 6th of 23 tested
- Intelligence index 65.9, 37th of 114 and above the median
- SimpleQA Verified 55.8%, 27th of 76, well above the median
- 1M token context window with responses up to 131k tokens

**Weaknesses**

- Blended price of $2.21 per million tokens, above the registry median
- SciCode 49.5%, 54th of 96, slightly below the median
- Accepts text input only

**Best for:** Coding agents and long-document tasks that need a 1M context window and tool calling.

Prices come from [genai-prices](https://github.com/pydantic/genai-prices), in US dollars per million tokens. Benchmark scores come from Epoch AI and LMArena (CC BY 4.0); the index and its sources are described at https://models.pydantic.dev/methodology.md. Data built 2026-11-25. Compare with other models: https://models.pydantic.dev/models.md
