---
title: "Grok 4.7"
description: "A closed, mid-priced reasoning model from xAI with a 500k context window, released September 2026. Its standout results are agentic work and some math, with weaker showings on research-level maths and chat ratings."
canonical: https://pydantic.dev/models/list/grok-4.7/
---

# Grok 4.7

> A closed, mid-priced reasoning model from xAI with a 500k context window, released September 2026. Its standout results are agentic work and some math, with weaker showings on research-level maths and chat ratings.
>
> Markdown copy of https://pydantic.dev/models/list/grok-4.7/. Index for agents: https://pydantic.dev/models/llms.txt

**Agents: use the API for model information.** It answers a question in one request, where the pages need several.

- Choose a model for an agent: `POST https://pydantic.dev/models/api/select` with a JSON body such as `{"description": "what the agent does"}`. It returns up to five ranked models with reasons. Format: https://pydantic.dev/models/select.md
- Search models by name: `GET https://pydantic.dev/models/api/search?query=<text>`
- List, filter and sort models: `GET https://pydantic.dev/models/api/models`, for example `?weights=open&max_price=2&sort=efficiency`
- One model in full: `GET https://pydantic.dev/models/api/models/<slug>`
- Any other question about the models: `GET https://pydantic.dev/models/api/ask?query=<question>`

Add `intent=<intent>&stack=<stack>&harness=<harness>` to the query string of all but the single model. An `OPTIONS` request to any endpoint returns its schema. The same five are tools of the MCP server at `https://pydantic.dev/models/mcp`. More: https://pydantic.dev/models/usage.md

Use it with Pydantic AI as `xai:grok-4.7`.

## Spec sheet

