---
title: "Kimi K3.1 Pro 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 80%; rank 4 of 44."
canonical: https://pydantic.dev/models/list/kimi-k3.1-pro/billing_ops/
---

# Kimi K3.1 Pro on Pydantic AI - Billing ops

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

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 90%   | 9 of 10      | $2.78 | 67       | 575        | 23.0 min |
| Code mode    | 80%   | 8 of 10      | $0.74 | 81       | 81         | 8.6 min  |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

Kimi-K3.1-Pro passed 17 of 20 runs: 9 of 10 with tool calling and 8 of 10 in code mode. All three failures are the same question, "which October invoices charge the wrong amount", which needs four separate checks (rate, tax, missed student, duplicate line). Every other task type passed in both modes. Total cost was $2.78 for tools and $0.74 for code mode.

#### Where it does well

- **Changes to the books (4 of 4).** Payments were allocated oldest first after reading existing allocations (37626 + 12500). The void and reissue was done in the right order with today's date.
- **Pricing rules.** Margin runs (4 of 4) handled half-up rounding, gross lessons, non-taxable clients and tutor pay on lessons with no charged student.
- **Cross-checks.** Both tools margin runs matched tutor pay to the payment order; code-mode margin runs re-ran an independent calculation.
- **Persistence on single-check audits.** The tools duplicate-lines run read all 384 invoices even after 250 clean ones.

#### Mistakes it makes

- **Incomplete audits (3 failures).**
  - Tools, large: it decided 394 invoices were too many, guessed from list summaries and returned 3 of 12.
  - Code mode, large: the recompute priced each line on its own, so three duplicate-line invoices passed (9 of 12).
  - Code mode, small: the same gap, plus it never checked that the billed student was charged (2 of 4).
- **It noticed the gap and moved on.** In all three failures its notes mention the missing error types and then answer anyway.
- **Sandbox slips.** Seven failed scripts across five code-mode runs: missing `import asyncio`/`datetime`/`collections`, `next(generator)`, one wrong key. Each cost one request.
- **Hand work in tools mode.** It typed 2,957 lesson IDs on an assumption of contiguous numbering, and added 67 values long-hand.

#### Tool calling compared with code mode

Code mode was far cheaper on large data: $0.07 against $1.19 for duplicate lines, and $0.10 against $0.80 for missed-billed, with exact joins instead of reading by eye. On small cases, cost and request counts were about the same.

Code mode was not more accurate. On the small wrong-invoices case, tools passed because reading every line showed the duplicate and the missed student, while the script only tested what it was written to test. On the large case, code mode did better (9 of 12 against 3 of 12) because it fetched everything.

## Runs

### small-invoice_total-1

**Tool calling: passed.** One `get_invoice` call for `INV-00084`, then answered the `total` field, 89700. Passed in 2 requests. ($0.016, 2 requests, 5 s)
- Right: Checked `net + tax` (74752 + 14948) equals the total before answering.

**Code mode: passed.** One `get_invoice` call inside `run_code`, then answered 89700. Passed in 2 requests. ($0.019, 2 requests, 4 s)
- Right: Read the `total` field directly.

### small-owed_on_invoices-1

**Tool calling: passed.** Found `CL-0007`, fetched unpaid invoices and allocations in parallel, and computed 39452 − 3563 + 49315 = 85204. Passed in 3 requests. ($0.028, 3 requests, 39 s)
- Right: Used `list_invoices(status="unpaid")` and `list_allocations` in one parallel step.
- Right: Subtracted only the allocation on an unpaid invoice (3563 on `INV-00155`) and checked `released_on`.

**Code mode: passed.** Found `CL-0007`, gathered unpaid invoices and allocations, and computed the outstanding amount in code: 85204. Passed in 4 requests. ($0.028, 4 requests, 12 s)
- Right: Filtered `released_on is None` in the script and summed per invoice (35889 + 49315).
- Mistake: Called `get_client`, which was not needed.

### large-tutor_margin-3

