---
title: "Claude Opus 5.5 on Pydantic AI - SQL data analysis"
description: "Planning journeys by querying a real Dresden public transport timetable with SQL, with an SVG map of each answer. Tool calling 100%, code mode 90%; rank 1 of 44."
canonical: https://pydantic.dev/models/list/claude-opus-5.5/sql_data_analysis/
---

# Claude Opus 5.5 on Pydantic AI - SQL data analysis

> Planning journeys by querying a real Dresden public transport timetable with SQL, with an SVG map of each answer. Tool calling 100%, code mode 90%; rank 1 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/claude-opus-5.5/sql_data_analysis/. 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/sql_data_analysis.md. The model on every Pydantic AI benchmark: https://pydantic.dev/models/list/claude-opus-5.5/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 100%  | 10 of 10     | $2.58 | 144      | 159        | 13.7 min |
| Code mode    | 90%   | 9 of 10      | $1.78 | 104      | 97         | 10.4 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

Claude Opus 5.5 passed 19 of 20 cases: 10 of 10 in tool calling and 9 of 10 in code mode. The only failure was `departure_profile` in code mode, caused by two bugs in the model's own Python code. Tool calling took 144 requests and cost $2.58. Code mode took 104 requests and cost $1.78.

#### Where it does well

- **Reading the rules.** Every run read DATA.md and correctly applied previous-day runs, numbering of repeated runs, walks of up to 400 m and the 120 s change margin.
- **Routing in SQL (tool calling).** In `departure_profile` it used window functions, `last_value(... ignore nulls)` over timed calls only, to interpolate untimed calls exactly as DATA.md specifies. It then ran a round-based search with tables `L1`, `L2` and `L3` and rebuilt each journey's legs with a `qualify rn=1` join.
- **Optimal arrival times.** Both modes found the same best arrival in every shared case: 6420, 64440, 33701, 28440, 30480, 34560, 44160, 48660 and 63480.
- **SVGs.** Every SVG followed the coordinate formula and tagged each leg with `data-run` and each platform with `data-place`.

#### Mistakes it makes

- **Code bugs (1 failure).** In code mode, `departure_profile` let already-interpolated calls act as anchors (`a=max(j ... if arr[j] is not None)`). The rounding errors built up, so times came out 1 s early, for example 25326 instead of 25327. It also stopped at `t>32400` (09:00) when the window ended at 08:00, so it returned 24 journeys instead of 12. It did not sanity-check the result before answering.
- **Loose fields the grader let pass (3 cases).** In code mode, `one_vehicle` gave a departure of 29400 instead of 29541, and `saturday_direct` gave 33300 instead of 33484. `after_midnight` set off 18 minutes earlier with an extra leg. All of these passed because the arrival time was right.
- **Cost of tool calling.** The tools run of `tour` took 28 requests and $0.64, against 13 requests and $0.26 in code mode.

#### Tool calling compared with code mode

Code mode was cheaper in 9 of 10 cases and took about 28% fewer requests. The exception was `one_vehicle`, at $0.15 against $0.13. Tool calling was more careful: its departure times followed the question's definition and its windows matched the question. Code mode's hand-written Python made a rule error, anchoring the interpolation on computed times, that the SQL approach avoided by how it was built. On this benchmark, tool calling was more reliable (10/10 against 9/10) and code mode was cheaper.

## Runs

### one_vehicle

**Tool calling: passed.** Walked 399 m to Strehlener Platz and rode `R27f8d4b1+2`, arriving at 30480. Passed. ($0.13, 9 requests, 38 s)
- Right: Used a walk of 399 m, just inside the 400 m limit, at the start of the trip
- Right: Set the departure to the boarding time minus the walk (29541)

**Code mode: passed.** Same leg `R27f8d4b1+2` as tools mode, but reported the departure as 29400 instead of the boarding time minus the walk (29541). Passed. ($0.15, 10 requests, 45 s)
- Right: Correct leg and arrival time
- Mistake: The departure time does not follow 'first departure minus walk' and the SVG leaves out the walk; the grader accepted it

### saturday_direct

**Tool calling: passed.** Found the direct Saturday run `Rb28d92d7`, boarding at 33484 and arriving at 34560. Passed. ($0.19, 11 requests, 56 s)
- Right: Selected the right services for a Saturday

**Code mode: passed.** Same run `Rb28d92d7` as tools mode, with the departure given as 33300 rather than the boarding time of 33484. Passed. ($0.12, 7 requests, 38 s)
- Right: Correct run and arrival time
- Mistake: The departure field is not the actual set-off time; the grader accepted it

### one_change

**Tool calling: passed.** Returned `Rafeef850`, then a walk at Straßburger Platz, then `R620ec7d9`, arriving at 28440. Passed in 9 requests. ($0.14, 9 requests, 40 s)
- Right: Efficient: 9 requests and $0.14

**Code mode: passed.** Same legs as tools mode, with the departure reported as 27669, the boarding time. Passed. ($0.12, 7 requests, 37 s)
- Right: 7 requests, $0.12

### walking_change

