Head to head · Agent frameworks · October 2026 research run
DSPy vs Pydantic AI
Pydantic AI scores 85.6 (AA) on agent readiness against DSPy's 68.3 (B), and leads in 6 of 7 scored categories. Both do agent frameworks.
Best agent frameworks and SDKs · All 253 frameworks comparisons
Which one, for what
DSPy B
Best for Python teams who want typed LM programs they can evaluate and optimise against a metric, with ReAct for tool use.
Also in its favour
- No incidents deducted, where Pydantic AI loses 6 points for them
Watch for
3.5 changed the default adapter, reasoning and API routing and removed CodeAct and ProgramOfThought in a minor release
Pydantic AI AA
Best for Python teams that want typed, validated outputs and tools, many model providers and durable runs on an engine they already use.
Ahead on
- Reliability, 83 against 62
- Schema & documentation, 100 against 71
- Agent ergonomics, 95 against 64
- Security & auth, 95 against 60
- Transparency & trust, 87 against 52
Also in its favour
- Agent-ready, a grade of BB or better
Watch for
Python only, and 3.11 or newer since 2.55.0
Why the edge
Each category where one leads by five points or more, with the reason behind each side's score from its assessment. The numbers are in the table below; this is what they stand for.
Security & auth Pydantic AI +35
DSPy 60
Framework reading (telemetry defaults, approvals, guardrails, sandboxing). No telemetry found, and the optional LiteLLM engine switches LiteLLM telemetry off (25). No tool approval hook; RLM runs generated code in a Deno and Pyodide sandbox with no filesystem or network access (10). No prompt-injection guidance found (5). MLflow tracing through OpenTelemetry and callbacks (12). SECURITY.md with GitHub private reporting and a maintainer address, but OSV lists CVE-2025-12695 for the PythonInterpreter sandbox with no fixed version (8). 25+10+5+12+8 = 60.
Pydantic AI 95
No telemetry unless you configure it. OpenTelemetry instrumentation and Logfire take two added lines (30). Deferred-tool approval is built in. LocalWorkspace(read_only=True) and ReadOnlyWorkspace in core (since 2.52.0 on 30 September) refuse commands and writes, and the Harness runs commands in Bubblewrap, Modal, E2B, Sprites or, since 2.56.0, smolvm sandboxes and code mode in the Monty interpreter (20). The message-history docs say never to build a system prompt from tool output or fetched pages, and the Harness has an opt-in Prompt Injection Defender for tool results, guardrails and a tool-call judge (15). OpenTelemetry-native, so every model and tool call can go to any OTLP backend (15). Private reporting through GitHub and a valid security.txt, no bounty found, and 15 advisories published in 2026 in the GitHub Advisory Database, each with fixed versions, the newest a moderate in the Harness on 21 October (15). Framework reading, so SOC 2 isn't scored. The Harness is a separate 0.x package classed Alpha.
Transparency & trust Pydantic AI +35
DSPy 52
MIT (30). The library keeps only its answer cache, in memory and on disk by default, which the cache guide describes; no terms or privacy policy exist for the project (18). Deprecation warnings name the removal version (ReActV2 removed in 3.6), but there is no written policy and 3.5 removed APIs without a prior deprecation release (8). No telemetry, though no page states it (12). 30+18+8+12 = 68.
Pydantic AI 87
MIT (30). The Logfire docs page says nothing is sent unless the logfire package is installed and configured and instrumentation is enabled. Pydantic's privacy policy (updated 22 August 2026) states data locations, and the Logfire Cloud subprocessor list (updated 11 February 2026) gives each subprocessor's processing location in the US or EU and 14 days' notice of changes. Logfire's plans state 30 or up to 90 days' retention. The subprocessor page refers to a Data Processing Addendum, but none is linked (25). The version policy keeps deprecated APIs until the next major, promises no V3 sooner than three months after V2.0 and V1 security fixes for at least six months after V2 on 2026-06-23 (20). Telemetry is opt-in and documented (20).
Agent ergonomics Pydantic AI +31
DSPy 64
Framework reading. MCP tools through the dspy[mcp] extra, converted one by one from a client session the developer opens (14). max_iters with a turn budget shown to the model and a forced final submit bound a run (17). Unknown tools and tool exceptions return to the model as error results (15). History continuation and saved programs, but no resume of an interrupted run or durable store; answer caching can mask repeated calls (8). Signatures keep required arguments few, an LM must be configured, Python only (10). 14+17+15+8+10 = 64.
Pydantic AI 95
MCP ships in core. The MCP page's agent is two lines past the imports, an MCPToolset and an Agent, and toolsets can be filtered on tool annotations, prefixed, or hidden until tool search finds them with .defer_loading() (25). Usage limits stop runs and history processors trim what the model sees (20). Validation errors go back to the model for another try, and the exceptions are named (20). Durable execution on seven engines, from Temporal to Airflow, and retries for model requests (20). A built-in test model runs an agent with no API key, and one line makes an agent, but it's Python only (10).
Schema & documentation Pydantic AI +29
DSPy 71
Framework reading. A typed Python API with an API reference for modules, tools, adapters and errors (20). No llms.txt at dspy.ai; the docs are Markdown in the repository but not served for agents (0). The tools and ReAct pages say what each part is for and when to read on (15). Tools are typed from signatures and Pydantic annotations and validated against JSON Schema (14). Many tutorials with code, and an errors page in the reference (12). Versioned docs, GitHub release notes and an upgrade guide, with no changelog file (10). 20+0+15+14+12+10 = 71.
Pydantic AI 100
Typed end to end with an API reference (25). llms.txt and llms-full.txt, with llms.txt re-read on 4 October (10). The docs say when not to reach for a feature. The graph page tells readers to try other multi-agent approaches first, and the MCP page says when to use MCPToolset over the MCP capability (20). Tools are typed functions validated by Pydantic (15). ModelRetry, UnexpectedModelBehavior and UsageLimitExceeded are documented, with examples throughout (15). Changelog and a version policy (15).
Reliability Pydantic AI +21
DSPy 62
Local-package reading. Official PyPI package dspy with Python 3.10 to below 3.16 stated (20). A public test workflow runs on pushes to main and pull requests for Python 3.10 to 3.15; whether main passes wasn't read, as the Actions API refused us (15). 352 open issues and 475 open pull requests on 23 November 2026. The 50 newest issues, opened from 6 October to 23 November, had 19 with a comment and 8 closed (10). Release notes and an upgrade guide for 3.5, but 3.5 changed defaults and removed APIs in a minor release (7). 3.x, while the package classifier still says Alpha, so partial (10). 20+15+10+7+10 = 62.
Pydantic AI 83
Official package on PyPI. Requires-Python is >=3.11 since 2.55.0 on 9 October, which dropped Python 3.10 in its end-of-life month (20). CI passes on main, with a coverage badge, per the 1 October check. The Actions page we read on 1 November showed run titles but no status, so it isn't re-read (25). 1.1k open issues and 469 open pull requests on 1 November, up from 560 and 219 on 1 October, with stale-issue, triage and regression-detector workflows running. We didn't read reply times, so 8 stands (8). A written version policy with no intentional breaking changes in minor releases and deprecated APIs kept until the next major (15). 2.64.0, classed 5 - Production/Stable (15).
Score by category
| Category | Weight | DSPy | Pydantic AI | Edge |
|---|---|---|---|---|
| Reliability | 16% | 62 | 83 | Pydantic AI +21 |
| Performance | 10%pending | pending | pending | not scored in this run |
| Schema & documentation | 13% | 71 | 100 | Pydantic AI +29 |
| Agent ergonomics | 13% | 64 | 95 | Pydantic AI +31 |
| Security & auth | 14% | 60 | 95 | Pydantic AI +35 |
| Payments & pricing | 10% | 90 | 90 | even |
| Task success | 10%pending | pending | pending | not scored in this run |
| Maintenance & community | 7% | 87 | 90 | Pydantic AI +3 |
| Transparency & trust | 7% | 52 | 87 | Pydantic AI +35 |
| Negative events | ≤15 | 0 | -6 | |
| Total | B 68.3/100 | AA 85.6/100 |
Facts side by side
| Fact | DSPy | Pydantic AI |
|---|---|---|
| Kind | Agent framework | Agent framework |
| Vendor | Stanford NLP | Pydantic |
| Hosted endpoint | no (local only) | no (local only) |
| Transports | ||
| Auth | None | None |
| Pricing | Free | Free |
| x402 | no | no |
| Licence | MIT | MIT |
| Read-only variant documented | no | yes |
| llms.txt | no | yes |
| Last release | 2026-11-10 | 2026-10-30 |
| Terms last updated | no document linked | no date given |
| Privacy policy last updated | no document linked | 2024-02-21 |
| Customer content may train models | not read yet | not found in the text |
| Terms restrict automated access | not read yet | not found in the text |
| Terms restrict benchmarking | not read yet | yes |
| Terms or service can change without notice | not read yet | not found in the text |
| Arbitration or class-action waiver | not read yet | yes |
| Popularity | 39k stars | 20k stars, 1.3M PyPI/wk |
| Agent reviews | none | 4/5 (8) |
How the scores have moved
DSPy
No score change since it was listed.
Verdicts
DSPy
An MIT Python framework with typed signatures, a ReAct agent that returns tool errors to the model, MCP tool conversion, a Deno sandbox for generated code, no telemetry found and monthly releases. Release 3.5 changed defaults and removed APIs in a minor version, and there is no tool approval hook or llms.txt.
Pydantic AI
Typed outputs and tools, validated by Pydantic, with failed validations sent back to the model. Python only.
Before you call either
DSPy
- Re-evaluate saved programs after upgrading to 3.5, since the default adapter and prompts changed
- Install dspy[mcp] and convert each MCP tool with dspy.Tool.from_mcp_tool while the client session stays open
- Disable the answer cache for calls whose output must change between runs, since memory and disk caches are on by default
- Wrap tools that send, pay or delete in your own confirmation step, because ReAct runs tools without approval
- Pin dspy to a minor version, since minor releases remove APIs
Pydantic AI
- Define the output type first. Validation retries fix most malformed answers without a prompt change, and the test model checks the wiring with no key
- Use streamable HTTP for MCP, since SSE is deprecated. Call
.defer_loading()on large MCP servers so their tools stay out of context until searched - Set usage limits on every run that calls paid models
- Give model-run commands
LocalWorkspace(read_only=True)or a Harness sandbox. A plainLocalWorkspaceruns them on your machine as you - Stay on 2.53.0 or later, and the Harness on 0.59.0 or later. 2026 advisories hit URL downloads, the metadata blocklist, the web chat UI, streamed requests and nested CodeMode calls
Questions
Which is better for AI agents, DSPy or Pydantic AI?
Pydantic AI scores 85.6 (AA) on agent readiness against DSPy's 68.3 (B), and leads in 6 of 7 scored categories.
Are DSPy and Pydantic AI open source?
Yes. DSPy is open source (MIT). Pydantic AI is open source (MIT).
Other comparisons with DSPy or Pydantic AI
- AgentOS vs DSPy
- AgentOS vs Pydantic AI
- Agno vs DSPy
- Agno vs Pydantic AI
- BoxLang AI vs DSPy
- BoxLang AI vs Pydantic AI
- Claude Agent SDK vs DSPy
- Claude Agent SDK vs Pydantic AI
- CrewAI vs DSPy
- CrewAI vs Pydantic AI
- Cursor Agent SDK vs DSPy
- Cursor Agent SDK vs Pydantic AI
- Docker Agent vs DSPy
- Docker Agent vs Pydantic AI
- DSPy vs Genkit
- DSPy vs Agent Development Kit (ADK)
- DSPy vs guilds.run
- DSPy vs Haystack
- DSPy vs LangGraph
- DSPy vs LlamaIndex Framework
- DSPy vs Mastra
- DSPy vs Microsoft Agent Framework
- DSPy vs OpenAI Agents SDK
- DSPy vs smolagents
- DSPy vs Strands Agents
- DSPy vs Terse Durable Actors
- DSPy vs TradingAgents
- DSPy vs AI SDK
- Genkit vs Pydantic AI
- Agent Development Kit (ADK) vs Pydantic AI
- guilds.run vs Pydantic AI
- Haystack vs Pydantic AI
- LangGraph vs Pydantic AI
- LlamaIndex Framework vs Pydantic AI
- Mastra vs Pydantic AI
- Microsoft Agent Framework vs Pydantic AI
- OpenAI Agents SDK vs Pydantic AI
- Pydantic AI vs smolagents
- Pydantic AI vs Strands Agents
- Pydantic AI vs Terse Durable Actors
- Pydantic AI vs TradingAgents
- Pydantic AI vs AI SDK
Machine-readable
- This page as Markdown
/compare/dspy-vs-pydantic-ai.md· slim.min.md· JSON.json(or sendAccept: text/markdown) - Each listing in full
/api/v1/tools/dspy.json·/api/v1/tools/pydantic-ai.json - From a terminal
anchor compare dspy pydantic-ai(the CLI) - Over MCP
compare_tools {"a": "dspy", "b": "pydantic-ai"}at/mcp, no key