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

# Gemini 3.8 Flash on Pydantic AI - Structured output

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

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time    |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | ------- |
| Tool calling | 100%  | 10 of 10     | $0.31 | 10       | 10         | 4.7 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`gemini-3.8-flash` passed all 10 cases (tools mode only), each in a single request with one `accounts` tool call and no retries. Total cost was about $0.31, or $0.026–$0.039 per case. Each conversation was one prompt holding the accounts text (59k–84k characters) and one structured answer. Every scored field matched, so the notes below are about unscored loose ends, not failures.

#### Where it does well

- **Units.** The three £000 sets (`tier1-07054261`, `tier1-11022760`, `tier2-SC121467`) were all scaled by 1,000, including a £100 share capital shown as 0.10 returned as `0`.
- **Signs.** Deficits were negative in the seven cases that had them, while creditors and costs stayed positive. Tax credits were negative (`-138000`, `-571000`, `-51830`), and a tax charge on a loss stayed positive (`632000` in `tier1-11022760`).
- **Group versus parent.** In the six cases asking for both, the columns were never mixed, e.g. `tier3-05959188` group `net_assets` `-13564855` against parent `-15485891`.
- **Restated comparatives.** `tier1-07054261` and `tier3-05959188` used the restated prior-year figures.
- **Notes.** Creditor lines were mapped to categories and due bands correctly in all four tier 4–5 cases, and staff cost totals agreed with their parts.

#### Mistakes it makes

None cost a pass, but zero and `null` handling is inconsistent, and the check was lenient about it:

- **`null` where `0` was expected** (3 cases): prior `interest_receivable` in `tier1-07054261`, prior `other_operating_income` in `tier1-11022760`, parent prior `investments` in `tier3-09727592`.
- **`0` where no value was expected** (3 cases): `creditors_after_one_year` in `tier2-SC121467` and `tier5-12026946`, parent prior `investments` in `tier5-NI037684`, and a `trade_creditors` `prior_amount` in `tier5-12026946`.
- **Zero-value creditor rows dropped** in `tier4-05840865` (group `amounts_owed_to_group`, parent `bank_loans_and_overdrafts`), although `tier4-NI626135` kept a similar `0` row.
- **Empty sections shaped inconsistently**: parent `staff_costs` was `{}` in `tier5-12026946` and four `null`s in `tier5-NI037684`.

Several answers also include fields outside the expected set, such as `turnover`, `gross_profit` and `operating_profit` in `tier1-11022760` and `tier2-11600506`. These were not verified. With no failed check in any run, the handbook's instruction to go back to the accounts after a check error was never exercised.

## Runs

### tier1-07054261

**Tool calling: passed.** Read the Cube Logic accounts (£000) and returned everything in one `accounts` tool call; all scored fields matched and it passed on the first request. ($0.029, 1 requests, 23 s)
- Right: Scaled every £000 figure by 1,000 (e.g. `intangible_assets` 2,640 -> `2640000`)
- Right: Signed the deficits correctly: `net_current_assets` `-8967000`, `net_assets` `-6187000`, `profit_and_loss_reserve` `-8457000`
- Right: Returned the prior-year tax credit as `tax: -138000` and used the restated 2024 comparatives (`intangible_assets` `1229000`, `administrative_expenses` `17009000`)
- Right: One request, $0.0291
- Mistake: In the single `accounts` call, `prior_profit_and_loss.interest_receivable` was `null` where the expected value is `0`; the check accepted it

### tier1-11022760

**Tool calling: passed.** Extracted the TaskUs company details, balance sheet and profit and loss for both years in one `accounts` call and passed. ($0.030, 1 requests, 35 s)
- Right: Converted £'000 to pounds and returned `called_up_share_capital: 0` for the £100 capital shown as 0.10
- Right: Net liabilities signed correctly (`net_assets` `-20029000`, prior `-20588000`) while `creditors_after_one_year` stayed positive (`104000`, prior `46695000`)
- Right: Tax charge kept positive on a prior-year loss: `profit_before_tax` `-1230000`, `tax` `632000`, `profit_after_tax` `-1862000`
- Right: One request, $0.0297
- Mistake: `prior_profit_and_loss.other_operating_income` returned `null` where expected is `0`; accepted by the check
- Mistake: Also returned `turnover` (`32402000`), `cost_of_sales` (`26177000`), `gross_profit` and `operating_profit` (`2351000`), which the expected set does not contain, so they were not verified

### tier2-11600506

