---
title: "DeepSeek V4.1 Flash on Pydantic AI - Structured output"
description: "Extracting UK company accounts into a nested Pydantic model, checked against the filer's tags. Tool calling 90%; rank 15 of 44."
canonical: https://pydantic.dev/models/list/deepseek-v4.1-flash/structured_output/
---

# DeepSeek V4.1 Flash on Pydantic AI - Structured output

> Extracting UK company accounts into a nested Pydantic model, checked against the filer's tags. Tool calling 90%; rank 15 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/deepseek-v4.1-flash/structured_output/. 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

About the benchmark: https://pydantic.dev/models/benchmarks/structured_output.md. The model on every Pydantic AI benchmark: https://pydantic.dev/models/list/deepseek-v4.1-flash/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost   | Requests | Tool calls | Time    |
| ------------ | ----- | ------------ | ------ | -------- | ---------- | ------- |
| Tool calling | 90%   | 9 of 10      | $0.066 | 10       | 10         | 6.7 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

DeepSeek-V4.1-Flash passed 9 of 10 cases, all in tool-calling mode. Every case took one request and one `accounts` call, and total cost was about $0.066. The only failure was a classification field: no monetary figure was wrong in any checked field.

#### Where it does well

- **Figures and scaling.** All three £000 cases (`tier1-07054261`, `tier1-11022760`, `tier2-SC121467`) were multiplied by 1,000 correctly.
- **Signs.** Deficits were returned negative and liabilities positive, including two awkward presentations:
  - `tier5-12026946`: "NET CURRENT LIABILITIES 14,613,956" printed without brackets became `net_current_assets` -14,613,956.
  - `tier3-09727592`: `provisions` printed as `(5,889)` stayed positive.
- **Tax credits.** All three were found and signed negative: -138,000, -571,000 and -51,830.
- **Group and parent.** The two sets of figures were kept apart in all six group cases, even where they differ by tens of pounds.
- **Creditor notes.** Every line was mapped to the right category and due date in the four cases that asked for them.

#### Mistakes it makes

- **Classifying by inference (1 failure).** In `tier1-07054261` it returned `accounts_type: "medium"` from turnover and headcount thresholds. Its own reasoning noted the accounts cite only FRS 102 and no medium-sized regime; `full` was expected. In `tier5-NI037684` it got `medium` right because the accounts state the regime.
- **Inconsistent handling of `-` lines.** It omitted zero creditor lines in `tier4-05840865` and included them in `tier4-NI626135`. Both passed, so the omission did not cost it here.
- **Near miss.** In `tier1-11022760` it wavered between 100, 0 and `null` for `called_up_share_capital` and landed on the expected 0 only at the end.
- **Computed figures.** It summed debtors due within and after one year in `tier1-07054261` and `tier2-SC121467`, against the handbook. The field was not checked.
- **Verbose deliberation.** Assistant output ran from about 4k to 62k characters. The longest runs (`tier4-05840865`, `tier5-12026946`, `tier1-11022760`) repeatedly re-argued settled points, and cost tracked this ($0.0033 to $0.0119).
- **No use of the checker.** It never submitted and corrected; every answer was a single first attempt.

## Runs

### tier1-07054261

**Tool calling: failed.** One request: read the Cube Logic accounts and called `accounts` once. Every figure matched, but it returned `accounts_type: "medium"` where `full` was expected, so the case failed. ($0.0076, 1 requests, 67 s)
- Right: Scaled all £000 figures by 1,000 and got every checked balance sheet and profit and loss figure right for both years.
- Right: Signs correct: `net_assets` -6,187,000, `profit_and_loss_reserve` -8,457,000, costs positive.
- Right: Read the 2024 tax line `138` as a credit by checking (10,577) + 138 = (10,439), and returned `tax: -138000`.
- Right: Treated `-` as 0 for 2025 `tax` and 2024 `interest_receivable`, both as expected.
- Right: `consolidated: false` despite the company being a parent, because it claims the consolidation exemption.
- Mistake: In its reasoning before the single `accounts` call it classified the filing from size thresholds (turnover £16.4m, 57 employees, so 'medium-sized') instead of from what the accounts state. It noted itself that the accounts 'don't say small companies regime or medium-sized companies regime. They just say FRS 102' and that `full` means 'FRS 102 without Section 1A', then still chose `medium`. It should have returned `full`, since no medium-sized regime statement appears.
- Mistake: It flip-flopped between `medium` and `full` more than ten times in the reasoning, which is where most of the output tokens went.
- Mistake: Returned `debtors` as a computed sum, 134 + 9,658 = 9,792,000 (and 10,162,000 prior), although the handbook says not to compute figures; the field was not checked.

### tier1-11022760

**Tool calling: passed.** One request: extracted the TaskUs Limited company details, balance sheet and profit and loss for both years in a single `accounts` call and passed. ($0.0082, 1 requests, 60 s)
- Right: `accounts_type: "full"`, `consolidated: false`, `audited: true` and both periods correct.
- Right: All £000 figures scaled correctly, including negative `net_current_assets` -36,631,000 and `net_assets` -20,029,000.
- Right: Prior-year sign change handled: `profit_before_tax` -1,230,000 and `profit_after_tax` -1,862,000.
- Mistake: `called_up_share_capital` was a long back-and-forth in the reasoning between 100 (note 20 shows 0.10 in £000), 0 (balance sheet shows `-`) and `null`; it first settled on 100 and only at the end committed to 0, which is what was expected. The pass on that field was close to a coin flip.
- Mistake: Roughly 35k characters of assistant output for a one-company extraction, most of it this deliberation; cost $0.0082.

### tier2-11600506

