---
title: "DeepSeek V4.1 Flash"
description: "Open-weights model from DeepSeek, priced far below the registry median, with a million-token context and strong math and abstract reasoning results. Weak on long professional agent tasks."
canonical: https://pydantic.dev/models/list/deepseek-v4.1-flash/
---

# DeepSeek V4.1 Flash

> Open-weights model from DeepSeek, priced far below the registry median, with a million-token context and strong math and abstract reasoning results. Weak on long professional agent tasks.
>
> Markdown copy of https://pydantic.dev/models/list/deepseek-v4.1-flash/. 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 `gateway/doubleword:deepseek-ai/DeepSeek-V4.1-Flash`.

## Spec sheet

- **Family:** DeepSeek
- **Released:** 10 Sept 2026
- **Weights:** open
- **Context window:** 1,048,576 tokens
- **Largest response:** 393,216 tokens
- **Accepts:** text, image
- **Tool calling:** yes
- **Knowledge cutoff:** 2025-05
- **Intelligence index:** 59.7 (rank 46)
- **Scores updated:** 2026-11-30
- **Price:** $0.15 input, $0.6 output, $0.26 blended per 1M tokens
- **Index points per $:** 227.4 (rank 11)
- **Speed:** 123.5 tokens/sec (rank 26)
- **Popularity:** rank 1 of 194 by usage
- **Pydantic AI Gateway:** built in