**Tool calling: passed.** Returned the Furat Acquisitions group balance sheet and profit and loss for both periods in one `accounts` call; passed. ($0.026, 1 requests, 19 s)
- Right: Took the group figures and not the company ones (e.g. group `cash` `1320993`, not the company's 84,945)
- Right: Deficits signed correctly: `net_current_assets` `-6090208`, `total_assets_less_current_liabilities` `-857995`, `net_assets` `-2896388`
- Right: All 40 scored fields matched in one request, $0.0258
- Mistake: None found; extra unscored fields (`turnover` `33135446`, `gross_profit`, `operating_profit`, `debtors`, `stocks`, `provisions`, `creditors_after_one_year`) were supplied and not verified

### tier2-SC121467

**Tool calling: passed.** Returned the Franke UK Holding group balance sheet and profit and loss (£000 accounts) in one `accounts` call; passed. ($0.039, 1 requests, 43 s)
- Right: Multiplied £000 figures by 1,000 throughout (`called_up_share_capital` `9559000`)
- Right: Prior-year tax credit returned negative (`tax: -571000`) with `profit_before_tax` `-1678000` and `profit_after_tax` `-1107000`
- Right: `profit_and_loss_reserve` negative (`-1296000`) although `net_assets` is positive (`8263000`)
- Right: One request, $0.0392 (the dearest case)
- Mistake: Current-year `creditors_after_one_year` returned as `0` rather than `null`, alongside a prior value of `4300000`; this field is not in the expected set, so it was not checked

### tier3-05959188

**Tool calling: passed.** Returned both the group and the parent company balance sheets of Tribe Payments for both periods in one `accounts` call; passed. ($0.032, 1 requests, 16 s)
- Right: Kept group and company columns apart (group `tangible_assets` `379315` vs parent `9602`; group `net_assets` `-13564855` vs parent `-15485891`)
- Right: Used the restated 2024 company figures from the prior period adjustment (`debtors` `3216646`, `profit_and_loss_reserve` `-19434573`, `net_assets` `-11497328`)
- Right: Parent `investments` `2467` / `2446` picked up; group `investments` left `null`
- Right: One request, $0.0316
- Mistake: None found

### tier3-09727592

**Tool calling: passed.** Returned the Tyk Technologies group and parent balance sheets for both periods in one `accounts` call; passed. ($0.028, 1 requests, 42 s)
- Right: Handled the sign change in the parent: `net_assets` `-1632236` this year, `783514` prior
- Right: Group and parent separated correctly (group `cash` `2720339`, parent `2017699`; parent `investments` `40275`)
- Right: Share capital taken from the pounds column (`252`, prior `250`), not the share counts
- Right: One request, $0.0283
- Mistake: `parent_company.prior_balance_sheet.investments` returned `null` where expected is `0`; accepted by the check

### tier4-05840865

**Tool calling: passed.** Returned the Drishaun Holdings staff costs and creditors notes for group and parent in one `accounts` call; passed. ($0.027, 1 requests, 21 s)
- Right: Staff cost totals agree with their parts for both entities (group `4716869` + `448675` + `205062` = `5370606`)
- Right: Creditor lines mapped to categories and split by `due`, e.g. parent `finance_leases` `11658` within one year and `28174` after
- Right: Parent `amounts_owed_to_group` `1538825` / `1524980` taken from the company columns
- Right: One request, $0.0266
- Mistake: Left out zero-value rows that the expected set lists: group `amounts_owed_to_group` within one year (`0`/`0`) and parent `bank_loans_and_overdrafts` within one year (`0`/`0`); the check did not penalise the omission

### tier4-NI626135

**Tool calling: passed.** Returned the Diamond Trucks staff costs and creditors notes for group and parent in one `accounts` call; passed. ($0.028, 1 requests, 17 s)
- Right: All ten creditor rows per entity returned, including the `bank_loans_and_overdrafts` after-one-year row with `amount: 0`, `prior_amount: 5836`
- Right: Totals match the notes: group `creditors_within_one_year` `15752489`, parent `17897307`; after one year `689258` and `686105`
- Right: Group and company staff costs kept apart (`total` `4404450` vs `1952516`)
- Right: One request, $0.028
- Mistake: None found

### tier5-12026946

**Tool calling: passed.** Returned the full Cambium Group set (company details, directors, group and parent balance sheets, group profit and loss, staff costs, creditors) in one `accounts` call; passed. ($0.036, 1 requests, 33 s)
- Right: All four directors listed
- Right: Group loss signed correctly (`operating_profit` `-4462968`, `profit_before_tax` `-4801087`) with a positive tax charge `72816` and a prior tax credit `-51830`
- Right: Parent and group creditors split correctly, e.g. `amounts_owed_to_group` `6050000` only in the parent, `bank_loans_and_overdrafts` `6841641` in both
- Right: Largest case (about 130 scored fields) done in one request, $0.0364
- Mistake: Parent `staff_costs` sent as an empty object `{}` and `prior_staff_costs` as `null`; inconsistent shapes, though nothing was expected there
- Mistake: Parent `trade_creditors` `prior_amount` returned as `0` and parent `creditors_after_one_year` as `0` where the expected set has no value; not penalised

### tier5-NI037684

**Tool calling: passed.** Returned the full John Mulholland Motors set for group and parent in one `accounts` call; passed. ($0.032, 1 requests, 29 s)
- Right: `accounts_type` correctly given as `medium` and `audited: true`
- Right: Both directors listed; `amounts_owed_to_directors` `18372` / `5938` mapped to its own category
- Right: Group vs parent differences captured (group `debtors` `713051` vs parent `3616379`; parent `investments` `300`)
- Right: Staff costs add up (`1119454` + `150080` + `34145` = `1303679`)
- Right: One request, $0.0321
- Mistake: `parent_company.prior_balance_sheet.investments` returned as `0` where the expected set has no value (the line is not shown); not penalised
- Mistake: Parent `staff_costs` returned as an object of four `null`s while `prior_staff_costs` was `null`; inconsistent but harmless
