EVEMISSTechnology

Repository guide · overview · v4

pydantic / pydantic-ai

“How Python does AI. Agents, realtime voice, image generation, embeddings. Every model, every interface, typed end to end.” — as described by its authors

  • AI Agents
  • Python
  • MIT · open-source license
Original repository
pydantic/pydantic-ai
Source platform
GitHub
Repository owner / organization
pydantic
License
MIT · open-source license
Analyzed revision
5b73d7c0da119f12c65b015b15eba3e4d128fca9
Last verified

Newer revision observed; the code this guide cites is unchanged. The default branch moved to f06bba53794d, checked 2026-10-03. A revision diff of 39 changed files found no change in the code regions this guide cites. The guide still describes revision 5b73d7c0da11; repository-wide counts (files, calls and so on) refer to that revision.

pydantic/pydantic-ai: Repository Overview Explained

Terms used on this page
Entrypoint record
A file the analyzer marks as a place where execution can start. When it carries a __main__ guard excerpt, the file contains an if __name__ == "__main__": block and the excerpt shows what that block calls; without an excerpt, the file was flagged by its name only.
Bounded static execution path
A call chain reconstructed from the source code without running it, stopped after a fixed number of steps. It shows how far the code can be followed on paper, not what happens at run time.
Unresolved boundary
Where a static path stops because the next call goes into an external library or cannot be resolved without running the code. It marks the edge of this analysis, not a defect in the repository.
Static relations
Calls and imports found in the source. "External or unresolved" relations point outside the analyzed files.
Module role
The analyzer's label for a file, inferred from how many calls go in and out (for example core, entry/orchestration, leaf). It describes a position in the call graph, not the authors' design.
Test-like files
Files whose names or locations look like tests. This analysis counts them; it does not run them.
Observed · inferred · author-claimed · unresolved
How each statement is supported: read directly from the analyzed files; derived by the analyzer from them; stated by the repository's authors (metadata, README); or not established by this analysis.
Verified
Two uses on these pages. In an analyzer record ("verified provenance", "a verified entrypoint") it means the record was read directly from the analyzed files, which these guides call observed; for an entrypoint, the __main__ guard text is present. Since the analyzer fix of 2026-10-04, a file that only has an entrypoint-like name such as cli.py or main.py is recorded as inferred; guides analyzed before that still call such a file verified, and it is still only a guess about how the file is used. It does not mean the code was run or tested. "Last verified" is the date the guide last passed the lab's checks against the analysis record of the stated revision; it is not a review of the repository itself.

A large, MIT-licensed Python repository — 4082 analyzed files, latest release v2.54.0 — whose verified starts are many __main__ guards across packages, scripts and examples. Static call-degree roles point to pydantic_ai_slim/pydantic_ai (agent, models, messages, exceptions) as the library core, with separate pydantic_evals and pydantic_graph packaging roots, 2514 test-like files, and manifest-based dependency evidence with documented parsing gaps.

What it is

Platform metadata records Python as the primary language, with 34,234,401 Python bytes alongside much smaller Makefile, PLpgSQL and Shell counts. It is MIT licensed; the latest recorded release is v2.54.0, published 2026-10-03, when the repository had 20385 stargazers. GitHub topics include agent-framework, genai, harness, harness-engineering, llm, pydantic and python.

The repository description — 'How Python does AI. Agents, realtime voice, image generation, embeddings. Every model, every interface, typed end to end.' — and the homepage https://pydantic.dev/pydantic-ai are author-supplied metadata, not analyzer observations.

Structurally, the analyzer counted 4082 analyzed files.

How it starts

Executable starts appear as Python __main__ guards across the pydantic_ai_slim and clai packages, .github/scripts, examples and tests. Two packages have __main__ guards: pydantic_ai_slim/pydantic_ai/__main__.py calls cli_exit() and clai/clai/__main__.py calls _cli.cli_exit('clai'). Under .github/scripts/ there are many more verified guards, including agent_provider_health.py, agent_spend_report.py and check_api_compatibility.py.

Examples show the usage pattern: pydantic_model.py runs agent.run_sync('The windy city in the US of A.') and prints result.output and result.usage; data_analyst.py calls analyst_agent.run_sync with a prompt and a deps object. chat_app.py starts a uvicorn server for pydantic_ai_examples.chat_app:app, and a module under tests/ calls mcp.run().

The one bounded static flow traced in detail starts at .claude/skills/testing-skill/parse_cassette.py, passes through main() and parse_cassette(), and terminates at unresolved external boundaries such as argparse.ArgumentParser and args.cassette.exists; the analyzer marks them unresolved_boundary, so nothing beyond them is established. The summary's 'detected starting point', examples/pydantic_ai_examples/slack_lead_qualifier/app.py, rests on a filename heuristic and is not established as the primary entry.