**Tool calling: passed.** Listed 75 October lessons for `TU-002`, fetched attendance and 18 clients, then summed 67 lessons by hand in its notes. Got 120741 (360316 − 239575) and passed. ($0.16, 6 requests, 2.1 min)
- Right: Included tutor pay for the four billable lessons where every student was `missed`.
- Right: Handled gross lessons for taxable clients (`7875` → net `6562`) and no tax for the non-taxable client.
- Right: Cross-checked its tutor-pay total against the `list_payment_orders` figure of 239575, which matched.
- Mistake: All arithmetic was long-hand addition of 67 values in groups of ten; correct here, but there was no check on the revenue side.

**Code mode: passed.** Fetched lessons, attendance and 18 clients, then computed the margin with `Decimal` and `ROUND_HALF_UP`: 360316 − 239575 = 120741. Passed in 8 requests. ($0.10, 8 requests, 70 s)
- Right: Per-student cost rounded before tax, gross lines as cost − tax, non-taxable clients with no tax.
- Right: Ran a second independent calculation that returned `independent_check_mismatches: []`.
- Right: Listed the four billable lessons with no charge and kept their tutor pay.
- Mistake: One failed script: `datetime` used without importing it.

### small-tutor_margin-3

**Tool calling: passed.** Listed 39 October lessons for `TU-001`, fetched attendance and 7 clients, and summed 37 billable lessons by hand: 187435 − 122390 = 65045. Passed in 6 requests. ($0.077, 6 requests, 1.5 min)
- Right: Excluded the two `cancelled` lessons and kept tutor pay for the four all-`missed` lessons.
- Right: Rounded `2250 × 0.75 = 1687.5` up to 1688 and used cost − tax for gross lessons (`5625` → `4687`).
- Right: Checked tutor pay against the 2026-11-03 payment order (122390) and re-added revenue by client.
- Mistake: Hand arithmetic throughout; no independent check on revenue beyond re-adding the same figures.

**Code mode: passed.** Fetched 39 lessons, attendance and 7 clients, computed with `Decimal`: 187435 − 122390 = 65045. Passed in 8 requests. ($0.085, 8 requests, 60 s)
- Right: Correct handling of non-taxable gross lessons and of the four billable lessons with no charged student.
- Right: Produced a per-subject breakdown and matched tutor pay to the payment order (122390).
- Mistake: One failed script: `datetime` used without importing it.
- Mistake: Two extra verification requests after the answer was already computed.

### large-duplicate_lines-1

**Tool calling: passed.** Fetched every non-void October invoice with `get_invoice` in parallel batches of 25–55 and read the lines by eye for repeats. Found `INV-06060`, `INV-06073`, `INV-06097` and passed, at $1.19 and 19 requests. ($1.19, 19 requests, 8.1 min)
- Right: Finished the full scan of 384 non-void invoices instead of stopping after 250 clean ones, although its notes show it considered answering "none".
- Right: Reconciled the fetched invoice IDs against the list before answering.
- Right: Checked the 10 void/reissue pairs first and correctly ruled them out.
- Mistake: Most expensive case in the set ($1.19, about 700 KB of conversation): roughly 18 times the code-mode cost for the same answer.
- Mistake: Spent early requests sampling 'suspicious' invoices by total and calling `list_attendance`, which cannot show duplicate lines.
- Mistake: Duplicate detection was by reading about 3,100 lines, not by any exact check; the three hits were all in the last batches, so a missed one earlier would have gone unnoticed.

**Code mode: passed.** Fetched 384 non-void invoices in four batches of 96 with `asyncio.gather` and counted `(lesson_id, student_id)` pairs with a `Counter`. Passed in 8 requests at $0.07. ($0.067, 8 requests, 49 s)
- Right: Exact check: `Counter((line["lesson_id"], line["student_id"]))` with `count > 1`.
- Right: Filtered `status != "void"` in code and confirmed 384 fetched.
- Right: Returned only counts from each batch, keeping the conversation at 26 KB.
- Mistake: Called `get_settings`, which the question did not need.

### large-missed_billed-1

