---
title: "Gemini 4 Carbon 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-carbon/billing_ops/
---

# Gemini 4 Carbon 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-carbon/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-carbon/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost   | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ------ | -------- | ---------- | -------- |
| Tool calling | 100%  | 10 of 10     | $11.03 | 80       | 1123       | 88.1 min |
| Code mode    | 100%  | 10 of 10     | $1.15  | 86       | 86         | 30.0 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

Gemini-4-carbon passed all 20 runs: 10 cases, each run once with normal tool calling and once in code mode. Every figure, ID list and change set matched exactly. The two modes differed sharply in cost. Tools mode cost about $11.03 and code mode about $1.15.

#### Where it does well

- **Applying the rules.** Both modes got all 16 wrong-invoice amounts right, including half-up rounding cases such as INV-06060 at 3563 and INV-00162 at 863. Both tutor-margin figures were also exact (120741 and 65045). In code mode it wrote clear `Decimal` and `round_half_up` routines that branch on charge type, net/gross pricing and `is_taxable`.
- **Write tasks.** In both large-correction-2 runs it called `update_attendance`, then `void_invoice` dated today, then `create_invoice` with only the 3 remaining lines. In both large-record_payment-1 runs it netted the 21152 already allocated to INV-02840 and split 50126 into 37626 and 12500, oldest due date first.
- **Short lookups.** The small invoice-total and owed questions took 2–4 requests each.
- **Parallel reads.** It batched independent read calls together, for example `get_client`, `get_settings`, `get_lessons` and `list_attendance` in one turn.

#### Mistakes it makes

None of the mistakes changed an answer; they were about cost.

- **Brute force in tools mode.** On the 4 large October audit cases it pulled almost every record into context:
  - duplicate_lines called `get_invoice` on about 384 invoices: 660 KB, $1.51.
  - missed_billed paged through 20+ pages of September `list_lessons` plus `list_attendance`: 1.2 MB, $3.69.
  - wrong_invoices (large) took 21 requests and about 1.36 MB: $4.48.
- **Unneeded calls.** Examples:
  - `list_invoices` for September in missed_billed
  - `get_settings` and `list_lessons` in duplicate_lines
  - `list_ledger_entries` in record_payment

#### Tool calling compared with code mode

Both modes got the same results. Code mode made the large audits much cheaper:

| Case                   | Tools mode | Code mode |
| ---------------------- | ---------- | --------- |
| missed_billed          | $3.69      | $0.12     |
| wrong_invoices (large) | $4.48      | $0.32     |
| duplicate_lines        | $1.51      | $0.10     |

In code mode it fetched with `asyncio.gather` and filtered in Python, so only small results came back into context. On small cases and write tasks, code mode cost about the same or slightly more, and sometimes took 1–3 extra requests (small-wrong_invoices: 13 against 10). For data-heavy questions this model should be run in code mode.

## Runs

### small-invoice_total-1

**Tool calling: passed.** Answered 89700 in 2 requests. ($0.018, 2 requests, 13 s)
- Right: Minimal and correct

**Code mode: passed.** Answered 89700 in 3 requests. ($0.025, 3 requests, 35 s)
- Right: Correct

### small-owed_on_invoices-1

**Tool calling: passed.** Answered 85204 in 3 requests. ($0.023, 3 requests, 32 s)
- Right: Minimal and correct

**Code mode: passed.** Answered 85204 in 4 requests. ($0.035, 4 requests, 4.8 min)
- Right: Correct

### large-tutor_margin-3

**Tool calling: passed.** Computed the margin from lessons, attendance and client tax status. Got 120741. Passed in 7 requests at $0.23. ($0.23, 7 requests, 3.6 min)
- Right: Exact figure

**Code mode: passed.** Wrote a pricing function using `Decimal`, `round_half_up` and the charge-type branches. It also tracked billable lessons with no charged students. Got 120741. Passed. ($0.10, 8 requests, 77 s)
- Right: Implemented the handbook rules faithfully, including tutor pay once per lesson

### small-tutor_margin-3

**Tool calling: passed.** Answered 65045 in 7 requests at $0.20. ($0.20, 7 requests, 6.9 min)
- Right: Exact figure

**Code mode: passed.** Computed 65045 with a `Decimal` pricing routine in 9 requests. Passed. ($0.12, 9 requests, 2.4 min)
- Right: Correct
- Mistake: Took 2 more requests than tools mode

### large-duplicate_lines-1

**Tool calling: passed.** Fetched 4 pages of October invoices, then called `get_invoice` on almost every one in large parallel batches over about 10 requests. Found INV-06060, INV-06073 and INV-06097. Passed, but cost $1.51. ($1.51, 10 requests, 15.1 min)
- Right: Correct answer
- Right: Used `sent_from`/`sent_to` filters and parallel calls
- Mistake: Brute-force: it pulled the full detail of about 384 invoices into context (a 660 KB conversation)
- Mistake: Made needless `get_settings` and September `list_lessons` calls for a pure duplicate check

