---
title: "DeepSeek V4 Flash 0423 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 10%, code mode 10%; rank 35 of 44."
canonical: https://pydantic.dev/models/list/deepseek-v4-flash/sql_data_analysis/
---

# DeepSeek V4 Flash 0423 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 10%, code mode 10%; rank 35 of 44.
>
> Markdown copy of https://pydantic.dev/models/list/deepseek-v4-flash/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/deepseek-v4-flash/pydantic_ai.md

| Mode         | Score | Tasks passed | Cost  | Requests | Tool calls | Time     |
| ------------ | ----- | ------------ | ----- | -------- | ---------- | -------- |
| Tool calling | 10%   | 1 of 10      | $0.85 | 650      | 745        | 58.1 min |
| Code mode    | 10%   | 1 of 10      | $1.07 | 697      | 697        | 65.4 min |

Each task was run once per mode.

## Review

Written by an LLM from the runs' transcripts.

#### Overall

deepseek-v4-flash passed **2 of 20** cases. The only passes were `one_vehicle` in both modes, the easiest question. Nine runs hit the 80-request limit (3 in tools, 6 in code mode). The other nine submitted wrong answers. Cost was about $0.85 for the tools runs and $1.07 for the code-mode runs.

#### Where it does well

- It decodes service bitmasks, `YYYY-DDD` days and repeat naming (`R27f8d4b1+2`) correctly.
- When it handles a single run, it applies the untimed-call interpolation and the 120 s plus walk margin correctly.
- Every submitted SVG followed the projection and carried `data-place`/`data-run`.
- In code mode `tour`, it eventually built a `heapq` planner and a search over visit orders, finding a return at 51780. It never submitted that answer.

#### Mistakes it makes

- **Searching by hand instead of writing an algorithm (most failures).** It traces one line at a time ('let me check line 62…') with one query per step. Multi-leg, tour and profile questions use up the 80 requests (9 cases) or end on a poor local answer: a 47-minute wait in `walking_change`, 3 of many journeys in `departure_profile`, and two shared stations checked in `meeting_point`.
- **Skipping untimed calls and repeats.** It often filtered with `at IS NOT NULL` and queried base runs only, which produced false gaps ('no line 9 between 06:29 and 18:50' in `one_change`).
- **Not reading the rules.** In 3 tools runs (`after_midnight`, `arrive_by`, `one_vehicle`) the paged `read_text` stopped at the first rule and the agent never read on. In `after_midnight`, neither mode used runs of the previous service day past 86400.
- **Approximating.** `timed_tour` (tools) estimated an interpolated arrival, and the TU stay then broke its time window (877 s inside the window, not 900).

#### Tool calling compared with code mode

Code mode did not help. It produced the same 1 pass, more request-limit failures (6 against 3) and about 25% higher cost. The model mostly used `run_code` as a wrapper around one SQL query and kept tracing by hand. Code mode also added a new failure: `run_sql` returned at most 200 rows, and the model treated those results as complete. In `saturday_direct` that hid the earlier tram `Ra7402f8f` and gave a worse answer than the tools run. Code mode did better in `meeting_point` (33840 against 35220) and used the fewest requests on `one_vehicle` (39 against 58).

## Runs

### one_vehicle

**Tool calling: passed.** It found the direct run `R27f8d4b1+2` from P0091960a at 29940 to P6e8c05a2 at 30480 and passed. ($0.065, 58 requests, 4.1 min)
- Right: Expanded the repeat correctly to `+2`
- Right: Gave a correct single-leg answer and a valid SVG
- Mistake: Never read the rules section of DATA.md past its first bullet (walks, margins). It passed only because the question needed none of them
- Mistake: Used 58 requests on a direct-run question

**Code mode: passed.** It found `R27f8d4b1+2` from 29940 to 30480 and reported arrival as 30519, adding the walk to the station point. It passed using 39 requests at $0.032. ($0.032, 39 requests, 4.4 min)
- Right: Correct run and repeat index
- Right: Cheapest passing run in the set
- Mistake: Hit 3 runtime errors along the way (for example `sorted(Path.iterdir())`)
- Mistake: Reporting arrival at 30519 instead of 30480 is unusual. The grader accepted it

### saturday_direct

**Tool calling: failed.** It settled on the direct tram 9 `Ra7402f8f` (board at 34320, arrive at 35460) after checking several lines by hand. The answer was wrong. ($0.035, 48 requests, 3.8 min)
- Right: Read the rules and checked access letters
- Right: Checked a tram 12 to Postplatz alternative
- Mistake: Its checks were not systematic: it looked for repeats on only 3 runs, and its queries often required `at IS NOT NULL`, which skips untimed calls. An earlier option was probably missed
- Mistake: No general earliest-arrival search