**Tool calling: passed.** Instead of reading every invoice, it pulled attendance for all 2,957 September lessons in 30 `list_attendance` calls and looked for `missed` with `invoiced: true`, then confirmed the three invoices. Passed in 8 requests at $0.80. ($0.80, 8 requests, 4.5 min)
- Right: Good shortcut: `status: missed` plus `invoiced: true` identifies the faulty lines without 384 `get_invoice` calls.
- Right: Confirmed each hit with `get_invoice`, `get_lessons` and a second `list_attendance` before answering.
- Right: Reasoned about void/reissued invoices and why they could not hide extra cases.
- Mistake: Assumed lesson IDs `LS-041722`–`LS-044678` were contiguous from the first and last page only, and hand-wrote 2,957 IDs into tool arguments; a gap or typo would have silently dropped lessons.
- Mistake: Only September lessons were scanned; an October invoice carrying an older lesson would have been missed.
- Mistake: Found the three rows by reading about 380 KB of attendance output by eye.

**Code mode: passed.** Fetched 384 invoices and attendance for 2,655 lessons, then joined invoice lines to attendance rows with `status == "missed"`. Passed in 14 requests at $0.10. ($0.10, 14 requests, 66 s)
- Right: Joined on `(lesson_id, student_id)` and reported `unmatched_line_count: 0`, so every line was checked.
- Right: Re-read the three invoices and their attendance before answering.
- Mistake: Three failed scripts, each costing a request: `asyncio`/`collections` not imported, `row["attendance"]` instead of `row["status"]` (KeyError), and `next(generator)` which the sandbox rejects.
- Mistake: Batches of 50 used 8 fetch steps where the duplicate-lines run used 4.

### large-wrong_invoices-1

**Tool calling: failed.** Listed 394 October invoices, judged a full audit too large, and answered from the list summaries alone with the three invoices whose tax looked wrong. Failed: 3 of 12 found. ($0.16, 6 requests, 2.1 min)
- Right: The three rows it gave (`INV-05851` 1050, `INV-06016` 1150, `INV-06105` 1875) are correct, and it confirmed with `get_client` that those clients are not taxable.
- Mistake: After the fourth `list_invoices` page it decided that 394 `get_invoice` calls were 'impossible' and guessed that the benchmark had seeded only tax errors. It should have fetched every non-void invoice, as it did in the duplicate-lines case.
- Mistake: Its notes name the other error types it might be missing ('split lessons', 'missed student billed', wrong rate) and then dismiss them without checking.
- Mistake: Missed 9 invoices: wrong rate (`INV-05791`, `INV-05877`, `INV-06017`), missed student billed (`INV-05821`, `INV-05846`, `INV-06080`) and duplicate lines (`INV-06060`, `INV-06073`, `INV-06097`).
- Mistake: It fetched `INV-05821` early and wrote it off as rounding instead of checking attendance.
- Mistake: Wasted a request on `search_clients(name="")`, which returned 50 rows without `is_taxable`.

**Code mode: failed.** Fetched all 384 non-void invoices, 2,655 lessons, attendance and 384 clients, and recomputed every line. Found 9 of 12 invoices; missed the three with duplicate lines. Failed after 19 requests. ($0.17, 19 requests, 1.9 min)
- Right: Did the full audit that the tools run skipped, with correct pricing, tax and half-up rounding.
- Right: Caught wrong rates, tax on non-taxable clients and all three missed-student lines; all nine amounts are correct.
- Right: When the first script raised on a `missed` student it treated that as a finding and recomputed with those lines at zero.
- Mistake: The recompute priced each invoice line on its own, so a repeated `(lesson_id, student_id)` line was priced as correct both times. `INV-06060` (3563), `INV-06073` (4500) and `INV-06097` (9900) were missed.
- Mistake: The line check used `exp_by_key = {(lesson_id, student_id): ...}`, which collapses duplicates. It should have counted pairs per invoice, as it did with `Counter` in the duplicate-lines case.
- Mistake: Its notes say the result was 'strong' after seeing nine line discrepancies and consistent header sums; neither check can see a duplicated line.
- Mistake: One failed script from `next(generator)`; 384 `get_client` calls took five requests.

### small-wrong_invoices-1

