---
title: "Gemini 4 Neon on Pydantic AI - Billing ops"
description: "Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 100%, code mode 100%; rank 1 of 44."
canonical: https://pydantic.dev/models/list/gemini-4-neon/billing_ops/
---

# Gemini 4 Neon on Pydantic AI - Billing ops

> Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 100%, code mode 100%; rank 1 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/gemini-4-neon/billing_ops/. 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/billing_ops.md. The model on every Pydantic AI benchmark: https://pydantic.dev/models/list/gemini-4-neon/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost   | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ------ | -------- | ---------- | -------- |
| Tool calling | 100%  | 10 of 10     | $12.76 | 91       | 1074       | 48.5 min |
| Code mode    | 100%  | 10 of 10     | $1.58  | 84       | 84         | 14.3 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

All 20 runs passed: 10 of 10 in tool calling and 10 of 10 in code mode. No provider errors, no wrong answers. The difference between modes is cost, not accuracy: tools cost $12.76 over 91 requests, code mode $1.58 over 84.

#### Where it does well

- **Write tasks** (`large-correction-2`, `large-record_payment-1`, both modes): correct order (`update_attendance`, `void_invoice`, `create_invoice`), dated today, oldest-due-first allocations (37626 then 12500), and a read-back check afterwards.
- **Handbook rules**: unreleased allocations, per-line half-up rounding (863 on INV-00162), split lessons and non-taxable clients were all handled correctly.
- **Parallelism**: up to 41 tool calls in one turn, which kept the largest audit to 25 requests.
- **Exhaustive audits**: all 384 non-void October invoices were covered in every audit case, in both modes.

#### Mistakes it makes

None changed a result; these are waste and risk.

- **Arithmetic by reading** in tools mode: margins over 67 and 37 billable lessons, and about 3,100 invoice lines, were checked with no computation. `large-tutor_margin-3` read only 3 clients of the 18 that code mode found.
- **Guessed IDs**: in tools `large-missed_billed-1` and `large-wrong_invoices-1` it built lesson IDs as a consecutive range from LS-041722 after reading only one or two pages of `list_lessons`.
- **Unfocused exploration**: tools `large-wrong_invoices-1` fetched attendance twice and called `search_clients` with an empty name.
- **Over-verifying**: code-mode `small-wrong_invoices-1` had its answer at message 8 and spent six more turns on unrelated checks.
- **Chunking by turn**: code mode split fetches into separate `run_code` calls of 80–90 (10 of 20 turns in `large-wrong_invoices-1`), and one script hit a runtime error.

#### Tool calling compared with code mode

Same accuracy, very different cost on bulk work. The three large audits cost $10.37 with tools and $0.68 in code mode: `large-wrong_invoices-1` was $5.53 against $0.37, `large-duplicate_lines-1` $2.87 against $0.13. Tools mode pulled up to 1.29 MB of records into context; code mode kept them in the sandbox and returned counts. Code mode also computed its answers (`Decimal`, `Counter`, joins) and reconciled them against invoice lines, so they are checkable. On small lookups the modes are level, and code mode sometimes used a request more (`small-invoice_total-1`: 3 against 2). For anything touching more than a few dozen records, choose code mode.

## Runs

### small-invoice_total-1

**Tool calling: passed.** One `get_invoice` call for INV-00084, then returned its `total` of 89700. Passed in 2 requests. ($0.026, 2 requests, 9 s)
- Right: Minimal path: read the stored total and answered.

**Code mode: passed.** Fetched INV-00084, then ran a second script summing the lines' net, tax and total to confirm 89700. Passed in 3 requests. ($0.035, 3 requests, 10 s)
- Right: Confirmed the stored total equals the sum of line totals.
- Mistake: The line-sum check was a second `run_code` turn; one request more than the tools run, which read the same field.

### small-owed_on_invoices-1

**Tool calling: passed.** Found CL-0007, read unpaid invoices and allocations, and answered 85204 (35889 left on INV-00155 plus 49315 on INV-00192). Passed in 4 requests. ($0.062, 4 requests, 19 s)
- Right: Subtracted the 3563 credit allocation from INV-00155 rather than summing invoice totals.
- Right: Fetched `list_invoices` (unpaid) and `list_allocations` in parallel.
- Mistake: Message 5 re-read `list_ledger_entries` and the full `list_invoices` for the client after it already had everything needed; one wasted request.

