Key Takeaways
- MIT license — free to use, modify, and self-host, including commercially
- GitHub repository stanfordnlp/dspy has passed 37,900 stars and 3,300 forks (started at Stanford NLP in December 2022)
- PyPI package
dspy, current release 3.3.1 (August 21, 2026) — actively maintained - Core abstractions: Signatures (typed I/O), Modules (Predict, ChainOfThought, ReAct), Optimizers (BootstrapFewShot, MIPROv2, GEPA)
- Category: prompt/weight optimization for LLM programs — not a multi-agent orchestration framework like LangChain or CrewAI
- Install:
pip install dspy, requires configuring an LLM provider before running a program
📍 In One Sentence
DSPy is a free, MIT-licensed Python framework from Stanford NLP that lets developers program LLM tasks with typed Signatures and Modules, then automatically optimizes the prompts and few-shot examples with algorithms like MIPROv2 instead of manual prompt engineering.
💬 In Plain Terms
DSPy lets you describe what you want an LLM to do — inputs, outputs, the steps — as code, and then it searches for the best actual prompt wording for you by testing options against examples, rather than you guessing and hand-editing prompt text.
📌Note: DSPy solves a different problem than most agent frameworks in this series — it optimizes the prompts inside a pipeline rather than orchestrating multi-agent conversations. See the Local LLM Software Directory for how DSPy fits among agent and pipeline frameworks.
From Stanford Research to Production Framework
Stanford NLP began developing DSPy in December 2022, and the stanfordnlp/dspy GitHub repository describes it as "the framework for programming—rather than prompting—language models." The project grew out of academic research into compiling declarative LLM pipelines rather than hand-writing prompt strings.
The framework introduced Signatures and Modules as its core abstractions early on, then expanded its optimization algorithms over time: BootstrapFewShot for fast few-shot example selection, followed by MIPROv2, which jointly searches instructions and few-shot examples using Bayesian optimization, and more recently GEPA, described in the documentation as tuning prompts automatically "until quality converges" from a set of examples and a scoring function.
DSPy is under active development as of this review: the dspy package on PyPI was at version 3.3.1, released August 21, 2026. The project's own site reports more than 454 contributors and documents production use at companies including Shopify, Databricks, and AWS.
Unlike several other frameworks in this series, DSPy has not been archived, has not entered a stated maintenance-only mode, and has no announced successor project — it is the actively developed, canonical implementation of the ideas it introduced.
Development begins at Stanford NLP
- Date:
- 2022-12
- What it means:
- The stanfordnlp/dspy repository and the core Signature/Module abstractions originate
BootstrapFewShot optimizer
- Date:
- Early releases
- What it means:
- A fast baseline optimizer bootstraps few-shot examples from a training set
MIPROv2 optimizer
- Date:
- Later releases
- What it means:
- Joint instruction + few-shot example search via Bayesian optimization ships
GEPA optimizer
- Date:
- Recent releases
- What it means:
- A newer optimizer for automatic prompt tuning against a scoring function
dspy 3.3.1 on PyPI
- Date:
- 2026-08-21
- What it means:
- Latest verified release as of this review — active development continues
📌Note: DSPy's PyPI package name has a history worth knowing: the name dspy was originally taken on PyPI, so the project shipped as dspy-ai for its early releases. The canonical package name is now dspy — use pip install dspy for current installs.
What Is DSPy?
DSPy is an open-source Python framework (MIT license, actively maintained, github.com/stanfordnlp/dspy) built by Stanford NLP for programming language model tasks declaratively, then compiling those declarations into optimized prompts — and optionally optimized weights — instead of a person manually iterating on prompt text.
- Signature: a typed definition of a task's inputs and outputs, written as a short class or string (for example,
"question -> answer"), portable across different underlying LLMs and prompt strategies - Module: a component that implements an execution strategy around a Signature —
Predictfor direct completion,ChainOfThoughtfor step-by-step reasoning,ReActfor tool-using reasoning loops, and others - Optimizer (formerly called a teleprompter): an algorithm that tunes the prompts and few-shot examples inside a DSPy program against a metric, automatically, instead of by hand — named optimizers include
BootstrapFewShot,MIPROv2, andGEPA - Compiling a program: running an optimizer over a training set and a scoring function produces a compiled program with tuned instructions and examples baked in, which you then run like any other DSPy program
- Model-agnostic: DSPy connects to the LLM provider you configure rather than shipping a built-in model, and the same Signature/Module code can be re-optimized for a different underlying model
- Not a multi-agent orchestrator: DSPy has no built-in concept of multiple communicating agents the way CrewAI or AutoGen do — a DSPy program is typically a single pipeline of Modules, though
ReActmodules can call tools in a reasoning loop
pip install dspy
# Minimal example: a Signature + Module + Optimizer
import dspy
class AnswerQuestion(dspy.Signature):
"""Answer a question factually."""
question: str = dspy.InputField()
answer: str = dspy.OutputField()
qa = dspy.ChainOfThought(AnswerQuestion)
result = qa(question="What is the capital of France?")
print(result.answer)How Much Does DSPy Cost?
DSPy itself is free under the MIT license — there is no subscription, paid tier, or Stanford-hosted service to pay for. You pay for your own compute plus any API fees from whichever LLM provider you configure.
- DSPy (the open-source framework): free forever under the MIT license, self-hosted, no usage caps, no account required to run it
- No hosted product or subscription: DSPy is a library you import and run yourself, not a managed service — there is nothing to subscribe to
- Optional cost: API fees from your configured LLM provider (for example, per-token pricing from a cloud provider) if you connect a cloud model instead of a local one
- Optimizer cost consideration: running an optimizer like MIPROv2 makes multiple LLM calls to search for the best prompt configuration, so compiling a program has its own API-call cost on top of running the compiled program afterward
How Do You Install and Get Started With DSPy?
Install DSPy from PyPI with pip install dspy. No cloning, no Docker, and no separate CLI binary are required — DSPy is used as a regular Python import.
- 1Install the package:
pip install dspy. - 2Configure an LLM provider — for example,
dspy.configure(lm=dspy.LM('openai/gpt-4o-mini', api_key='your-key'))for a hosted model, or point it at a locally served OpenAI-compatible endpoint. - 3Define a Signature describing your task's inputs and outputs, either as a short string (
"question -> answer") or a typed class withdspy.InputField()/dspy.OutputField(). - 4Wrap the Signature in a Module —
dspy.Predict(...)for a direct call, ordspy.ChainOfThought(...)for step-by-step reasoning — and call it like a function. - 5Optional: assemble a small training set and a scoring function, then run an optimizer such as
dspy.BootstrapFewShotordspy.MIPROv2to compile a tuned version of your program. - 6See the DSPy documentation for the full tutorial set, including RAG pipelines, agent loops with
ReAct, and optimizer configuration.
Do I need Docker or a GPU to run DSPy?
No. DSPy is a Python library that calls an LLM provider you configure — it does not require Docker or local GPU hardware unless you are separately running a local model server.
Does DSPy work with local models?
Yes, if the local model is served through an OpenAI-compatible or otherwise supported endpoint that you point DSPy's LM configuration at — DSPy itself does not ship a built-in model.
Who Should Use DSPy?
DSPy fits developers who are already writing LLM pipelines in Python and want the prompts inside those pipelines tuned against measurable results instead of by manual trial and error. It is a narrower fit for teams that primarily need multi-agent coordination or a no-code interface.
When Should You NOT Use DSPy?
Skip DSPy when your task is really about coordinating multiple agents or wiring together third-party tool integrations, rather than optimizing the prompt inside a single pipeline.
- A team that needs a visual, no-code workflow builder — DSPy is code-first with no drag-and-drop interface
- A project that is fundamentally multi-agent coordination (agents delegating sub-tasks to each other) — a framework purpose-built for that pattern, like CrewAI or AutoGen, is a better structural fit
- A one-off script where a single hand-written prompt already performs well enough — introducing Signatures, Modules, and an optimization loop adds engineering overhead that only pays off when you need measurable, repeatable prompt improvement
- A task with no way to score correctness — DSPy's optimizers require a metric function, so tasks that are purely subjective with no labeled examples get little benefit from the optimization step
- Use DSPy instead specifically when you have a pipeline, a metric, and a training set, and want the prompt-engineering step automated and reproducible
DSPy vs. Alternatives
DSPy occupies a different category from most agent-orchestration frameworks: it optimizes prompts and few-shot examples inside a pipeline rather than coordinating multiple agents. The closest points of comparison are other Python frameworks for building LLM pipelines, even though their core jobs differ from DSPy's.
Tool | Core Job | License | Status | Best For |
|---|---|---|---|---|
| DSPy | Prompt/weight optimization | MIT | Active | Tuning prompts against a metric |
| LangChain | General LLM pipeline building | MIT | Active | Broadest integration ecosystem |
| LlamaIndex | RAG-focused data framework | MIT | Active | Retrieval-augmented pipelines |
| Semantic Kernel | Structured prompt/skill composition | MIT | Active (converging into MAF) | Enterprise .NET/Python/Java SDK |
This table compares DSPy against Python pipeline frameworks with the closest conceptual overlap, not multi-agent orchestrators — DSPy does not compete directly with CrewAI or AutoGen, which solve agent coordination rather than prompt optimization.
Common Mistakes When Evaluating DSPy
These mistakes come from treating DSPy like a multi-agent framework, or skipping the optimization step that is the actual point of the framework.
Frequently Asked Questions
Is DSPy still maintained?
Yes. The stanfordnlp/dspy repository is under active development; the dspy package on PyPI was at version 3.3.1, released August 21, 2026, as of this review.
Is DSPy free to use?
Yes. DSPy is MIT licensed and free for commercial use, modification, and self-hosting. There is no subscription or hosted product to pay for.
What is the difference between DSPy and LangChain?
LangChain is a general-purpose framework for building LLM pipelines with a broad integration ecosystem; DSPy focuses specifically on programming tasks with typed Signatures and Modules, then automatically optimizing the prompts and few-shot examples against a metric. They solve different, complementary problems.
What are DSPy Signatures and Modules?
A Signature is a typed definition of a task's inputs and outputs (for example, "question -> answer"). A Module implements an execution strategy around a Signature — Predict for direct completion, ChainOfThought for step-by-step reasoning, ReAct for tool-using reasoning loops.
What are DSPy optimizers?
Optimizers, formerly called teleprompters, are algorithms that automatically tune the prompts and few-shot examples inside a DSPy program against a metric and training set — named optimizers include BootstrapFewShot, MIPROv2, and GEPA.
How do I install DSPy?
Run pip install dspy. That is the canonical current PyPI package name; an older dspy-ai package predates it.
Does DSPy replace multi-agent frameworks like CrewAI or AutoGen?
No. DSPy optimizes prompts inside a pipeline; it does not orchestrate multiple communicating agents the way CrewAI or AutoGen do. The two categories are complementary rather than competing.
What license is DSPy released under?
MIT, which permits free commercial use, modification, and self-hosting.
Who built DSPy?
DSPy was built at Stanford NLP, with development starting in December 2022. The project reports more than 454 contributors and documented production use at companies including Shopify, Databricks, and AWS.
How many GitHub stars does DSPy have?
The stanfordnlp/dspy repository has passed 37,900 GitHub stars and 3,300 forks, as of September 2026.
