Agent frameworks

DSPy

Treats prompts as parameters to be optimised against a metric instead of hand-tuned strings.

Visit dspy.ai ↗

Pricing
Open source
Runs
Self-hosted
Languages
Python
Interface
Library
Source
Open source

What DSPy is

DSPy reframes prompting as an optimisation problem. You declare what a step should do and supply a metric and examples; DSPy compiles the prompts, and can re-optimise when you change model. The payoff is that prompt quality stops being craft you redo by hand every time the model changes.

Best for

Tasks with a measurable metric and enough examples to optimise against, where hand-tuned prompts keep drifting.

Consider something else if

The mental model is genuinely different from prompt-writing, and it needs a dataset and a metric before it does anything for you.

DSPy alternatives

The closest options in agent frameworks, on the axes that actually separate them.

DSPy compared with 5 alternatives
ToolBest forPricingRuns
DSPyopen sourceTasks with a measurable metric and enough examples to optimise against, where hand-tuned prompts keep drifting.Open sourceSelf-hosted
Pydantic AIopen sourcePython teams already using Pydantic who want type safety and a framework small enough to hold in your head.Open sourceSelf-hosted
LangChainopen sourceProjects that benefit from breadth of integrations, and teams who want explicit stateful graphs via LangGraph.Open sourceHosted or self-hosted
Claude Agent SDKopen sourceFilesystem- and shell-shaped agents where the built-in tool set is most of what you need.Open sourceSelf-hosted
LlamaIndexopen sourceRetrieval-heavy applications where document ingestion and indexing are the hard part.Open sourceHosted or self-hosted
Mastraopen sourceTypeScript and Node teams who want a framework designed for their stack instead of a translated one.Open sourceHosted or self-hosted

Choosing within agent frameworks

Language, honestly

Most of this category is Python-first. If your service is TypeScript, the shortlist is genuinely shorter, and a thin layer over the provider SDK is often better than a half-maintained port.

How much it hides

Some frameworks give you primitives you compose; others give you an agent you configure. The second is faster to a demo and harder to debug at depth. Match this to how much novel behaviour you expect to need.

The full guide to agent frameworks →

Questions

What is DSPy?

DSPy reframes prompting as an optimisation problem. You declare what a step should do and supply a metric and examples; DSPy compiles the prompts, and can re-optimise when you change model. The payoff is that prompt quality stops being craft you redo by hand every time the model changes. It is open source and self-hosted.

What are the alternatives to DSPy?

The closest alternatives are Pydantic AI, LangChain, Claude Agent SDK, LlamaIndex, Mastra. They sit in the same category — agent frameworks — and differ mainly on hosting model, pricing shape, and how much they abstract away.

Is DSPy the right choice?

Tasks with a measurable metric and enough examples to optimise against, where hand-tuned prompts keep drifting. The main caveat: The mental model is genuinely different from prompt-writing, and it needs a dataset and a metric before it does anything for you.