**Code mode: passed.** Gathered client, invoices, allocations and ledger for CL-0007 in one `asyncio.gather`, then computed total less unreleased allocations per unpaid invoice. Answered 85204 in 4 requests. ($0.057, 4 requests, 24 s)
- Right: Filtered allocations on `released_on is None` as the handbook requires.
- Right: Cross-checked against the ledger balance (-85204) and unallocated credit (0).
- Mistake: Read only page 1 of each list without checking `pages`; fine here, as the tools run showed one page.

### large-tutor_margin-3

**Tool calling: passed.** Listed TU-002's 75 October lessons, their attendance, a few clients and four November invoices, then answered 120741 with no visible calculation. Correct in 7 requests. ($0.53, 7 requests, 4.0 min)
- Right: Used `list_attendance` for all lessons in one call and cross-checked against invoice lines via `get_invoice` on INV-06243, INV-06213, INV-06406 and INV-06193.
- Right: Looked up tax status with `get_client`.
- Mistake: Called `get_client` for only three clients (CL-0097, CL-0065, CL-0269), although the code-mode run of the same case found 18 clients in these lessons; the tax status of the rest was not read directly.
- Mistake: Fetched only four of the 36 invoices the code-mode run found for these clients, so most lines were priced by hand: 67 billable lessons with `hourly_split`, `gross` and non-taxable cases, all summed without a tool. Correct, but unverifiable.
- Mistake: `list_payment_orders` is not needed by the handbook's margin rule.

**Code mode: passed.** Paged TU-002's 75 lessons, loaded attendance and 18 clients, computed the margin with `Decimal` and `ROUND_HALF_UP`, then confirmed all 74 computed lines against invoice lines. Answered 120741 in 7 requests at $0.14. ($0.14, 7 requests, 68 s)
- Right: Net 360316 less tutor pay 239575, each computed in code with explicit half-up rounding.
- Right: Reconciled against 36 invoices (74 matched, 0 mismatched) and against the payment order total 239575.
- Right: Checked for lessons crossing the month boundary.
- Mistake: The invoice reconciliation and the boundary check (messages 9 and 11) were extra requests; the answer was already in hand after message 8.

### small-tutor_margin-3

**Tool calling: passed.** Listed TU-001's 39 October lessons, attendance, seven clients and two November invoices, then answered 65045. Correct in 7 requests. ($0.30, 7 requests, 2.2 min)
- Right: Called `get_client` for all seven clients in one turn to get tax status.
- Right: Cross-checked the lessons of the two clients it queried against INV-00187 and INV-00220.
- Mistake: Margin over 37 billable lessons (24 net, 15 gross, two non-taxable clients) was summed without any tool to compute it.
- Mistake: `list_payment_orders` and the invoice lookups for only CL-0002 and CL-0037 were not required.

**Code mode: passed.** Loaded TU-001's 39 lessons, attendance and seven clients, computed net 187435 less tutor pay 122390 with `Decimal`, and reconciled against invoice lines. Answered 65045 in 7 requests. ($0.13, 7 requests, 57 s)
- Right: Printed counts of statuses, charge types, net/gross and taxable clients before computing.
- Right: Matched 33 invoice lines with no differences; tutor pay equalled the November payment order (122390).
- Right: Also computed tutor pay for charged-student lessons only (110902) and correctly did not use it.
- Mistake: Message 11 re-searched tutors by `Kai` and `Iyer` and re-listed lessons over a wider window; it changed nothing.
- Mistake: Three verification turns after the answer was already computed in message 8.

### large-duplicate_lines-1

**Tool calling: passed.** Paged all 394 October invoices, then called `get_invoice` on essentially every one in parallel batches and found the duplicated lines by reading the responses. Correct, but cost $2.87 with a 640 KB conversation. ($2.87, 12 requests, 7.9 min)
- Right: Covered all four `list_invoices` pages and every non-void invoice, so the answer was exhaustive.
- Right: Final turn fetched the void invoices (e.g. INV-05817, INV-05959) to confirm they were excluded.
- Right: Used large parallel batches of `get_invoice`, keeping it to 12 requests.
- Mistake: Message 5 fetched a seemingly arbitrary handful of invoices (INV-05851, INV-06016, INV-06105, INV-05884, INV-05811...) before starting the systematic sweep from INV-05761; those were fetched again later.
- Mistake: Duplicate detection over ~3,100 lines was done by reading raw JSON in context, with no computed check; correct here, but nothing verified it.

