
DSPy
A Python framework that uses typed signatures and reusable modules to build optimizable language-model programs.
About DSPy
DSPy is a Python framework for building AI systems as modular programs instead of collections of hand-written prompts. Developers declare typed signatures for inputs and outputs, then choose reusable modules that control how a language model reasons, calls tools, or returns structured results. Its adapters cover chat, JSON, two-step, and XML interaction patterns, while the model layer includes language-model and embedding interfaces. Separating task definitions from execution strategy makes it easier to change models or workflows without rebuilding the application around prompt strings. DSPy also supports agents such as ReAct and can work with tracing tools during development. It suits Python teams prepared to define program structure, maintain evaluations, and operate the underlying model services. The framework uses the MIT license and requires Python 3.10 or later. Teams still need examples or evaluation criteria for optimization, must learn DSPy abstractions, and remain responsible for provider usage, reliability, and operating costs.
Best for
Best use cases
A support workflow needs typed urgency and routing outputs while keeping execution strategy replaceable.
A retrieval system needs an automated relevance judge plus repeatable offline evaluation and optimization.
An agent must call tools across multiple steps while developers inspect traces during iteration.
Compare before choosing
Compared with raw prompt scripts, DSPy adds typed signatures and reusable execution modules but requires learning its abstractions.
Compared with a hosted no-code builder, DSPy gives Python-level control while leaving deployment and model operations to the team.
Compared with a single-provider SDK, DSPy offers model-facing abstractions, though provider costs and behavior still affect production results.
Features
Structured extraction
Declare typed input and output fields for extracting events or details from text.
Retrieval and ranking
Compose retrieval, relevance judging, and offline evaluation as modular workflows.
Tool-using agents
Build multi-step agents that call tools and expose traces during development.
Pros
- Typed signatures make expected inputs and outputs explicit, which improves maintainability when workflows change.
- Reusable modules and adapters let teams change reasoning or output strategies without rewriting the task definition.
- The MIT license and Python package make the framework accessible for internal experiments and production engineering.
Cons
- Teams must learn DSPy signatures, modules, adapters, and optimization concepts before they can use the framework effectively.
- Running production systems still requires separate model access, deployment, monitoring, and control of provider usage costs.
- Optimization is most useful when a team can supply representative examples or evaluation criteria, adding preparation work.
Pricing Plans
Subscription
- Python framework for modular AI programs
- Signatures, modules, adapters, and model interfaces
- Agent and optimization workflows
* Pricing information is for reference only. Please refer to the latest announcement on DSPy's official website.