Structure

The analyzer designates docs, src and tests as top-level subsystems. Dependency records cite pydantic_evals/pyproject.toml and pydantic_graph/pyproject.toml as source paths, alongside the root pyproject.toml.

Static call-degree roles (inferred by the analyzer) sketch the library's shape: messages.py draws 403 incoming calls and sends 70, while exceptions.py draws 421 with none outgoing — both look like widely shared layers. agent/__init__.py shows the opposite profile, 4 incoming and 203 outgoing calls, and is labeled a service/core candidate. models/__init__.py (113 in, 52 out) and models/openai.py (8 in, 151 out) sit between.

In total the analyzer recorded 150000 relations — 124623 calls and 25377 imports — of which 125702 remain external or unresolved and 24298 resolved to local targets.

Dependencies and tests

The root pyproject.toml declares a large dev group: pytest, anyio, trio, coverage, dirty-equals, inline-snapshot, hypothesis, pytest-mock, pytest-xdist, pytest-split, mypy, pyright and ruff. Subpackages carry their own manifests: pydantic_graph lists anyio, logfire-api, pydantic and typing-inspection as runtime dependencies, and pydantic_evals lists logfire as optional. Manifest coverage is partial: the parser reads requirements files and pyproject.toml (PEP 621/735, Poetry tables) but not setup.py, setup.cfg, Pipfile or lock files, and version constraints are recorded as written.

The repository holds 2514 test-like files and 8 build/dependency manifests. tests/conftest.py defines pytest_configure (lines 101-113) and an anyio_backend function (lines 367-370).

Two coverage gaps: bounded analysis leaves files over 400 kB, minified bundles and vendored directories unparsed, and the packet reports five files in that state without establishing what their absence costs this analysis.

Read first

  • README.md first — the analyzer classifies it as a project-level important file.
  • Then pyproject.toml and LICENSE, also project-level important files.
  • Then the library core: pydantic_ai_slim/pydantic_ai/agent/__init__.py, where the extracted Agent class spans lines 476-4290; follow with messages.py and exceptions.py (for example SystemPromptPart, ModelRetry).
  • Then one runnable example, examples/pydantic_ai_examples/pydantic_model.py, to see run_sync usage and the result object in context.
  • The analyzer's suggested path agrees: start from manifests and important symbols, trace the bounded execution path, and inspect unresolved boundaries before changing code.

Limits of this analysis

This overview rests on static analysis only: reflection, runtime dependency injection, dynamic imports, monkey-patching, generated code, framework runtime wiring and dynamic dispatch are not resolved. Nothing here establishes runtime behavior — install/run/build inference is partial and installation commands are not verified. README-derived statements would remain author claims even if quoted, since extraction is line-based and skips headings, fenced code, HTML, badges, tables and shell prompts.

Relation coverage is incomplete: 125702 of the 150000 recorded relations remain external or unresolved, and the recorded total equals the documented 150000-per-repository cap. The packet also reports three entrypoint paths with no statically detected call steps; what those entrypoints do is not established.

The analysis resolves no wiring for how plugins or extensions load; dynamic imports and framework runtime wiring fall under the same static limits.

Notable symbols

  • models/__init__.py defines known_model_names (lines 120-127), the Model class (lines 454-1149), StreamedResponse (lines 1153-1417) and parse_model_id (lines 1645-1660).
  • pydantic_ai_slim/pydantic_ai/exceptions.py defines ModelRetry (59-99), ToolFailed (102-149), CallDeferred (152-167), ApprovalRequired (170-185) and RunCancelled (270-449).
  • pydantic_ai_slim/pydantic_ai/messages.py defines SystemPromptPart, FileUrl, VideoUrl, AudioUrl, ImageUrl, DocumentUrl and BinaryContent.

What this analysis could not establish

The writing model's own notes on the analysis record. Identifiers such as lim_3, exec_* or claim_… name records of that analysis; the claims table cites the same records.

  • No primary entrypoint is established: the summary's 'detected starting point' rests on a filename heuristic, and the one traced bounded path starts in a script under .claude/skills/.
  • 125702 of 150000 recorded static relations are external or unresolved; the recorded total equals the documented repository cap, so the relation set is capped.
  • Five files were inventoried but not parsed (oversized, minified or vendored); their content is absent from this analysis.
  • Runtime behavior is unverified: install/run/build inference is partial, installation commands are not verified, and three entrypoint paths have no statically detected call steps.
  • Module call-degree roles are static inferences and may not reflect runtime importance.
  • Dependency parsing excludes setup.py, setup.cfg, Pipfile and lock files; version constraints are recorded as written.