**Code mode: passed.** Listed the October invoices, fetched the details inside Python and checked for duplicate (lesson, student) pairs. Passed with $0.10 cost against $1.51 in tools mode. ($0.099, 9 requests, 2.7 min)
- Right: Filtering happened in the sandbox, so little data entered the context
- Mistake: Printed the whole first `list_invoices` page before writing the real code

### large-missed_billed-1

**Tool calling: passed.** Paged through about 20+ pages of September `list_lessons`, called `list_attendance` with long ID lists, then September `list_invoices` and some `get_invoice`. Answered INV-05821, INV-05846 and INV-06080. Passed, but cost $3.69 and the conversation reached 1.2 MB. ($3.69, 9 requests, 19.9 min)
- Right: Correct answer
- Right: Correctly reasoned that October invoices bill September lessons
- Mistake: Very costly brute force: paged all September lessons and their attendance instead of starting from invoice lines
- Mistake: Listed September invoices (`sent_from 2026-09-01`), which was irrelevant to the question

**Code mode: passed.** Joined invoice lines to attendance in Python. Answered INV-05821, INV-05846 and INV-06080 for $0.12, about 30 times cheaper than in tools mode. ($0.12, 9 requests, 3.3 min)
- Right: Correct, compact

### large-wrong_invoices-1

**Tool calling: passed.** Started with `get_settings` and `list_invoices`, then pulled invoice details, lessons and attendance over 21 requests, recomputing every line by hand. All 12 overcharge rows were exact. Passed, but at $4.48, the most expensive case. ($4.48, 21 requests, 26.1 min)
- Right: All 12 amounts exactly right, including rounding cases such as INV-06060 at 3563
- Mistake: Huge context (about 1.36 MB) from fetching everything through individual tool calls

**Code mode: passed.** Sampled invoices and clients, fetched details in batches of 100 with `asyncio.gather`, then recomputed every line in Python. All 12 rows were exact. Passed at $0.32 against $4.48 in tools mode. ($0.32, 20 requests, 6.5 min)
- Right: Explored the data shape before writing the full computation
- Right: Exact half-up rounding
- Mistake: 20 requests, partly because it fetched in small batches over several turns

### small-wrong_invoices-1

**Tool calling: passed.** Called `get_settings` and `list_invoices`, then went through invoice details by hand. All 4 rows were correct (for example INV-00162 at 863). Passed at $0.74. ($0.74, 10 requests, 9.8 min)
- Right: Correct rows and amounts
- Mistake: 225 KB of context for a small dataset

**Code mode: passed.** Recomputed the October invoice lines in Python and returned the 4 correct rows. Passed in 13 requests at $0.20. ($0.20, 13 requests, 3.2 min)
- Right: Correct amounts
- Mistake: Used 3 more requests than tools mode, but cost less

### large-correction-2

**Tool calling: passed.** Got the invoice, client, settings, lessons, attendance and allocations. Then it called `update_attendance` (LS-045235 → `missed`), `void_invoice` INV-06372 dated 2026-11-13, and `create_invoice` with the 3 remaining lines, which made INV-06548 (17100, paid from credit). Passed. ($0.072, 6 requests, 79 s)
- Right: Batched the read calls in parallel and made the 3 writes in the right order
- Right: The reissued invoice left out LS-045235 and kept the `missed_chargeable` lesson LS-045914
- Right: The summary correctly said 5700 of credit was left unallocated
- Mistake: Small waste: called `list_lessons` for Oct–Nov and `list_invoices`, which the task didn't need

**Code mode: passed.** Did the same 3 writes as in tools mode (attendance → `missed`, void INV-06372, reissue 3 lines) and got the identical changes. Passed. ($0.075, 6 requests, 2.6 min)
- Right: Same correct change set at nearly the same cost ($0.075)

### large-record_payment-1

**Tool calling: passed.** Looked up the client, invoices, allocations and ledger. Worked out that INV-02840 still owed 37626 and called `record_payment` for 50126, allocating 37626 to INV-02840 and 12500 to INV-03247. Passed. ($0.054, 5 requests, 4.6 min)
- Right: Allocated oldest due date first, correctly netting the 21152 already applied to INV-02840
- Right: Only 5 requests
- Mistake: The `list_ledger_entries` call wasn't strictly needed

**Code mode: passed.** Recorded the 50126 payment with the same allocations (37626 to INV-02840, 12500 to INV-03247). The summary noted 12504 still unpaid on INV-03247. Passed. ($0.060, 5 requests, 2.6 min)
- Right: Correct allocation and a more informative summary
