Skip to content

Menu

DSPy logo

DSPy

Published

AI Agents

At a glance

What it is
DSPy is an open-source Python framework for building applications on top of language models.
Price from
Open source Details
Best for
Python teams building multi-step LLM pipelines; Projects with a clear metric and labeled examples
Official site
dspy.ai
Last checked
November 2026
Watch out for
Optimizers need a metric you write and a set of training examples, so they are of little use before you can measure quality.

DSPy is an open-source Python framework for building applications on top of language models. Its own tagline sums up the idea: program, don't prompt, your LLMs. The project lives under the Stanford NLP organization on GitHub and is released under the MIT license. Instead of writing long prompt strings by hand, you describe each task as a signature with typed inputs and outputs, and DSPy turns that into calls to a model.

In practice, developers write small Python programs out of modules. A module decides how a signature runs. It might ask for a direct prediction, ask the model to reason step by step, or run a ReAct loop that calls tools. Modules compose with ordinary Python code, so a classifier, a RAG pipeline and an agent loop all use the same building blocks. Once a program works, you can hand it to an optimizer along with a metric and some examples, and the optimizer tunes the instructions (and, for some optimizers, weights) to score better on that metric.

Install is a single pip command, and the docs list Python 3.10 or later. The examples on the official site use OpenAI models, but the site does not publish a full list of supported providers. One caveat for existing users: the README says the LM layer now uses bundled native lm15 engines with no LiteLLM runtime dependency or fallback, and it links a migration guide covering breaking changes to provider options, custom LMs, text completions and embeddings. Check that guide before upgrading an older project.

Key features

Signatures
You declare a task as typed inputs and outputs, for example an email in and an event name and date out, rather than writing a prompt string.
Modules
Strategies such as direct prediction, step-by-step reasoning and ReAct tool loops decide how a signature is executed.
Plain Python composition
Modules combine with normal Python code, so larger programs like RAG pipelines and agent loops stay readable and testable.
Optimizers
Optimizers tune a program against a metric you define and a set of examples, covering both prompts and weights according to the README.
GEPA reflective optimization
GEPA runs your program, scores outputs with your metric, and uses a separate reflection model to propose better instructions until a budget runs out.
Budget presets
GEPA exposes an auto setting where light evaluates about six candidate prompts and medium or heavy evaluate more.
MIT license
The code is free to use and modify under the MIT license.

Pricing

As of November 2026, DSPy is free and open source under the MIT license, installed with pip. There is no paid plan on the official site. You pay your model provider for every call your program makes, and optimization runs add calls on top of normal usage.

Best for

  • Python teams building multi-step LLM pipelines
  • Projects with a clear metric and labeled examples
  • RAG and agent loops that need repeatable prompt tuning
  • Developers tired of hand-editing prompt strings

Limitations

  • Optimizers need a metric you write and a set of training examples, so they are of little use before you can measure quality.
  • Optimization multiplies model calls, since GEPA scores every candidate on the validation set and also calls a reflection model.
  • The docs note that parallel threads may need lowering to stay within provider rate limits during optimization.
  • The move to native lm15 engines brought breaking changes to provider options, custom LMs, text completions and embeddings, per the README's migration notice.
  • It is a Python library only, requiring Python 3.10 or later.

Verdict

DSPy suits developers who want to treat LLM work like software, with declared interfaces and a measurable target. It asks for upfront effort: you need examples and a metric before the optimizers pay off, and runs cost extra model calls. For teams that can supply those, it replaces a lot of prompt guesswork with a repeatable process.

Sources

Written from the vendor's own site and documentation, checked November 2026. We have no paid relationship that affects what this page says.

How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…