**Code mode: failed.** `run_sql` results were capped at 200 rows, so its list of runs at the origin platforms left out `Ra7402f8f` (34320). It concluded that `R0c0b14bd` at 35220 was 'the only run' and submitted an arrival at 36337, which was wrong. ($0.057, 43 requests, 4.7 min)
- Right: Computed the 8 s walk to the platform and the interpolated arrival
- Mistake: Treated truncated 200-row query results as complete. It noticed this later for places.txt ('only returned rows from the first 200 rows') but did not recheck the run list
- Mistake: Missed earlier direct tram 9 runs, which even the tools run found

### one_change

**Tool calling: error.** Over about 79 requests it explored lines from Gret-Palucca-Straße by hand. It had a candidate: walk to Hauptbahnhof, then bus 360 arriving at 29400. It never submitted it and hit the request limit. ($0.079, 80 requests, 6.8 min)
- Right: Read the rules
- Right: Found a plausible walk-then-bus candidate
- Mistake: Its queries used `c1.at IS NOT NULL` and base runs only. That produced false gaps ('no line 9 … between 06:29 and 18:50') because repeats were not expanded
- Mistake: Kept exploring instead of submitting its best answer, and ran out at 80 requests

**Code mode: error.** It checked repeats and nearby platforms around Gret-Palucca-Straße step by step and hit the 80-request limit with no answer. ($0.080, 80 requests, 5.7 min)
- Right: Read the rules
- Right: Looked at repeats.txt for the origin runs
- Mistake: Kept tracing by hand: the walk radius, then bus 261's route
- Mistake: Never wrote a 2-vehicle search and ran out of requests

### walking_change

**Tool calling: failed.** It submitted bus 62 to Pirnaischer Platz (arriving at 66000), then a 47-minute wait for tram 1 `R7b64cf35`, arriving at 69720. The answer was wrong. ($0.078, 60 requests, 5.8 min)
- Right: Read the rules and applied the 120 s plus walk margin
- Right: Listed platforms within 400 m
- Mistake: Queries filtered `at IS NOT NULL` and limited options to trams at a few stations, so it missed better walking changes
- Mistake: A 47-minute wait at the change point should have prompted a wider search

**Code mode: error.** It loaded tables and traced bus 62, bus 333 and tram 2 options via Postplatz and Hauptbahnhof run by hand. It hit the 80-request limit without submitting. ($0.095, 80 requests, 5.6 min)
- Right: Created DuckDB tables (`calls`, `places`) instead of re-reading CSVs on every query
- Mistake: Checked candidate runs one by one (`R3485561f`, `R782868bc`) instead of running a search
- Mistake: Ran out of requests

### after_midnight

**Tool calling: failed.** It only read DATA.md up to the first bullet of 'Rules the questions use', so it never saw the walking, 120 s change and previous-service-day rules. It filtered to Saturday services, found nothing before 03:53 and submitted line 66 then line 61, leaving at 17760 and arriving at 19140. That answer was wrong. ($0.075, 54 requests, 4.3 min)
- Right: Decoded the service bitmasks correctly for Saturday 2026-339
- Right: The legs it gave are consistent: `R183f16dd` to C-D-Friedrich-Straße, then `R6a766471` to Wasaplatz
- Right: The SVG used the right projection and carried `data-place`/`data-run`
- Mistake: The second `read_text` call (`start_line` 60) was cut off at 'It ends on reaching any platform…'. It never read the rest of the rules
- Mistake: It only used services that run on day 339. It never looked at runs on Friday 2026-338 with `at` > 86400, which the question about a 01:10 start is built around
- Mistake: It searched by hand, line by line (lines 3, 66, 360, 62, 63, 1), across about 50 SQL calls instead of writing a search

**Code mode: error.** It explored with `run_sql` inside `run_code`. Results were capped at 200 rows and it ignored the runs of the previous service day. Its best candidate left at 30960, worse than the tools run, and it hit the 80-request limit. ($0.13, 80 requests, 7.4 min)
- Right: Read the full rules
- Mistake: Never considered Friday 2026-338 runs with times past 86400
- Mistake: Worked from truncated 200-row results and concluded 'the first departure from Reichenbachstraße is at 30960'
- Mistake: Searched by hand within code mode and ran out of requests

### arrive_by

**Tool calling: error.** It never read the rules section past its first bullet. It then explored line 12 and line 4 connections from Pohlandplatz by hand and hit the 80-request limit without giving an answer. ($0.100, 80 requests, 6.0 min)
- Right: Worked out the time window correctly: 59400 to 64800
- Mistake: Did not read the full rules in DATA.md
- Mistake: Ran ad-hoc SQL per line (line 12 to Prager Straße, line 4 to Lennéplatz) and computed walks by hand instead of running a latest-departure search
- Mistake: Used all 80 requests and submitted nothing