**Code mode: passed.** Paged 394 invoices, fetched the 384 non-void ones in five batches of 80, and counted `(student_id, lesson_id)` pairs with a `Counter`. Correct in 10 requests at $0.13, against $2.87 with tools. ($0.13, 10 requests, 71 s)
- Right: Duplicate detection was computed, both within each invoice and across invoices.
- Right: Kept invoice data in the sandbox and returned only counts, so the conversation is 10 KB.
- Right: Also checked the 10 void invoices for duplicates and that no line lacked an ID.
- Mistake: Split `get_invoice` fetching into five separate `run_code` turns of 80 instead of one loop; four extra requests.
- Mistake: The last check for missing `student_id`/`lesson_id` fields (message 17) added a request without affecting the answer.

### large-missed_billed-1

**Tool calling: passed.** Listed October invoices, then pulled attendance for September lessons in six `list_attendance` calls of about 500 IDs each, and fetched invoices for candidate missed students. Correct in 13 requests at $1.97. ($1.97, 13 requests, 7.9 min)
- Right: Went attendance-first: found `missed` records, then confirmed with `get_invoice` on a few candidates instead of opening all 384 invoices.
- Right: Checked the three hit lessons with `get_lessons` (LS-041761, LS-043071, LS-044224) before answering.
- Mistake: Only read `list_lessons` page 1 and page 30 for September, then generated lesson IDs as a consecutive range (LS-041722 onwards). That assumes IDs are contiguous and date-ordered; it held here but was not verified.
- Mistake: Message 5 called `list_attendance` with only five lesson IDs and three stray `get_invoice` calls, then `list_invoices` for void invoices from January to September, none of which the question needed.
- Mistake: About 380 KB of attendance records were read into context to find three rows.

**Code mode: passed.** Fetched all 384 non-void October invoices, then attendance for the 2,655 lessons on them in chunks of 100, and joined lines to attendance in code. Found three `missed` lines. Correct in 10 requests at $0.18. ($0.18, 10 requests, 58 s)
- Right: Took lesson IDs from the invoice lines, not from a guessed ID range as in the tools run.
- Right: Joined 3,108 lines against attendance by `(lesson_id, student_id)` and confirmed zero missing attendance records.
- Right: Noticed the attended line count (2760) exceeded attendance records (2757) and traced it to the three duplicate lines.
- Mistake: Message 1 returned the whole first page of invoices to the model (14 KB) when only the keys and count were needed.
- Mistake: Five separate turns of 90 `get_invoice` calls instead of one loop.

### large-wrong_invoices-1

**Tool calling: passed.** Fetched October invoices, September lessons, attendance for about 2,650 lessons and nearly every invoice in batches of up to 41 parallel calls, then compared them by reading. All 12 rows correct, but it took 25 requests, $5.53 and a 1.29 MB conversation. ($5.53, 25 requests, 19.4 min)
- Right: Found all three error types: wrong rate (e.g. INV-05791, 600), billed `missed` students (INV-05821, INV-05846, INV-06080) and duplicated lines (INV-06060, INV-06073, INV-06097).
- Right: Final turn checked the duplicate lessons LS-044150, LS-042250 and LS-044126 and the taxable status of CL-0034 and CL-0125 before answering.
- Right: Heavy parallelism kept the request count at 25 despite roughly 400 tool calls.
- Mistake: Unfocused start: message 5 sampled a few invoices, message 7 listed `cancelled` lessons, message 13 called `search_clients` with `name: ""` and listed September invoices, in a turn that returned 119 KB.
- Mistake: Attendance was fetched twice: first for selected lesson IDs (messages 9-11), then again for the whole consecutive range from LS-041722 (messages 17-23).
- Mistake: Lesson IDs were generated as a consecutive range rather than taken from the invoice lines.
- Mistake: Every line amount was checked by reading, with no computation; the most expensive case of the benchmark by a factor of two.

**Code mode: passed.** Loaded 384 invoices, 2,655 lessons, attendance and 384 clients, recomputed every line with integer half-up rounding and diffed against invoiced amounts. Found all 12 rows; 20 requests at $0.37, against $5.53 with tools. ($0.37, 20 requests, 2.9 min)
- Right: Expected amounts came from an `expected_line_amounts` function using `(2*num + den) // (2*den)` for half-up rounding.
- Right: Flagged duplicate lines separately and confirmed 537 split-lesson lines were covered.
- Right: Extra checks: no cross-invoice duplicates, all lessons in September, the 150 billable September lessons not invoiced were all `missed`.
- Mistake: Message 25's script hit a `Runtime error` after printing its results; message 27 re-ran the printing to recover, costing a request.
- Mistake: Ten turns went on chunked fetching: five batches of 90 for `get_invoice` and five for `get_client`, each a separate `run_code` call.
- Mistake: Tried `search_clients(name="")` to list all clients; it returned only 50, so it fell back to per-client `get_client`.

### small-wrong_invoices-1

