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

# Gemini 4 Hydrogen on Pydantic AI - Billing ops

> Questions about and changes to a tutoring agency's books, checked to the penny. Tool calling 90%, code mode 100%; rank 4 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/gemini-4-hydrogen/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-hydrogen/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 90%   | 9 of 10      | $5.76 | 83       | 733        | 27.3 min |
| Code mode    | 100%  | 10 of 10     | $0.79 | 92       | 92         | 6.1 min  |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

`gemini-4-hydrogen` passed 19 of 20 cases: 9 of 10 with tool calling and 10 of 10 in code mode. The one failure was `large-wrong_invoices-1` with tool calling, where it returned 6 of the 12 wrong invoices. No case hit a provider error. Total cost was $5.76 for tool calling and $0.79 for code mode.

#### Where it does well

- **Changes (4 of 4 passed).** Both corrections ran `update_attendance`, `void_invoice` and `create_invoice` in the right order, dated today. Both payments netted off the existing 21152 allocation and allocated oldest due date first.
- **Handbook rules.** It applied half-up rounding, split charges, non-taxable clients, released allocations and tutor pay for lessons with no charged student correctly everywhere it tried.
- **Self-checking.** Margin answers were reconciled against invoice lines (74 and 33 lines, 0 mismatches). Code-mode writes were read back afterwards.
- **Efficient lookups.** Simple questions took 2 to 5 requests.

#### Mistakes it makes

- **Incomplete coverage on the large audit (1 failure).** In `large-wrong_invoices-1` with tool calling it fetched only about 30 of 384 October invoices with `get_invoice`. It relied on shortcuts: odd tax totals in `list_invoices`, and `missed` attendance marked `invoiced`. Those found six invoices with correct amounts. It never recomputed lines, so it missed three duplicate-line and three wrong-rate invoices. It used 26 requests, including `search_clients(name="a")`.
- **Guessed response fields in code.** Five code-mode cases wrote pagination loops testing keys that do not exist (`has_more`, `next_page`, `has_next`), costing a repeat request in three. One runtime error came from `a["attendance"]` instead of `status`; it recovered.
- **Over-checking.** `small-wrong_invoices-1` in code mode had the answer by request 5 and ran six more. The large variant spent eight requests on September and November data.
- **Arithmetic done unaided with tool calling.** The answers were right, but nothing in those runs verifies them.

#### Tool calling compared with code mode

Code mode was more reliable and about 7x cheaper overall. The gap is in the large audit cases:

| Case                      | Tool calling  | Code mode     |
| ------------------------- | ------------- | ------------- |
| `large-missed_billed-1`   | $2.35         | $0.06         |
| `large-duplicate_lines-1` | $0.79         | $0.08         |
| `large-wrong_invoices-1`  | $1.77, failed | $0.23, passed |

Tool calling pulled thousands of records into context; code mode joined them in the sandbox and recomputed every line. On small lookups and changes, tool calling was slightly cheaper and used 1 to 2 fewer requests. Code mode's request counts were inflated by fetching in batches of 80 to 96 (up to nine requests per case).

## 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.014, 2 requests, 4 s)
- Right: Shortest possible path

**Code mode: passed.** Fetched INV-00084, then summed its lines in a second script to confirm 89700. Passed in 3 requests. ($0.017, 3 requests, 5 s)
- Right: Confirmed the line sums match the header `net`, `tax` and `total`
- Mistake: One more request than tool calling for a single lookup

### small-owed_on_invoices-1

**Tool calling: passed.** Found CL-0007, listed unpaid invoices and allocations, re-fetched allocations per invoice, and answered 85204. Passed in 4 requests. ($0.028, 4 requests, 24 s)
- Right: Subtracted the 3563 credit allocation on INV-00155 from the 88767 unpaid total
- Mistake: Request 3 repeated `list_allocations` per invoice after already having them by client

**Code mode: passed.** Listed unpaid invoices and allocations for CL-0007, computed 88767 less 3563, and cross-checked against the ledger balance of -85204. Passed in 5 requests. ($0.032, 5 requests, 13 s)
- Right: Excluded released allocations with `released_on is None`
- Right: Cross-check against ledger balance and unallocated credit agreed
- Mistake: Pagination loop used a guessed `has_next` key
- Mistake: Request 3 fetched all invoices and the ledger, which the answer did not need

### large-tutor_margin-3

**Tool calling: passed.** Listed TU-002's 75 October lessons, attendance and the three relevant clients, worked out the margin without code, and cross-checked against November invoices. Answered 120741, correct. ($0.21, 7 requests, 2.2 min)
- Right: Fetched `get_client` only for clients where taxability mattered, finding CL-0097 non-taxable
- Right: Cross-checked its line amounts against `get_invoice` INV-06213 and INV-06406
- Mistake: `list_lessons` for 2026-10-31 to 2026-11-01 and `list_payment_orders` added nothing to the answer
- Mistake: All arithmetic over 75 lessons and 90 attendance rows was done unaided; it was right, but nothing in the run verifies it