Claims and evidence — 39 claims, 39 supported by an independent verifier

Every statement above is a claim that cites grounding IDs from the analysis. IDs are internal to the analysis run; the columns show what each claim rests on and how strong that ground is.

Every substantive statement above is a claim bound to grounding IDs of the analyzed revision. Global grounding IDs are namespaced by the analysis run.

Claim Epistemic status Verifier Grounding (global IDs)
c1 Platform metadata records Python as the primary language; recorded language bytes are 34234401 Python plus smaller Makefile, PLpgSQL and Shell counts. observed supported analysis_169ebfd40f3abfe7:meta_primary_language, analysis_169ebfd40f3abfe7:meta_language_bytes
c2 Platform metadata records an MIT license, a latest release v2.54.0 published 2026-10-03, and 20385 stargazers observed at 2026-10-03. observed supported analysis_169ebfd40f3abfe7:meta_license, analysis_169ebfd40f3abfe7:meta_latest_release, analysis_169ebfd40f3abfe7:meta_stars
c3 GitHub topics recorded for the repository are: agent-framework, genai, harness, harness-engineering, llm, pydantic, python. observed supported analysis_169ebfd40f3abfe7:meta_topics
c4 The repository description ('How Python does AI. Agents, realtime voice, image generation, embeddings. Every model, every interface, typed end to end.') and the homepage https://pydantic.dev/pydantic-ai are author-supplied metadata, not analyzer observations. author_claimed supported analysis_169ebfd40f3abfe7:meta_description, analysis_169ebfd40f3abfe7:meta_homepage
c5 The analyzer's repository summary counts 4082 analyzed files. inferred supported analysis_169ebfd40f3abfe7:claim_72d2b935d53e
c6 pydantic_ai_slim/pydantic_ai/__main__.py contains a __main__ guard calling cli_exit(), and clai/clai/__main__.py contains one calling _cli.cli_exit('clai'). observed supported analysis_169ebfd40f3abfe7:py_entry_34c79207455c, analysis_169ebfd40f3abfe7:py_entry_ced396f72e87
c7 Verified __main__ guards exist under .github/scripts/, including agent_provider_health.py, agent_spend_report.py and check_api_compatibility.py. observed supported analysis_169ebfd40f3abfe7:py_entry_1a93f87ae56b, analysis_169ebfd40f3abfe7:py_entry_120add6b5d1d, analysis_169ebfd40f3abfe7:py_entry_6490561ef266
c8 Examples run agents inside __main__ guards: pydantic_model.py calls agent.run_sync('The windy city in the US of A.') then prints result.output and result.usage; data_analyst.py calls analyst_agent.run_sync with a user prompt and a deps object. observed supported analysis_169ebfd40f3abfe7:py_entry_e19dcd82aa60, analysis_169ebfd40f3abfe7:py_entry_09a800ee582e
c9 examples/pydantic_ai_examples/chat_app.py starts a uvicorn server (with reload) for pydantic_ai_examples.chat_app:app, and tests/example_modules/mcp_server.py calls mcp.run() under a guard. observed supported analysis_169ebfd40f3abfe7:py_entry_2a02f95bcb6d, analysis_169ebfd40f3abfe7:py_entry_3676648a1457
c10 The bounded static path from .claude/skills/testing-skill/parse_cassette.py's __main__ guard goes to main() and parse_cassette() and ends at unresolved external boundaries such as argparse.ArgumentParser and args.cassette.exists (terminal_reason unresolved_boundary). inferred supported analysis_169ebfd40f3abfe7:py_entry_e9ef1059e87f, analysis_169ebfd40f3abfe7:exec_bb0400b95179, analysis_169ebfd40f3abfe7:exec_5f90db10d033
c11 The summary names examples/pydantic_ai_examples/slack_lead_qualifier/app.py as a detected starting point, but that rests on a filename heuristic, so no primary entry is established. inferred supported analysis_169ebfd40f3abfe7:entry_26, analysis_169ebfd40f3abfe7:claim_72d2b935d53e
c12 The analyzer treats docs, src and tests as top-level subsystems. observed supported analysis_169ebfd40f3abfe7:subsys_1, analysis_169ebfd40f3abfe7:subsys_2, analysis_169ebfd40f3abfe7:subsys_3
c13 Dependency records cite pydantic_evals/pyproject.toml, pydantic_graph/pyproject.toml and the root pyproject.toml as their source paths. observed supported analysis_169ebfd40f3abfe7:dep_1, analysis_169ebfd40f3abfe7:dep_2, analysis_169ebfd40f3abfe7:dep_6
c14 Static call-degree roles: pydantic_ai_slim/pydantic_ai/messages.py has 403 incoming and 70 outgoing calls (service/core candidate); exceptions.py has 421 incoming and 0 outgoing (leaf/data-boundary candidate). inferred supported analysis_169ebfd40f3abfe7:role_190, analysis_169ebfd40f3abfe7:role_172
c15 pydantic_ai_slim/pydantic_ai/agent/__init__.py has 4 incoming and 203 outgoing calls and is labeled a service/core candidate. inferred supported analysis_169ebfd40f3abfe7:role_94
c16 pydantic_ai_slim/pydantic_ai/models/__init__.py has 113 incoming and 52 outgoing calls; models/openai.py has 8 incoming and 151 outgoing calls. inferred supported analysis_169ebfd40f3abfe7:role_191, analysis_169ebfd40f3abfe7:role_212
c17 The analyzer recorded 150000 relations: 124623 calls and 25377 imports; 125702 are external or unresolved and 24298 resolved locally. observed supported analysis_169ebfd40f3abfe7:relation_counts
c18 The root pyproject.toml dev group includes pytest, anyio, trio, coverage, dirty-equals, inline-snapshot, hypothesis, pytest-mock, pytest-xdist, pytest-split, mypy, pyright and ruff. observed supported analysis_169ebfd40f3abfe7:dep_19, analysis_169ebfd40f3abfe7:dep_6, analysis_169ebfd40f3abfe7:dep_7, analysis_169ebfd40f3abfe7:dep_11, analysis_169ebfd40f3abfe7:dep_12, analysis_169ebfd40f3abfe7:dep_18, analysis_169ebfd40f3abfe7:dep_40, analysis_169ebfd40f3abfe7:dep_22, analysis_169ebfd40f3abfe7:dep_25, analysis_169ebfd40f3abfe7:dep_26, analysis_169ebfd40f3abfe7:dep_43, analysis_169ebfd40f3abfe7:dep_44, analysis_169ebfd40f3abfe7:dep_45
c19 pydantic_graph/pyproject.toml lists anyio, logfire-api, pydantic and typing-inspection as runtime dependencies; pydantic_evals/pyproject.toml lists logfire as optional. observed supported analysis_169ebfd40f3abfe7:dep_2, analysis_169ebfd40f3abfe7:dep_3, analysis_169ebfd40f3abfe7:dep_4, analysis_169ebfd40f3abfe7:dep_5, analysis_169ebfd40f3abfe7:dep_1
c20 Dependency parsing covers requirements files and pyproject.toml (PEP 621/735, Poetry tables); setup.py, setup.cfg, Pipfile and lock files are not parsed, and version constraints are recorded as written. observed supported analysis_169ebfd40f3abfe7:lim_3a
c21 The repository contains 2514 test file(s) or test-like file(s) and 8 build/dependency manifest file(s). observed supported analysis_169ebfd40f3abfe7:ev_tests_1, analysis_169ebfd40f3abfe7:ev_manifest_1
c22 tests/conftest.py defines pytest_configure (lines 101-113) and an anyio_backend function (lines 367-370). observed supported analysis_169ebfd40f3abfe7:py_func_bb16171a4902, analysis_169ebfd40f3abfe7:py_func_f4fbd8cb1704
c23 Bounded analysis leaves files over 400 kB, minified bundles and vendored directories inventoried but not parsed; relation extraction is capped at 2500 per file and 150000 per repository. observed supported analysis_169ebfd40f3abfe7:lim_6
c24 The packet reports five files as inventoried but not parsed; what those files contain and what their absence costs this analysis is not established. unresolved supported analysis_169ebfd40f3abfe7:claim_f0da02ed20f8
c25 README.md is classified as a project-level important file; start reading there. observed supported analysis_169ebfd40f3abfe7:important_1
c26 pyproject.toml and LICENSE are classified as project-level important files. observed supported analysis_169ebfd40f3abfe7:important_2, analysis_169ebfd40f3abfe7:important_3
c27 Read pydantic_ai_slim/pydantic_ai/agent/__init__.py, where the extracted Agent class spans lines 476-4290. observed supported analysis_169ebfd40f3abfe7:py_class_79f0e588fd25
c28 Read messages.py and exceptions.py for shared types such as SystemPromptPart and ModelRetry, then examples/pydantic_ai_examples/pydantic_model.py to see run_sync usage with result.output and result.usage. observed supported analysis_169ebfd40f3abfe7:py_class_d8c3a02ec320, analysis_169ebfd40f3abfe7:py_class_d49faffe09ee, analysis_169ebfd40f3abfe7:py_entry_e19dcd82aa60
c29 The analyzer's suggested learning path: start with manifests and important symbols, then trace the bounded execution path and inspect unresolved boundaries before changing code. inferred supported analysis_169ebfd40f3abfe7:claim_e56db45165bf
c30 The analysis is static only: reflection, runtime dependency injection, dynamic imports, monkey-patching, generated code, framework runtime wiring and dynamic dispatch are not resolved. observed supported analysis_169ebfd40f3abfe7:lim_1
c31 Install/run/build inference is partial and installation commands are not verified, so runtime behavior is unestablished by this analysis. observed supported analysis_169ebfd40f3abfe7:lim_2
c32 README claim extraction is line-based, skipping headings, fenced code, HTML, badges, tables and shell prompts; README-derived statements remain author claims. observed supported analysis_169ebfd40f3abfe7:lim_4a
c33 125702 of the 150000 recorded relations remain external or unresolved. observed supported analysis_169ebfd40f3abfe7:relation_counts
c34 Recorded relations total exactly the documented 150000-per-repository cap (2500 per file also documented), so the recorded relation set is capped. observed supported analysis_169ebfd40f3abfe7:lim_6, analysis_169ebfd40f3abfe7:relation_counts
c35 The packet reports three entrypoint paths with no statically detected call steps; what those entrypoints do is not established. unresolved supported analysis_169ebfd40f3abfe7:claim_38330fcb3baf
c36 The analysis resolves no wiring for how plugin or extension content loads; dynamic imports and framework runtime wiring are outside static resolution. observed supported analysis_169ebfd40f3abfe7:important_4, analysis_169ebfd40f3abfe7:lim_1
c37 models/__init__.py defines known_model_names (lines 120-127), the Model class (lines 454-1149), StreamedResponse (lines 1153-1417) and parse_model_id (lines 1645-1660). observed supported analysis_169ebfd40f3abfe7:py_func_16c786b72118, analysis_169ebfd40f3abfe7:py_class_60a18e1a7082, analysis_169ebfd40f3abfe7:py_class_ff8431d660fe, analysis_169ebfd40f3abfe7:py_func_b20321ee6970
c38 pydantic_ai_slim/pydantic_ai/exceptions.py defines ModelRetry (lines 59-99), ToolFailed (102-149), CallDeferred (152-167), ApprovalRequired (170-185) and RunCancelled (270-449). observed supported analysis_169ebfd40f3abfe7:py_class_d49faffe09ee, analysis_169ebfd40f3abfe7:py_class_eb835e57c589, analysis_169ebfd40f3abfe7:py_class_dcb9c601b016, analysis_169ebfd40f3abfe7:py_class_a42bb6b88176, analysis_169ebfd40f3abfe7:py_class_cb47d788aff7
c39 pydantic_ai_slim/pydantic_ai/messages.py defines SystemPromptPart, FileUrl, VideoUrl, AudioUrl, ImageUrl, DocumentUrl and BinaryContent. observed supported analysis_169ebfd40f3abfe7:py_class_d8c3a02ec320, analysis_169ebfd40f3abfe7:py_class_cbe4737a495b, analysis_169ebfd40f3abfe7:py_class_337a23459368, analysis_169ebfd40f3abfe7:py_class_e8d528a88774, analysis_169ebfd40f3abfe7:py_class_54b4119c54e7, analysis_169ebfd40f3abfe7:py_class_c0fc8af8d1b8, analysis_169ebfd40f3abfe7:py_class_7ec8af3b4ac7

Sources, rights and disclosure · attribution-license-templates/v0.1

Rights notice. Original repository hosted on GitHub. Repository source code, documentation, names, media, and related project materials remain subject to the rights of their respective authors, contributors, and other rights holders and to applicable repository license terms.

Platform notice. GitHub is the source hosting platform for the linked repository. GitHub and related marks are trademarks of GitHub, Inc. EVEMISS Technology is not affiliated with or endorsed by GitHub unless explicitly stated otherwise.

How this page is produced. This page was produced using revision-aware repository analysis and AI-assisted editorial tooling. Technical claims are tied to the analyzed repository revision and may be revalidated when the source repository changes.

AI-assisted analysis. Reviewed by EVEMISS Technology through human–AI collaborative review. · Report a rights concern · All repository guides