**Tool calling: passed.** One request: extracted the group balance sheet and profit and loss for both years and passed, with the shortest reasoning of the set. ($0.0033, 1 requests, 7 s)
- Right: All 40 checked figures correct in whole pounds, no scaling needed.
- Right: Net liabilities returned as negatives: `net_current_assets` -6,090,208, `net_assets` -2,896,388, `profit_and_loss_reserve` -2,896,788.
- Right: Returned only the group figures, as asked.
- Right: Cheapest run at $0.0033 with about 3.8k characters of output.

### tier2-SC121467

**Tool calling: passed.** One request: extracted the group balance sheet and profit and loss from £000 accounts for both years and passed. ($0.0065, 1 requests, 36 s)
- Right: Multiplied every £000 figure by 1,000.
- Right: Kept `administrative_expenses` as reported (10,998,000 and 12,351,000) rather than folding the separate 2024 bad debt provision line of 619 into it, and still took `operating_profit` -1,818,000 from the statement.
- Right: Prior-year tax credit returned as `tax: -571000`; `profit_and_loss_reserve` -1,296,000 and -1,176,000.
- Mistake: Returned `debtors` as sums it computed (808 + 5,988 = 6,796,000; 1,644 + 8,543 = 10,187,000), against the handbook's instruction not to compute figures; `debtors` was not among the checked fields.
- Mistake: Long deliberation over the bad debt provision line, about 22k characters of output.

### tier3-05959188

**Tool calling: passed.** One request: extracted group and parent company balance sheets for both years and passed. ($0.0042, 1 requests, 9 s)
- Right: Kept the two sets of figures apart where they differ slightly, for example prior `intangible_assets` 14,896,135 for the group and 14,896,091 for the parent.
- Right: Deficits negative for both entities: group `net_assets` -13,564,855, parent -15,485,891.
- Right: Noted the equity reserve has no field and left it out rather than merging it into another reserve.
- Right: Short reasoning, about 5k characters, $0.0042.

### tier3-09727592

**Tool calling: passed.** One request: extracted group and parent company balance sheets for both years and passed. ($0.0036, 1 requests, 9 s)
- Right: Returned `provisions` 5,889 as a positive amount although the parent balance sheet prints it as `(5,889)`, citing the handbook rule on liabilities.
- Right: Handled the sign change on the parent: `net_assets` -1,632,236 in the current year and 783,514 in the prior year.
- Right: Left out 'Other reserves', which has no field.
- Right: Parent prior `investments` shown as `-` returned as 0, as expected.

### tier4-05840865

**Tool calling: passed.** One request: extracted staff costs and the creditors notes for group and parent company and passed, after the longest reasoning of the set. ($0.012, 1 requests, 1.6 min)
- Right: Staff cost totals and components correct for both entities and both years.
- Right: Mapped every creditor line in notes 16 and 17 to the right category and due date, including `finance_leases` after one year 28,174 for the parent.
- Right: Kept 'Other creditors' as `other` at 1,278,154 instead of splitting out the director loan accounts of 48,817 mentioned in the note text, which matched the expected value.
- Mistake: Omitted lines the note shows as `-`: group `amounts_owed_to_group` and parent `bank_loans_and_overdrafts` within one year. The expected output lists them at 0, so the pass depended on the checker treating a missing line as 0. In `tier4-NI626135` it made the opposite choice and included the zero line.
- Mistake: About 62k characters of assistant output, the most of any case, at the highest cost, $0.0119.

### tier4-NI626135

**Tool calling: passed.** One request: extracted staff costs and the creditors notes for group and parent company and passed. ($0.0053, 1 requests, 24 s)
- Right: All eight within-one-year categories mapped correctly for both entities, including `amounts_owed_to_group` 3,668,476 for the group and 10,067,741 for the parent.
- Right: Included the after-one-year `bank_loans_and_overdrafts` line with `amount: 0` and `prior_amount: 5836`, which keeps the prior figure the note shows.
- Right: Balance sheet totals `creditors_within_one_year` and `creditors_after_one_year` correct for both entities.
- Mistake: Its reasoning went back and forth on whether to include lines shown as `-` before including them; the rule it applied here is the opposite of the one it applied in `tier4-05840865`.

### tier5-12026946

**Tool calling: passed.** One request: extracted company details, directors, group and parent balance sheets, group profit and loss, staff costs and creditors for The Cambium Group UK Holdings and passed. ($0.011, 1 requests, 72 s)
- Right: `accounts_type: "full"` and `consolidated: true`.
- Right: Listed all four directors, including Mr R Thompson who resigned on 13 August 2025.
- Right: Read 'NET CURRENT LIABILITIES 14,613,956', printed without brackets, as `net_current_assets` -14,613,956, and confirmed it with 16,705,042 - 14,613,956 = 2,091,086.
- Right: Took `interest_receivable` 374,360 and `interest_payable` 292,474 from the statement totals and cross-checked them against notes 11 and 12.
- Right: Prior tax credit returned as `tax: -51830`.
- Mistake: About 47k characters of assistant output, with long runs of re-confirming figures already settled; cost $0.0105.

### tier5-NI037684

**Tool calling: passed.** One request: extracted the full set of sections for John Mulholland Motors and passed. ($0.0053, 1 requests, 26 s)
- Right: `accounts_type: "medium"` taken from the accounts' own statement that they are prepared under 'the medium companies regime', which is the evidence it lacked in `tier1-07054261`.
- Right: Left group `intangible_assets` as `null` because goodwill has a nil carrying amount and no balance sheet line, and `investment_property` as `null` because it is not on its own line.
- Right: Kept group and parent creditors apart where they differ by small amounts, for example `other` prior 103,090 for the group and 102,990 for the parent.
- Right: Mapped the directors' loan line to `amounts_owed_to_directors` 18,372 and 5,938.