**Code mode: passed.** Fetched 75 lessons, 90 attendance rows and 18 clients, computed net charges and tutor pay with `Decimal` and `ROUND_HALF_UP`, and reconciled against invoice lines. Answered 120741, correct. ($0.064, 6 requests, 29 s)
- Right: Half-up rounding done with `Decimal`, not `round()`
- Right: Paid the tutor for billable lessons with no charged student, as the handbook says
- Right: Reconciliation matched 74 lines with 0 mismatches and the same net of 360316
- Mistake: Request 2's pagination loop used guessed keys (`has_more`, `per_page`) and was rewritten in request 3

### small-tutor_margin-3

**Tool calling: passed.** Listed TU-001's 39 October lessons, attendance and seven clients, computed the margin without code and checked two November invoices. Answered 65045, correct. ($0.12, 7 requests, 70 s)
- Right: Fetched all seven clients to get `is_taxable`
- Right: Cross-checked lines against INV-00187 and INV-00220
- Mistake: `list_payment_orders` was not needed by the handbook's margin rule, though it gave a check on tutor pay
- Mistake: Arithmetic done unaided

**Code mode: passed.** Fetched 39 lessons, attendance and seven clients, computed the margin with `Decimal`, and matched 33 of 33 invoice lines. Answered 65045 after one runtime error. ($0.072, 9 requests, 35 s)
- Right: Tutor pay of 122390 matched the payment order
- Right: All 33 charged lines matched invoices with 0 mismatches
- Mistake: Request 3 failed with a runtime error on `a["attendance"]`; the field is `status`, which the same script had just printed. Fixed in request 4
- Mistake: Request 8 re-checked lessons around the month boundaries, which was not needed

### large-duplicate_lines-1

**Tool calling: passed.** Paged `list_invoices` for October (4 pages), then called `get_invoice` for the non-void invoices in parallel batches of roughly 80 and found the three duplicates by reading them. Passed at $0.79. ($0.79, 10 requests, 3.3 min)
- Right: Covered every October invoice rather than sampling
- Right: Correct three ids: INV-06060, INV-06073, INV-06097
- Mistake: Request 3 made an unfiltered `list_invoices(page=1)` and `list_lessons(page=1)` that returned 2025 data of no use
- Mistake: Duplicate detection was done by reading about 3,100 invoice lines in context, with no way to check it; about 10x the cost of the code-mode run

**Code mode: passed.** Paged October invoices, fetched all 384 non-void ones with `get_invoice` in five batches of 90, and counted `(lesson_id, student_id)` pairs with a `Counter`. Passed at $0.08. ($0.082, 10 requests, 30 s)
- Right: Duplicate check was exact and done in code
- Right: Also checked for the same pair across different October invoices
- Right: Printed the three invoices' lines before answering
- Mistake: The first script guessed pagination keys (`has_more`, `next_page`, `invoices`) and stopped after page 1, so request 2 fetched the pages again
- Mistake: Spent five requests on batches of 90

### large-missed_billed-1

**Tool calling: passed.** Listed October invoices, paged all 30 pages of September lessons, then called `list_attendance` over consecutive lesson-id ranges to find `missed` students marked `invoiced: true`, and confirmed against three invoices. Passed, but cost $2.35. ($2.35, 9 requests, 5.7 min)
- Right: Used the `invoiced` flag on attendance to find candidates instead of fetching all 384 invoices
- Right: Checked `get_invoice` for INV-05821, INV-05846, INV-06080 and `get_lessons` for the three lessons before answering
- Right: Checked `LS-044139`, saw `missed_chargeable`, and correctly left it out
- Mistake: Fetched 30 pages of `list_lessons` into context only to learn the lesson-id range; the most expensive case in the benchmark at $2.35 against $0.06 in code mode
- Mistake: Early probes (`get_invoice` on void INV-05811 and INV-06146, `list_lessons` for August and October) were not needed

**Code mode: passed.** Fetched all 384 non-void October invoices, then `list_attendance` for the 2,655 lessons in 27 chunks, and matched invoice lines to `missed` attendance in code. Passed at $0.06. ($0.064, 10 requests, 29 s)
- Right: Joined 3,108 invoice lines to attendance on `(lesson_id, student_id)` in code
- Right: Confirmed counts (394 fetched, 384 non-void checked) and looked up the three lessons before answering
- Mistake: The pagination loop tested several key names that do not exist; it worked only because the empty-page check ended it

### large-wrong_invoices-1