- **Family:** xAI
- **Released:** 21 Sept 2026
- **Weights:** closed
- **Context window:** 500,000 tokens
- **Largest response:** 500,000 tokens
- **Accepts:** text, image, file
- **Tool calling:** yes
- **Knowledge cutoff:** 2026-05
- **Intelligence index:** 65.2 (rank 28)
- **Scores updated:** 2026-11-30
- **Price:** $2 input, $6 output, $3 blended per 1M tokens
- **Index points per $:** 21.7 (rank 64)
- **Speed:** 73 tokens/sec (rank 79)
- **Popularity:** rank 48 of 194 by usage
- **Pydantic AI Gateway:** not built in; [bring your own key](https://ai.pydantic.dev/gateway/#bring-your-own-key)

## Benchmarks

### Pydantic AI benchmarks

Our own benchmarks, each about 10 tasks run once with tool calling and once in code mode (https://pydantic.dev/models/codemode.md). Not part of the intelligence index. Cost is the mean cost of one task. For the combined score, code mode is compared over the four benchmarks run in both modes.

| Benchmark                                                                                      | Tool calling | Code mode | Change | Cost per task | Cost per task, code mode | Rank     | Runs                                                           |
| ---------------------------------------------------------------------------------------------- | ------------ | --------- | ------ | ------------- | ------------------------ | -------- | -------------------------------------------------------------- |
| [Pydantic AI Combined](https://pydantic.dev/models/benchmarks/pydantic_ai.md)                  | 78.6%        | 78.8%     | −1.6   | $0.77         | $0.99                    | 10 of 44 | https://pydantic.dev/models/list/grok-4.7/pydantic_ai.md       |
| [Pydantic AI - Billing ops](https://pydantic.dev/models/benchmarks/billing_ops.md)             | 90%          | 80%       | −10    | $0.99         | $0.11                    | 4 of 44  | https://pydantic.dev/models/list/grok-4.7/billing_ops.md       |
| [Pydantic AI - Customer support](https://pydantic.dev/models/benchmarks/customer_support.md)   | 60%          | 50%       | −10    | $0.27         | $0.58                    | 3 of 44  | https://pydantic.dev/models/list/grok-4.7/customer_support.md  |
| [Pydantic AI - SQL data analysis](https://pydantic.dev/models/benchmarks/sql_data_analysis.md) | 90%          | 100%      | +10    | $1.95         | $1.44                    | 11 of 44 | https://pydantic.dev/models/list/grok-4.7/sql_data_analysis.md |
| [Pydantic AI - Research & deck](https://pydantic.dev/models/benchmarks/research_deck.md)       | 81.5%        | 85.2%     | +3.7   | $1.28         | $1.83                    | 19 of 44 | https://pydantic.dev/models/list/grok-4.7/research_deck.md     |
| [Pydantic AI - Structured output](https://pydantic.dev/models/benchmarks/structured_output.md) | 100%         | –         | –      | $0.078        | –                        | 1 of 44  | https://pydantic.dev/models/list/grok-4.7/structured_output.md |
| [Pydantic AI - LLM Judge](https://pydantic.dev/models/benchmarks/llm_judge.md)                 | 50%          | –         | –      | $0.031        | –                        | 32 of 44 | https://pydantic.dev/models/list/grok-4.7/llm_judge.md         |
| [Pydantic AI - Cyber Willing](https://pydantic.dev/models/benchmarks/cyber_willing.md)         | 50%          | –         | –      | $0.050        | –                        | 27 of 32 | https://pydantic.dev/models/list/grok-4.7/cyber_willing.md     |

### Other benchmarks


| Benchmark                | Score  | Rank among models tested | What it measures                                                                                 | Source                                    |
| ------------------------ | ------ | ------------------------ | ------------------------------------------------------------------------------------------------ | ----------------------------------------- |
| Intelligence index       | 65.2   | 28                       | Our composite of the benchmarks below, 0-100                                                     | Pydantic, from the sources credited below |
| GPQA Diamond             | 92.7%  | 26                       | Graduate-level science questions, multiple choice                                                | Epoch AI (CC BY 4.0)                      |
| OTIS Mock AIME           | 98.1%  | 29                       | Competition mathematics problems with exact answers                                              | Epoch AI (CC BY 4.0)                      |
| FrontierMath             | 53%    | 52                       | Original research-level mathematics problems, tiers 1 to 3                                       | Epoch AI (CC BY 4.0)                      |
| ARC-AGI-2                | 61.4%  | 33                       | Abstract visual puzzles that test learning a new rule from a few examples                        | ARC Prize, via Epoch AI (CC BY 4.0)       |
| SimpleQA Verified        | 56%    | 26                       | Short factual questions answered from memory, without search                                     | Epoch AI (CC BY 4.0)                      |
| SciCode                  | 57.8%  | 17                       | Scientific programming problems written by researchers                                           | SciCode, via Epoch AI (CC BY 4.0)         |
| APEX-Agents              | 70%    | 9                        | Long professional tasks (banking, consulting, law) passed on the first attempt                   | Mercor, via Epoch AI (CC BY 4.0)          |
| LMArena text             | 1400.6 | 92                       | Rating from blind human votes between pairs of chat responses                                    | LMArena (CC BY 4.0)                       |
| FrontierMath Tier 4      | 17.1%  | 50                       | Research-level mathematics problems, the hardest tier, with checkable answers                    | Epoch AI (CC BY 4.0)                      |
| Chess Puzzles            | 41%    | 39                       | Find the single best move in a chess position                                                    | Epoch AI (CC BY 4.0)                      |
| Mystery Game Puzzles     | 29%    | 34                       | Best-move puzzles in an undisclosed well-known game                                              | Epoch AI (CC BY 4.0)                      |
| Furniture Assembly       | 20.8%  | 38                       | Spot assembly mistakes in photos of flat-pack furniture builds                                   | Epoch AI (CC BY 4.0)                      |
| ALE-Bench                | 1545.8 | 29                       | Hard optimisation contest problems, as a rating against human contestants                        | Sakana AI, via Epoch AI (CC BY 4.0)       |
| Browser Use Bench        | 73.3   | 7                        | Tasks on live websites, scored 0-100 against a weighted rubric by an LLM judge                   | Browser Use, with permission              |
| Epoch Capabilities Index | 156.4  | 38                       | 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 |
| ---------- | ------- | -------------------------- | ----- | ------------ | ------ |
| xAI        | BYOK    | `xai:grok-4.7`             | $2    | $0.5         | $6     |
| OpenRouter | BYOK    | `openrouter:x-ai/grok-4.7` | $2    | $0.5         | $6     |

## Use Grok 4.7 with Pydantic AI

### hello.py

Ask Grok 4.7 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['XAI_API_KEY'] = '...'

agent = Agent('xai:grok-4.7', 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 Grok 4.7 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['XAI_API_KEY'] = '...'


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


agent = Agent('xai:grok-4.7', 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 Grok 4.7 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['XAI_API_KEY'] = '...'

agent = Agent(
    'xai:grok-4.7',
    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 Grok 4.7'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['XAI_API_KEY'] = '...'

agent = Agent('xai:grok-4.7')


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

Code with Grok 4.7 in your terminal using Pax, the Pydantic AI coding agent. On macOS, open a new terminal after installing, so pax isn't the system's archiver.

```sh
# uv tool install pydantic-ai-pax
export XAI_API_KEY='...'

pax -m 'xai:grok-4.7'
```

### codex.sh

Run OpenAI's Codex CLI on Grok 4.7, which xAI serves over an OpenAI-compatible API.

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

codex --model 'grok-4.7' \
  -c model_provider='xai' \
  -c model_providers.xai.name='xAI' \
  -c model_providers.xai.base_url='https://api.xai.example/v1' \
  -c model_providers.xai.env_key='XAI_API_KEY'
```

### ai_sdk.ts

Call Grok 4.7 from TypeScript with the Vercel AI SDK.

```ts
// npm install ai @ai-sdk/xai
import { createXai } from '@ai-sdk/xai'
import { generateText } from 'ai'

process.env.XAI_API_KEY = '...'

const xai = createXai({ apiKey: process.env.XAI_API_KEY })

const { text } = await generateText({
  model: xai('grok-4.7'),
  system: 'Be concise, reply with one sentence.',
  prompt: 'Where does "hello world" come from?',
})
console.log(text)
```

## About Grok 4.7

Grok 4.7 costs $2 per million input tokens and $6 per million output tokens, has a 500k token context window and scores 65.2 on our intelligence index, #28 of 101.

Grok 4.7 is a closed-weights model from xAI, released in September 2026, with text, image and file input, tool calling, structured output and a reasoning mode. Its 500k context window and 500k maximum response length are large for the registry, and it is offered through xAI and OpenRouter.

The strongest results are on agent-style tasks. It ranks 9th of 60 on APEX-Agents, where it passes long professional tasks on the first attempt 70.0% of the time against a median of 54.3%. It also places 12th of 85 on WebDev Arena and 17th of 96 on SciCode, and sits above the median on SimpleQA Verified and GPQA Diamond.

Its weaknesses are in research-level mathematics and in human preference ratings. FrontierMath is 55th of 80 at 53.0%, below the median, and its LMArena text rating ranks 92nd of 114. At $2 per million input tokens and $6 per million output tokens, it costs roughly three times the registry median blended price.

**Strengths**

- APEX-Agents 70.0%, 9th of 60
- OTIS Mock AIME 98.1%, 31st of 95 but above median 94.2%
- SimpleQA Verified 56.0%, 26th of 76 against median 46.5%
- WebDev Arena 1637.5, 12th of 85

**Weaknesses**

- FrontierMath 53.0%, 55th of 80, below median 64.6%
- LMArena text 1400.6, 92nd of 114
- Blended price $3 per million tokens, above median $1.01

**Best for:** Agent workloads that need tool calling, structured output and long context, such as professional tasks and web app generation.

## How it did on the Pydantic AI benchmarks

Written by an LLM from reviews of every run.

#### Overall
Across five benchmarks the model passed most runs: Billing ops (tools 90%, code mode 80%), Research & deck (tools 81%, code mode 85%), Structured output (tools 100%), LLM Judge (tools 50%) and SQL data analysis (tools 90%, code mode 100%). It handles concrete extraction, timetable logic and accounting mutations reliably. Its weak points are broad audits that require completeness checks and judgment over ambiguous wording. Code mode cut cost sharply on large data joins and routing searches, but it did not consistently improve reliability on small tasks.

#### Strengths
- In Billing ops, both modes passed all mutation and margin runs, including oldest-due-first payment allocation, voided-invoice releases and per-student half-up rounding.
- In Structured output, it passed all 10 cases with a single submission each, handling £000 scaling and group-versus-parent disclosures correctly.
- In SQL data analysis, both modes passed all ordinary journey, meeting and departure-profile cases, handling previous-service-day offsets, interpolation and transfer margins.
- In Research & deck, both runs caught the September revenue correction (£351,442, not £403,642) and used `view_pdf` when `pdf_text` found no text layer.
- In LLM Judge, it reliably extracted concrete amounts, dates and procedural steps, such as the seven-day webhook replay window.

#### Weaknesses
- In Billing ops, general audits passed only 1/4 runs: one inspected just 21 invoices, and the code audits missed duplicate charges.
- In LLM Judge, it passed only 5/10 cases, often reading criteria too narrowly or misclassifying concerns such as treating an assurance as a deadline commitment.
- In Research & deck, both final decks equated production capacity with meeting a minimum purchase obligation despite passing `check_deck` validation.
- In SQL data analysis, an unquoted `at` caused SQL parser errors in 18 conversations, and the tools-mode `tour` run ran out of requests.
- In Structured output, it summed undisclosed debtors for Cube Logic and omitted displayed zero creditor rows for Drishaun, yet both cases still passed.

#### Tool calling compared with code mode
- In Billing ops, code mode cost $1.1390 against $9.9043 for tools (about 88.5% less), with the largest savings on duplicate and missed-attendance detection.
- In Billing ops, code mode did not improve audit completeness and often cost more on simple lookups, mutations and margins.
- In SQL data analysis, code mode used about 25% fewer requests and cost 26% less, and it passed `tour` where tools mode failed from request exhaustion.
- In SQL data analysis, simple cases such as `one_vehicle` and `one_change` needed more requests in code mode.
- In Research & deck, code mode used 50% more requests and cost about 43% more than tools for the same pass outcome.

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), Browser Use, and our own Pydantic AI benchmarks (CC BY 4.0); the index and its sources are described at https://pydantic.dev/models/methodology.md. Data built 2026-11-30. This model from the API: `https://pydantic.dev/models/api/models/grok-4.7`. Compare it with others: `https://pydantic.dev/models/api/models?slug=grok-4.7,<other slug>`