**Code mode: error.** It checked stations near Pohlandplatz and line 12 repeats one at a time and hit the 80-request limit without answering. ($0.095, 80 requests, 5.2 min)
- Right: Read the rules
- Right: Expanded repeats such as `Rf0e36679+1`
- Mistake: Did not load the timetable into Python and run a search, even though it had code
- Mistake: Ran out of requests

### departure_profile

**Tool calling: failed.** It listed only 3 journeys (leaving at 25800, 27000 and 28380), built by hand from a few lines. In code mode the same model found many more non-dominated departures in the same window. The answer was wrong. ($0.12, 67 requests, 7.2 min)
- Right: Read the full rules
- Right: Named repeated runs in the `R16738db2+1` form
- Mistake: Did not enumerate every departure in 07:00–08:00. It took one connection per line pair, so the profile is incomplete
- Mistake: Did not check dominance across all candidates

**Code mode: failed.** It loaded the data into Python with an interpolation helper (`compute_times`), but built journeys from hand-picked line pairs (line 1 or 2 to line 9 or line 4). It submitted a long list starting at a 25565 departure. The answer was wrong. ($0.16, 76 requests, 9.7 min)
- Right: Implemented untimed-call interpolation and repeat expansion
- Right: Departure times correctly subtract the walk to the origin platform
- Mistake: Generated candidates from specific line pairs (`R77afbc0f+k` to `R023e7fca+k`) instead of from all connections
- Mistake: Dominance was checked only among those candidates

### meeting_point

**Tool calling: failed.** It intersected the call lists of two line 11 runs (`Rc0124950` and `R437bfcc1`) and picked Gret-Palucca-Straße at 35220. In code mode the model found a meeting at 33840, so this answer is clearly not the soonest. ($0.045, 50 requests, 5.1 min)
- Right: Read the rules and considered walks of up to 400 m from Waldschlößchen
- Mistake: Only looked at stations shared by one hand-picked run from each friend. It missed the earlier line 6 option (`Rfa439a34` at 09:01) and changes
- Mistake: Never computed earliest arrival at every station for both origins

**Code mode: failed.** It found line 11 from Waldschlößchen at 09:15 and line 6 from Julius-Vahlteich-Str. at 09:01, and chose Bahnhof Neustadt S17b69c22 at 33840. It said 'let me implement a Dijkstra-like algorithm' but never did. The answer was wrong. ($0.095, 59 requests, 7.1 min)
- Right: Found a meeting much earlier than the tools run (33840 against 35220)
- Right: Checked walks to nearby platforms
- Mistake: Did not compute earliest arrival at every station from both origins, so the minimum is unverified
- Mistake: Planned a proper search but went back to manual tracing

### timed_tour

**Tool calling: failed.** It built a 6-leg tour returning at 52680. It estimated the interpolated TU arrival by copying travel time from another run ('let me just approximate') rather than applying the formula. With the resulting arrival of 41423 and departure of 42496, only 877 s of the stay fall inside the TU window, which ends at 42300. ($0.14, 73 requests, 8.8 min)
- Right: Respected the Pohlandplatz and Mickten windows
- Right: Used repeated-run names such as `R2593df05+7`
- Mistake: Did not apply the interpolation formula for the untimed TU call
- Mistake: The 15 minutes at TU (Sd3f1948f) do not fit inside 10:15–11:45, which breaks a constraint in the question
- Mistake: Did not compare visit orders systematically

**Code mode: error.** It explored tram and bus lines between the tour stations one query at a time (for example 'Tram 3 doesn't serve any of our stations'). It wrote 'I need to … write a proper journey planner' at request 79 and hit the limit. ($0.16, 80 requests, 6.2 min)
- Right: Read the time windows and checked walking options (TU to Nürnberger Platz, 373 m)
- Mistake: Did not write the planner until the request budget was gone
- Mistake: A malformed SQL `WHERE` mixed `AND`/`OR` without parentheses

### tour

**Tool calling: error.** It worked through line 11 repeats and interpolation for the first leg of a 5-station round trip by hand and hit the 80-request limit with no route. ($0.11, 80 requests, 6.2 min)
- Right: Read the rules and handled repeat expansion and interpolation correctly for one run
- Mistake: Planned the tour one leg at a time in SQL, which cannot finish within 80 requests
- Mistake: Did not write code for station-to-station earliest arrival plus a search over visit orders

**Code mode: error.** It built a `heapq`-based search plus a permutation search over visit orders, and found a best return of 51780 (14:23) with a full 10-leg route. It ran out of requests while drawing the SVG, before calling `final_result`. ($0.16, 80 requests, 9.3 min)
- Right: The only run that wrote a real routing algorithm and tried every visit order
- Right: Its route used repeated runs and changes correctly
- Mistake: Spent about 70 requests exploring before writing the planner, then had no requests left to submit the answer