**Tool calling: failed.** Returned 6 of the 12 wrong invoices, each with the right amount. It found the tax-on-non-taxable and missed-student errors but never recomputed every invoice line, so the three duplicate-line and three wrong-rate invoices were missed. ($1.77, 26 requests, 10.8 min)
- Right: Spotted INV-05851, INV-06016 and INV-06105 from the `list_invoices` totals alone (tax not 0 and not 20%) and confirmed with `get_client`
- Right: Found INV-05821, INV-05846 and INV-06080 through `list_attendance` rows with `missed` and `invoiced: true`
- Right: All six amounts it gave are correct
- Mistake: Fetched only about 30 of the 384 non-void October invoices with `get_invoice` (requests 4, 7, 10, 18, 19, 21, 22, 25), so duplicate lines in INV-06060, INV-06073 and INV-06097 were never seen; the same model fetched all of them in the tools duplicate_lines case
- Mistake: Never compared line amounts with `charge_rate` times hours, so the rate errors in INV-05791 (600), INV-05877 (750) and INV-06017 (500) were missed
- Mistake: Request 6 was `search_clients(name="a")`, a dump of clients with no use
- Mistake: Spent requests on September and November invoice lists, cancelled and planned lessons and four `list_ledger_entries` calls instead of covering October invoices
- Mistake: 26 requests and $1.77 for half the answer

**Code mode: passed.** Fetched all 384 invoices, 2,655 lessons, attendance and 384 clients, recomputed every line, and returned all 12 wrong invoices with correct amounts. Passed in 25 requests at $0.23. ($0.23, 25 requests, 2.1 min)
- Right: Recomputed each line from `charge_rate`, duration, charged-student count and `is_taxable`
- Right: The first pass found 9 invoices; a separate duplicate check at request 14 added INV-06060, INV-06073 and INV-06097
- Right: Final script deduplicated lines and printed a reason for each of the 12
- Mistake: The first comparison did not flag duplicate lines, so the answer was complete only because of the later extra check
- Mistake: Nine requests went on fetching invoices and clients in batches of 80 to 96
- Mistake: Requests 16 to 23 checked September and November invoices and uninvoiced lessons, which the question did not ask about

### small-wrong_invoices-1

**Tool calling: passed.** Fetched all 37 October invoices, their clients, four pages of September lessons and attendance, and found all four wrong invoices with correct amounts. Passed in 8 requests. ($0.41, 8 requests, 3.1 min)
- Right: Covered every invoice with `get_invoice`, which is what the large variant failed to do
- Right: Got all four error types right: INV-00158 4050, INV-00162 863, INV-00172 600, INV-00176 6000
- Right: Checked for void invoices with `list_invoices(status="void")`
- Mistake: Recomputed about 280 lines in context at $0.41; this approach did not scale to the large dataset

**Code mode: passed.** Fetched 37 invoices, 280 lessons, attendance and clients, recomputed each line in code and found the four wrong invoices. Passed in 12 requests. ($0.13, 12 requests, 63 s)
- Right: `calc_line` handled lesson status, attendance, split counts, tax and duplicates in one pass
- Right: Correct amounts for all four, including the 4050 duplicate on INV-00158
- Mistake: Had the answer by request 5, then spent six more requests fetching all 223 invoices and 1,371 pre-October lessons to look for cross-invoice duplicates and uninvoiced lessons, none of which changed the answer

### large-correction-2

**Tool calling: passed.** Looked up the client, invoice, lessons, attendance and allocations, then ran `update_attendance`, `void_invoice` and `create_invoice` for the three remaining lessons, all dated 2026-11-13. Passed in 6 requests. ($0.042, 6 requests, 19 s)
- Right: Searched `search_clients` with `Baker` (the student's surname) and picked the paying client CL-0234 from the invoice rather than from the name
- Right: Did the changes in the right order: attendance to `missed`, void, then reissue with only `LS-045914`, `LS-046583`, `LS-047246`
- Right: Summary correctly reported the new invoice was auto-paid from credit, leaving 5700 pence credit
- Mistake: Sent `update_attendance` and `void_invoice` as parallel calls in one request; it worked, but the order was not guaranteed by the model

**Code mode: passed.** Gathered client, invoice, lessons, attendance and allocations with `asyncio.gather`, then ran `update_attendance`, `void_invoice` and `create_invoice` in order in one script, and re-read the records afterwards. Passed in 6 requests. ($0.060, 6 requests, 22 s)
- Right: The three writes ran in sequence inside one `run_code` call
- Right: Read back attendance, allocations and ledger after the change to confirm it
- Mistake: Wrapped `get_invoice` in a needless `try/except`
- Mistake: Request 3 re-listed lessons and invoices it did not need

### large-record_payment-1

**Tool calling: passed.** Found the client, read invoices, allocations and ledger, then called `record_payment` for 50126 with allocations 37626 to INV-02840 and 12500 to INV-03247. Passed in 4 requests. ($0.035, 4 requests, 16 s)
- Right: Subtracted the existing 21152 allocation on INV-02840 so only 37626 went to it
- Right: Applied oldest due date first and dated the payment 2026-11-13

**Code mode: passed.** Computed what was left on each unpaid invoice in code, called `record_payment` with 37626 and 12500, and verified the invoice statuses afterwards. Passed in 6 requests. ($0.043, 6 requests, 17 s)
- Right: Allocation was computed, sorted by `due_date`, and excluded released allocations
- Right: Verified INV-02840 became `paid` and INV-03247 stayed `unpaid`
- Mistake: Two more requests than tool calling for the same result
