# Kimi K2 0711

> Open-weight text model from Moonshot AI with tool calling and a long context window. Its only benchmark result, on Terminal-Bench, sits well below the registry median.

Use it with Pydantic AI as `gateway/groq:moonshotai/kimi-k2-instruct`.

## Spec sheet

- **Family:** Moonshot AI
- **Released:** 11 Jul 2025
- **Weights:** open
- **Context window:** 131,072 tokens
- **Largest response:** 98,304 tokens
- **Accepts:** text
- **Tool calling:** yes
- **Knowledge cutoff:** 2024-12
- **Intelligence index:** not enough benchmark results yet
- **Price:** $1 input, $3 output, $1.5 blended per 1M tokens
- **Index points per $:** – (rank –)
- **Speed:** 32 tokens/sec (rank 165)
- **Popularity:** rank 101 of 194 by usage
- **Pydantic AI Gateway:** built in

## Benchmarks

| Benchmark | Score | Rank among models tested | What it measures | Source |
| --- | --- | --- | --- | --- |
| Terminal-Bench | 27.8% | 27 | Tasks completed in a terminal; the best result of any agent using the model | Terminal-Bench, via Epoch AI (CC BY 4.0) |

## Providers and prices

US dollars per million tokens.

| Provider | Gateway | Pydantic AI string | Input | Cached input | Output |
| --- | --- | --- | --- | --- | --- |
| Groq | built in | `gateway/groq:moonshotai/kimi-k2-instruct` | $1 | $0.5 | $3 |
| Novita | BYOK | – | $0.57 | – | $2.3 |
| OpenRouter | BYOK | `openrouter:moonshotai/kimi-k2` | $0.57 | – | $2.3 |

## Example code

### hello.py

Ask Kimi K2 0711 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['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'

agent = Agent('gateway/groq:moonshotai/kimi-k2-instruct', 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 Kimi K2 0711 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['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'


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


agent = Agent('gateway/groq:moonshotai/kimi-k2-instruct', 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 Kimi K2 0711 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['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'

agent = Agent(
    'gateway/groq:moonshotai/kimi-k2-instruct',
    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 Kimi K2 0711'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['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'

agent = Agent('gateway/groq:moonshotai/kimi-k2-instruct')


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 Kimi K2 0711 in your terminal using pax, the TUI for pydantic-ai-harness. Coming soon.

```sh
export PYDANTIC_AI_GATEWAY_API_KEY='...'

uvx pax --model 'gateway/groq:moonshotai/kimi-k2-instruct'
```

### pi.sh

Use Kimi K2 0711 as the model behind the pi coding agent, with Pydantic AI Gateway registered as a custom provider in ~/.pi/agent/models.json.

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

# pi has no built-in Gateway provider, so register one.
# Merge this by hand if you already have a models.json.
mkdir -p ~/.pi/agent
cat > ~/.pi/agent/models.json <<'EOF'
{
  "providers": {
    "pydantic-ai-gateway": {
      "baseUrl": "https://gateway.pydantic.dev/proxy/groq/v1",
      "api": "openai-completions",
      "apiKey": "$PYDANTIC_AI_GATEWAY_API_KEY",
      "models": [
        {
          "id": "moonshotai/kimi-k2-instruct"
        }
      ]
    }
  }
}
EOF

pi --provider pydantic-ai-gateway --model 'moonshotai/kimi-k2-instruct'
```

### codex.sh

Run OpenAI's Codex CLI on Kimi K2 0711 through Pydantic AI Gateway.

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

codex --model 'moonshotai/kimi-k2-instruct' \
  -c model_provider='gateway' \
  -c model_providers.gateway.name='Pydantic AI Gateway' \
  -c model_providers.gateway.base_url='https://gateway.pydantic.dev/proxy/groq/v1' \
  -c model_providers.gateway.env_key='PYDANTIC_AI_GATEWAY_API_KEY'
```

### ai_sdk.ts

Call Kimi K2 0711 from TypeScript with the Vercel AI SDK, through Pydantic AI Gateway.

```ts
// npm install ai @ai-sdk/groq
import { createGroq } from '@ai-sdk/groq'
import { generateText } from 'ai'

process.env.PYDANTIC_AI_GATEWAY_API_KEY = '...'

const groq = createGroq({
  baseURL: 'https://gateway.pydantic.dev/proxy/groq',
  apiKey: process.env.PYDANTIC_AI_GATEWAY_API_KEY,
})

const { text } = await generateText({
  model: groq('moonshotai/kimi-k2-instruct'),
  system: 'Be concise, reply with one sentence.',
  prompt: 'Where does "hello world" come from?',
})
console.log(text)
```

## About Kimi K2 0711

Kimi K2 0711 is an open-weight text model from Moonshot AI, with a 131k context window and up to 98k tokens per response. It supports tool calling, which is the main reason an agent builder might consider it. It is offered by Groq, Novita and OpenRouter and is built into the Gateway.

Pricing is $1 per million input tokens and $3 per million output tokens, a blended $1.50 that sits just above the registry median. The knowledge cutoff is December 2024. The model has no reasoning mode and no structured output option.

The only benchmark result is Terminal-Bench, where it completes 27.8% of tasks, 27th of 35 and well below the median of 43.2%. With so little benchmark coverage, this single score is the main evidence on agentic performance, and it suggests weaker results than the median model on that task.

**Strengths**

- Open weights, with tool calling supported
- 131k context window and 98k maximum response length
- Available from Groq, Novita and OpenRouter, and built into the Gateway
- Blended price of $1.50 per million tokens, just above the registry median

**Weaknesses**

- Terminal-Bench 27.8%, 27th of 35, well below the 43.2% median
- No reasoning mode or structured output; accepts text input only
- No intelligence-per-dollar figure is available for ranking value

**Best for:** Tool-calling agents on text tasks where open weights and a mid-range price matter more than terminal task performance.

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