**Tool calling: passed.** Fetched all 37 October invoices in two parallel batches, the clients, four pages of September lessons and their attendance, then reported four wrong invoices. Correct in 8 requests at $1.25. ($1.25, 8 requests, 5.5 min)
- Right: Direct plan: invoices, clients, lessons, attendance, then answer.
- Right: Checked for void October invoices (none) before finalising.
- Right: Got 863 for INV-00162 right, a figure that depends on per-line rounding.
- Mistake: Message 13 added `list_ledger_entries` and per-client `list_invoices` for CL-0010, CL-0014 and CL-0025 that could not change the answer.
- Mistake: Recomputed about 280 lessons' charges by reading; 203 KB of context for a 37-invoice dataset.

**Code mode: passed.** Fetched all 37 October invoices, 280 lessons, attendance and clients, recomputed each line with a `compute_line` function and found four discrepancies. Correct, but 11 requests against 8 with tools. ($0.29, 11 requests, 2.1 min)
- Right: The four discrepancies were found by message 8, with expected and invoiced amounts per line.
- Right: Half-up rounding done with `Decimal.quantize`; counted edge cases (26 split, 101 gross, 46 non-taxable lines).
- Mistake: After the answer was known, six more turns checked things outside the question: all 223 invoices in the system, 77 September and November invoices, ledger entries, void invoices, and 717 lessons before August (messages 9-19).
- Mistake: None of those checks changed the result; they roughly doubled the requests.

### large-correction-2

**Tool calling: passed.** Looked up the client, invoice, lessons, attendance and allocations, then called `update_attendance`, `void_invoice` and `create_invoice` with the three remaining lessons, all dated 2026-11-13. Passed in 7 requests. ($0.12, 7 requests, 38 s)
- Right: Batched reads in parallel (`search_clients`, `get_invoice`, `get_settings` in one turn; five lookups in the next).
- Right: Correct write order: `update_attendance` (LS-045235 -> `missed`) and `void_invoice` before `create_invoice` with LS-045914, LS-046583, LS-047246.
- Right: Re-read `list_attendance` and `list_allocations` after writing and reported the 17100p auto-payment and 5700p leftover credit.
- Mistake: `list_lessons` for ST-0332 in October (message 5) returned the same four lessons already fetched by `get_lessons`; one redundant request.
- Mistake: `update_attendance` and `void_invoice` were issued in the same parallel turn, relying on neither depending on the other.

**Code mode: passed.** Gathered settings, client, invoice, lessons, attendance, allocations and ledger with `asyncio.gather`, then ran `update_attendance`, `void_invoice` and `create_invoice` sequentially in one script. Passed in 6 requests. ($0.15, 6 requests, 3.6 min)
- Right: The three writes were awaited in order inside one `run_code` block, so the attendance change preceded the void and reissue.
- Right: Post-write check re-read attendance, ledger and allocations and computed the balance.
- Right: Summary reported INV-06548 at 17100p auto-paid, with 5700p unallocated credit.
- Mistake: `list_lessons` for ST-0332 across October and November (message 5) duplicated the earlier `get_lessons` data.
- Mistake: All three writes ran in one script with no check between them; a failure mid-script would have left a partial change.

### large-record_payment-1

**Tool calling: passed.** Found the client, read unpaid invoices, allocations and the ledger, then called `record_payment` for 50126 with allocations 37626 to INV-02840 and 12500 to INV-03247. Passed in 6 requests. ($0.11, 6 requests, 34 s)
- Right: Converted £501.26 to `50126` and dated the payment 2026-11-13.
- Right: Allocated oldest due date first, accounting for the 21152 already allocated to INV-02840.
- Right: Verified afterwards with `get_invoice` on both invoices (INV-02840 now `paid`).
- Mistake: `list_ledger_entries` (message 5) was not needed to work out the allocations.

**Code mode: passed.** Read the client's invoices, allocations and ledger, computed the oldest-first allocation in code, then called `record_payment` with 37626 to INV-02840 and 12500 to INV-03247. Passed in 6 requests. ($0.11, 6 requests, 53 s)
- Right: Allocation was computed by sorting unpaid invoices on `(due_date, id)` and subtracting unreleased allocations.
- Right: Checked that existing unallocated credit was 0 and that paid invoices matched their allocations before writing.
- Right: Verified afterwards that INV-02840 is `paid` and both new allocations exist.
- Mistake: Defined a `get_all_pages` helper in message 3 and never used it; only page 1 of invoices, allocations and ledger was read.
- Mistake: The pre-write consistency check and the `record_payment` call were in the same script, so the write would have gone ahead even if a mismatch had printed.