**Tool calling: passed.** Returned `R76d2117b+4`, then a walk at Pirnaischer Platz, then `R3a0dccd4+54`, arriving at 63480. Passed. ($0.17, 12 requests, 52 s)
- Right: Changed vehicles with a walk between platforms correctly

**Code mode: passed.** Changed vehicles via Prager Straße and Altmarkt instead of Pirnaischer Platz, with the same arrival time of 63480. Passed. ($0.14, 11 requests, 49 s)
- Right: Found an equally good alternative route

### after_midnight

**Tool calling: passed.** Built the timetable with SQL, including runs from the previous service day, and returned a 2-leg trip (`R93fefd15`, then a walk, then `R900bf42f+2`) leaving at 5280 and arriving at 6420. Passed. ($0.24, 18 requests, 77 s)
- Right: Handled the previous service day correctly: times minus 86400 and runs past midnight
- Right: Drew the SVG with matching `data-place` and `data-run` elements
- Mistake: Used 18 requests, almost twice as many as code mode (10) for the same arrival time

**Code mode: passed.** Returned a 3-leg trip that left earlier (4200) and arrived at the same time (6420) as the tools run. Passed. ($0.14, 10 requests, 47 s)
- Right: Correct arrival time in 10 requests
- Mistake: Left 18 minutes earlier and made one more change than needed, where a 2-leg trip leaving at 5280 existed. It still passed because the arrival time was optimal

### arrive_by

**Tool calling: passed.** Found the latest departure that still arrives by the deadline: `R1aabe4da+29`, then `Rfd6f9e2d+67`, leaving at 63360 and arriving at 64440. Passed in 11 requests. ($0.16, 11 requests, 46 s)
- Right: Gave the same answer as code mode
- Right: Drew walk segments without a data-run, so they were not mistaken for legs

**Code mode: passed.** Gave the same answer as tools mode (63360 to 64440) in 6 requests. Passed. ($0.12, 6 requests, 38 s)
- Right: Cheapest arrive_by run: $0.12

### departure_profile

**Tool calling: passed.** Interpolated untimed calls with SQL window functions (`last_value ... ignore nulls` over timed calls only), ran a round-based search over L1, L2 and L3 tables, kept the latest start for each arrival time with `having max(s) between 25200 and 28800`, and returned 12 journeys from 25327 to 28620. Passed. ($0.35, 17 requests, 1.8 min)
- Right: Interpolated only between timed calls, as DATA.md says, so times such as 25327 and 27317 were exact
- Right: Applied the 07:00–08:00 window correctly (25200–28800)
- Right: Rebuilt each journey's legs with one join query using `qualify rn=1`
- Mistake: A first SQL attempt failed because `at` is a reserved word; it fixed the query by quoting the column

**Code mode: failed.** Wrote a Python connection-scan in the sandbox. It returned 24 journeys up to 32220 with times 1 s off (25326 instead of 25327), and failed. ($0.28, 12 requests, 1.6 min)
- Right: Read DATA.md and loaded the data quickly, after a first attempt with `__import__` that the sandbox rejected
- Right: The connection-scan structure and the Pareto filter were sound
- Mistake: In the interpolation loop, `a=max(j for j in range(i) if arr[j] is not None)` counted already-interpolated calls as timed anchors. Floor errors then built up and shifted times such as `R77afbc0f+4` to 25326 and `R023e7fca+2` to 27316. It should have anchored only on the calls that have an `at` in calls.txt
- Mistake: Used `if t>32400: break` (09:00) as the cutoff for the 07:00–08:00 window, so it listed 24 journeys instead of 12. It should have used 28800
- Mistake: Never checked the journeys against the question's window before answering

### meeting_point

**Tool calling: passed.** Picked Albertplatz `Sbb9212fa` as the meeting station at 33701, with one direct leg for each traveller (`Rc0124950`, `Rfa439a34`). Passed. ($0.28, 15 requests, 1.5 min)
- Right: Found the right station and meeting time

**Code mode: passed.** Same station `Sbb9212fa` and time 33701 as tools mode, but the first traveller boards `Rc0124950` at a different platform (`Pda4a5390`, 33300). Passed. ($0.22, 14 requests, 80 s)
- Right: Correct meeting station and time

### timed_tour

**Tool calling: passed.** Visited 4 stations with 5 legs and returned to the start at 44160. Passed. ($0.29, 14 requests, 1.7 min)
- Right: Got the same arrival time as code mode

**Code mode: passed.** Same 5 runs and arrival time 44160 as tools mode, with the first boarding at a different platform. Passed. ($0.23, 14 requests, 1.5 min)
- Right: Matched the optimal tour

### tour

**Tool calling: passed.** Solved the multi-station tour with 11 legs, arriving at 48660. Passed, but used 28 requests and $0.64, the most of any case. ($0.64, 28 requests, 3.5 min)
- Right: Found the optimal arrival time of 48660, which code mode also found
- Mistake: Costly: 28 requests, against 13 in code mode for the same arrival

**Code mode: passed.** 12 legs (one more than tools mode) with the same arrival time of 48660, in 13 requests. Passed. ($0.26, 13 requests, 1.7 min)
- Right: Less than half the cost of the tools run ($0.26 against $0.64)
- Mistake: Added an extra leg `R6a6680a8+4` that the tools run did not need