**Tool calling: passed.** Fetched all 37 October invoices in one parallel step, then September lessons and attendance, and checked every invoice line by line in its notes. Found all four and passed, at $0.29. ($0.29, 7 requests, 2.8 min)
- Right: Read all 37 invoices instead of sampling, and spotted the duplicate `LS-001226` line on `INV-00158` straight from the lines.
- Right: Found `INV-00176` from the attendance row `LS-001346` with `status: missed` and `invoiced: true`.
- Right: Verified split lessons (for example `LS-001219` with one charged student at 8000) so it did not flag correct lines.
- Mistake: Sent attendance requests for every ID from `LS-001057` to `LS-001371` rather than only invoiced lessons, adding about 80 KB of output it did not need.

**Code mode: failed.** Fetched all 37 invoices, lessons, attendance and clients, and recomputed each line. Returned only `INV-00162` and `INV-00172`; missed `INV-00158` and `INV-00176`. Failed in 9 requests. ($0.083, 9 requests, 66 s)
- Right: The two rows returned (863 and 600) are correct.
- Right: Used exact integer half-up rounding (`rhu(n, d)`) rather than floats.
- Mistake: `expected_line` priced a line from the lesson and the count of charged students, but never checked that the line's own student was charged. The `missed` student on `LS-001346` was priced at full cost, so `INV-00176` (6000) looked correct.
- Mistake: No check for repeated `(lesson_id, student_id)` lines, so the duplicate `LS-001226` on `INV-00158` (4050) was priced as correct twice.
- Mistake: Its notes ask whether there might be 'extraneous lines not captured' and then move on without testing.
- Mistake: Two failed scripts: `asyncio` not imported and `next(generator)`.
- Mistake: The `hourly_split` branch divides minutes by 6 and then by 60, which is wrong; it did not matter only because this dataset has no `hourly_split` lessons.

### large-correction-2

**Tool calling: passed.** Looked up the client and `INV-06372`, then ran `update_attendance` → `void_invoice` → `create_invoice` with the three remaining lessons, all dated 2026-11-13. Passed in 5 requests. ($0.035, 5 requests, 38 s)
- Right: Fetched `search_clients` and `get_invoice` in parallel in the first request.
- Right: Correct order: `update_attendance(LS-045235, ST-0332, missed)`, then `void_invoice`, then `create_invoice` with only `LS-045914`, `LS-046583`, `LS-047246`.
- Right: Summary reports the new invoice `INV-06548`, total 17100, paid from the released credit.
- Mistake: Did not read the attendance or lesson records before changing them; it relied on the invoice line description alone to pick `LS-045235`. It was right, but unverified.

**Code mode: passed.** Read the invoice, settings, attendance and lessons, then ran `update_attendance`, `void_invoice` and `create_invoice` in one script. Passed in 4 requests. ($0.031, 4 requests, 38 s)
- Right: Unlike the tools run, it checked `list_attendance` and `get_lessons` for all four lines before changing anything.
- Right: All three writes in one `run_code` call, in the right order, dated 2026-11-13.
- Right: Summary avoided claiming a leftover credit figure it had not read.

### large-record_payment-1

**Tool calling: passed.** Found the client, listed unpaid invoices and allocations, worked out 37626 still owed on `INV-02840`, and called `record_payment` with 37626 and 12500. Passed in 5 requests. ($0.026, 5 requests, 27 s)
- Right: Read `list_allocations` and spotted the 21152 already applied to `INV-02840` that same day, so it did not over-allocate.
- Right: Allocated oldest due date first: 37626 to `INV-02840`, 12500 to `INV-03247`, total 50126.
- Right: Payment dated 2026-11-13 as required.

**Code mode: passed.** Searched the client, listed unpaid invoices and allocations in separate scripts, then called `record_payment` with 37626 and 12500. Passed in 5 requests. ($0.042, 5 requests, 34 s)
- Right: Spotted the same-day 21152 allocation on `INV-02840` and computed 58778 − 21152 = 37626.
- Right: Correct allocations and date.
- Mistake: The allocation amounts were worked out in its notes and typed in as literals, not computed in the script from the fetched records.
- Mistake: Three reads done as three separate scripts where one would do.