## 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)                  | 62.7%        | 50.3%     | −3.8   | $0.022        | $0.032                   | 28 of 44 | https://pydantic.dev/models/list/deepseek-v4.1-flash/pydantic_ai.md       |
| [Pydantic AI - Billing ops](https://pydantic.dev/models/benchmarks/billing_ops.md)             | 70%          | 40%       | −30    | $0.027        | $0.0031                  | 21 of 44 | https://pydantic.dev/models/list/deepseek-v4.1-flash/billing_ops.md       |
| [Pydantic AI - Customer support](https://pydantic.dev/models/benchmarks/customer_support.md)   | 50%          | 30%       | −20    | $0.010        | $0.0081                  | 12 of 44 | https://pydantic.dev/models/list/deepseek-v4.1-flash/customer_support.md  |
| [Pydantic AI - SQL data analysis](https://pydantic.dev/models/benchmarks/sql_data_analysis.md) | 20%          | 60%       | +40    | $0.027        | $0.044                   | 30 of 44 | https://pydantic.dev/models/list/deepseek-v4.1-flash/sql_data_analysis.md |
| [Pydantic AI - Research & deck](https://pydantic.dev/models/benchmarks/research_deck.md)       | 76.3%        | 71.1%     | −5.2   | $0.059        | $0.073                   | 25 of 44 | https://pydantic.dev/models/list/deepseek-v4.1-flash/research_deck.md     |
| [Pydantic AI - Structured output](https://pydantic.dev/models/benchmarks/structured_output.md) | 90%          | –         | –      | $0.0066       | –                        | 15 of 44 | https://pydantic.dev/models/list/deepseek-v4.1-flash/structured_output.md |
| [Pydantic AI - LLM Judge](https://pydantic.dev/models/benchmarks/llm_judge.md)                 | 70%          | –         | –      | $0.0019       | –                        | 18 of 44 | https://pydantic.dev/models/list/deepseek-v4.1-flash/llm_judge.md         |
| [Pydantic AI - Cyber Willing](https://pydantic.dev/models/benchmarks/cyber_willing.md)         | 86.1%        | –         | –      | $0.0091       | –                        | 16 of 32 | https://pydantic.dev/models/list/deepseek-v4.1-flash/cyber_willing.md     |

### Other benchmarks


| Benchmark                | Score  | Rank among models tested | What it measures                                                                                 | Source                                    |
| ------------------------ | ------ | ------------------------ | ------------------------------------------------------------------------------------------------ | ----------------------------------------- |
| Intelligence index       | 59.7   | 46                       | Our composite of the benchmarks below, 0-100                                                     | Pydantic, from the sources credited below |
| GPQA Diamond             | 89.8%  | 45                       | Graduate-level science questions, multiple choice                                                | Epoch AI (CC BY 4.0)                      |
| OTIS Mock AIME           | 98.3%  | 25                       | Competition mathematics problems with exact answers                                              | Epoch AI (CC BY 4.0)                      |
| FrontierMath             | 67.4%  | 35                       | Original research-level mathematics problems, tiers 1 to 3                                       | Epoch AI (CC BY 4.0)                      |
| ARC-AGI-2                | 72.9%  | 26                       | Abstract visual puzzles that test learning a new rule from a few examples                        | ARC Prize, via Epoch AI (CC BY 4.0)       |
| SimpleQA Verified        | 42.9%  | 44                       | Short factual questions answered from memory, without search                                     | Epoch AI (CC BY 4.0)                      |
| SciCode                  | 51.9%  | 43                       | Scientific programming problems written by researchers                                           | SciCode, via Epoch AI (CC BY 4.0)         |
| APEX-Agents              | 39.5%  | 47                       | Long professional tasks (banking, consulting, law) passed on the first attempt                   | Mercor, via Epoch AI (CC BY 4.0)          |
| LMArena text             | 1462.8 | 31                       | Rating from blind human votes between pairs of chat responses                                    | LMArena (CC BY 4.0)                       |
| FrontierMath Tier 4      | 26.8%  | 39                       | Research-level mathematics problems, the hardest tier, with checkable answers                    | Epoch AI (CC BY 4.0)                      |
| Chess Puzzles            | 48%    | 23                       | Find the single best move in a chess position                                                    | Epoch AI (CC BY 4.0)                      |
| Mystery Game Puzzles     | 43%    | 19                       | Best-move puzzles in an undisclosed well-known game                                              | Epoch AI (CC BY 4.0)                      |
| Furniture Assembly       | 34.2%  | 27                       | Spot assembly mistakes in photos of flat-pack furniture builds                                   | Epoch AI (CC BY 4.0)                      |
| SimpleBench              | 66.7%  | 29                       | Six-option trick questions that test common sense                                                | SimpleBench, via Epoch AI (CC BY 4.0)     |
| ALE-Bench                | 1092.3 | 51                       | Hard optimisation contest problems, as a rating against human contestants                        | Sakana AI, via Epoch AI (CC BY 4.0)       |
| Browser Use Bench        | 70.9   | 10                       | Tasks on live websites, scored 0-100 against a weighted rubric by an LLM judge                   | Browser Use, with permission              |
| Epoch Capabilities Index | 157    | 34                       | 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 |
| ----------- | -------- | ---------------------------------------------------- | ----- | ------------ | ------ |
| Doubleword  | built in | `gateway/doubleword:deepseek-ai/DeepSeek-V4.1-Flash` | $0.15 | $0.01        | $0.6   |
| OpenRouter  | BYOK     | `openrouter:deepseek/deepseek-v4.1-flash`            | $0.21 | $0.004       | $0.84  |
| Baseten     | BYOK     | –                                                    | $0.3  | $0.007       | $1.2   |
| Novita      | BYOK     | –                                                    | $0.3  | $0.006       | $1.2   |
| Together AI | BYOK     | `together:deepseek-ai/DeepSeek-V4.1-Flash`           | $0.3  | $0.006       | $1.2   |

## Use DeepSeek V4.1 Flash with Pydantic AI

### hello.py

Ask DeepSeek V4.1 Flash 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/doubleword:deepseek-ai/DeepSeek-V4.1-Flash', 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 DeepSeek V4.1 Flash 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/doubleword:deepseek-ai/DeepSeek-V4.1-Flash', 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 DeepSeek V4.1 Flash 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/doubleword:deepseek-ai/DeepSeek-V4.1-Flash',
    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 DeepSeek V4.1 Flash'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/doubleword:deepseek-ai/DeepSeek-V4.1-Flash')


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 DeepSeek V4.1 Flash 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 PYDANTIC_AI_GATEWAY_API_KEY='...'

pax -m 'gateway/doubleword:deepseek-ai/DeepSeek-V4.1-Flash'
```

### codex.sh

Run OpenAI's Codex CLI on DeepSeek V4.1 Flash through Pydantic AI Gateway.

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

codex --model 'deepseek-ai/DeepSeek-V4.1-Flash' \
  -c model_provider='gateway' \
  -c model_providers.gateway.name='Pydantic AI Gateway' \
  -c model_providers.gateway.base_url='https://gateway.pydantic.dev/proxy/doubleword/v1' \
  -c model_providers.gateway.env_key='PYDANTIC_AI_GATEWAY_API_KEY'
```

### ai_sdk.ts

Call DeepSeek V4.1 Flash from TypeScript with the Vercel AI SDK, through Pydantic AI Gateway.

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

process.env.PYDANTIC_AI_GATEWAY_API_KEY = '...'

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

const { text } = await generateText({
  model: doubleword('deepseek-ai/DeepSeek-V4.1-Flash'),
  system: 'Be concise, reply with one sentence.',
  prompt: 'Where does "hello world" come from?',
})
console.log(text)
```

## About DeepSeek V4.1 Flash

DeepSeek V4.1 Flash costs $0.15 per million input tokens and $0.6 per million output tokens, has a 1M token context window and scores 59.7 on our intelligence index, #46 of 101.

DeepSeek V4.1 Flash is an open-weights model released in September 2026 that accepts text and image input. It has a context window of 1M tokens, can return up to 393k tokens in one response, and supports tool calling, reasoning mode and structured output. Its price is the main draw: $0.15 per million input tokens and $0.60 per million output tokens, a blended rate of $0.26 against a registry median of $1.01.

On benchmarks it is mostly above the registry median. It scores 98.3% on OTIS Mock AIME, 27th of 95, and 72.9% on ARC-AGI-2, 25th of 68. Its overall intelligence index of 62.8 places it 46th of 114, a little above median. It lags on APEX-Agents at 39.5%, 49th of 60, and on SimpleQA Verified at 42.9%, below the median of 46.5%.

**Strengths**

- Blended price of $0.26 per million tokens, against a $1.01 median
- 98.3% on OTIS Mock AIME, 27th of 95
- 72.9% on ARC-AGI-2, 25th of 68
- Intelligence per dollar ranks 11th of 194

**Weaknesses**

- 39.5% on APEX-Agents, 49th of 60, well below the 54.3% median
- 42.9% on SimpleQA Verified, 45th of 76, below the median
- Intelligence index of 62.8 ranks 46th of 114, only slightly above median

**Best for:** Budget-conscious agents for math, reasoning and image-aware tasks; less suited to long professional workflows.

## How it did on the Pydantic AI benchmarks

Written by an LLM from reviews of every run.

#### Overall
The model is inexpensive and applies written rules well, with strong one-shot extraction on Structured output (90%) and solid tool-calling results on Billing ops (70%) and Research & deck (76%). Its dominant failure is calling `final_result` before the work is done, often with placeholder or invented values, while its own reasoning says it is about to fetch more data. This fault hit 13 of 20 SQL data analysis runs and 5 Billing ops code-mode runs. It also leans toward yes on borderline judgements and sometimes stops early on large audits.

#### Strengths
- On Structured output it scaled all three £000 cases correctly, kept group and parent figures separate in six cases, and signed deficits, liabilities and tax credits correctly, with no wrong monetary figure in any checked field.
- On Billing ops with tool calling it passed both write cases, allocating payments oldest-first after netting an existing allocation and running void-and-reissue in the right order.
- On Research & deck both runs read the full data room, reconciled revenue against units × price, and caught the restated September revenue and the Northline cancellation.
- On LLM Judge every case ended in one well-formed `final_result` call with no malformed calls or missing verdict ids, at about $0.019 in total.
- On SQL data analysis it read `DATA.md` correctly on weekday bits, access letters, walk limits and service-day offsets, and in code mode it delivered verified answers with SVGs for four cases.

#### Weaknesses
- On SQL data analysis it called `final_result` prematurely in 13 of 20 runs, submitting values such as `run: "bogus"`, `legs: []` or ids that appear in no query result.
- On Billing ops code mode it submitted placeholders like `{"pence": 0}` or `{"ids": ["x"]}`, and in one run it fabricated invoice ids and amounts after exhausting the sandbox budget.
- On Billing ops with tool calling it stopped large audits early, for example checking 26 of 384 invoices and guessing the rest.
- On LLM Judge all three failures were yes where the labels said no, including one case where its reasoning concluded no and then switched.
- On Research & deck code mode it asked the founder before reading the files, did not resolve an ambiguous slide order, and misreported which image it had shipped.

#### Tool calling compared with code mode
- On Billing ops tool calling was more reliable (7 of 10 against 4 of 10), and code mode's roughly ninefold lower cost came mostly from runs that ended early with placeholders.
- On Billing ops code mode solved duplicate-lines at one sixteenth of the tool-calling cost when it finished, but it usually made one tool call per `run_code` and hit both sandbox limits.
- On SQL data analysis code mode passed 6 of 10 against 2 of 10 for tool calling, at $0.044 per run against $0.027, and tool calling solved no case that code mode missed.
- On Research & deck tool calling passed with half the requests, while code mode lost requests to sandbox gaps such as `view_image` not being callable and `import html` missing.
- Across Billing ops and SQL data analysis, a guard that rejects placeholder `final_result` payloads is needed for either mode, especially code mode.

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/deepseek-v4.1-flash`. Compare it with others: `https://pydantic.dev/models/api/models?slug=deepseek-v4.1-flash,<other slug>`
