Skip to main content
PromptQuorumBuilt for humans. Structured for AI.
Home/Power Local LLM/DSPy Review: Features, Optimizers, Alternatives
Local AI Agents & Tool Use

DSPy Review: Features, Optimizers, Alternatives

·11 min read·By Hans Kuepper · Founder of PromptQuorum · Discovery engine for open-weight & open-source AI

DSPy is a free, open-source (MIT licensed) Python framework built by Stanford NLP for programming, rather than prompting, language models, available at the stanfordnlp/dspy GitHub repository. Developers define typed Signatures describing a task's inputs and outputs, compose them into Modules (Predict, ChainOfThought, ReAct, and more) that control execution strategy, and run an Optimizer — BootstrapFewShot, MIPROv2, or GEPA — that automatically searches for the instruction wording and few-shot examples that score best against a metric, instead of a person hand-tuning a prompt string. The repository has passed 37,900 GitHub stars and 3,300 forks, ships as the dspy package on PyPI (pip install dspy, current release 3.3.1), and is under active development, with documented production use at companies including Shopify, Databricks, and AWS.

DSPy is a free, open-source (MIT licensed) Python framework from Stanford NLP for programming, not prompting, language models, available at the stanfordnlp/dspy GitHub repository. Instead of hand-writing and hand-tuning prompt strings, developers define typed Signatures (a task's inputs and outputs), compose them into Modules (Predict, ChainOfThought, ReAct, and others), and run an Optimizer — such as BootstrapFewShot or MIPROv2 — that automatically searches for the prompt wording and few-shot examples that score best against a metric on a training set. DSPy does not orchestrate multi-agent conversations the way LangChain or CrewAI do; it optimizes the prompts and, optionally, the weights inside whatever pipeline you build.

DSPy Review: Features, Optimizers, Alternatives

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 — Predict for direct completion, ChainOfThought for step-by-step reasoning, ReAct for 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, and GEPA
  • 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 ReAct modules can call tools in a reasoning loop

Programming, not prompting — what that phrase means in practice

In DSPy, you do not write a prompt string and iterate on its wording by hand. You describe the task's shape with a Signature and pick a Module that defines the reasoning strategy; the actual prompt text sent to the LLM is generated and, when you compile with an Optimizer, tuned automatically. This is the framework's core positioning difference from prompt libraries and orchestration frameworks that treat the prompt string itself as the unit you author.

python
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.

  1. 1
    Install the package: pip install dspy.
  2. 2
    Configure 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.
  3. 3
    Define a Signature describing your task's inputs and outputs, either as a short string ("question -> answer") or a typed class with dspy.InputField() / dspy.OutputField().
  4. 4
    Wrap the Signature in a Module — dspy.Predict(...) for a direct call, or dspy.ChainOfThought(...) for step-by-step reasoning — and call it like a function.
  5. 5
    Optional: assemble a small training set and a scoring function, then run an optimizer such as dspy.BootstrapFewShot or dspy.MIPROv2 to compile a tuned version of your program.
  6. 6
    See the DSPy documentation for the full tutorial set, including RAG pipelines, agent loops with ReAct, and optimizer configuration.

Legacy package name

Older tutorials and some existing codebases reference pip install dspy-ai — that was the original PyPI name before the project reclaimed the dspy name. New installs should use pip install dspy.

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.

Use DSPy if

  • You have a Python LLM pipeline and a way to score its outputs — DSPy's optimizers need a metric and a training set to search against
  • You want prompts and few-shot examples to be generated and tuned programmatically, reproducibly, and re-optimizable when you switch the underlying model
  • You are comfortable defining tasks as typed Signatures and composing Modules in code, rather than working in a no-code visual builder
  • Your task benefits from structured reasoning strategies like ChainOfThought or tool-using loops like ReAct, and you want those strategies tuned rather than hand-prompted

Avoid DSPy if

  • You need multi-agent orchestration — multiple LLM agents communicating, delegating, and coordinating tasks — that is the core job of CrewAI, AutoGen, or LangGraph, not DSPy
  • You need a no-code or low-code interface — DSPy is a Python library with no visual builder, unlike tools such as Langflow or Flowise
  • You don't have labeled examples or a scoring function for your task — DSPy's optimizers need something to measure against, so without that, you are back to writing prompts by hand anyway
  • You need the broadest possible ecosystem of pre-built integrations (document loaders, vector store connectors, agent tools) — LangChain has a larger integration surface for that purpose

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
DSPyPrompt/weight optimizationMITActiveTuning prompts against a metric
LangChainGeneral LLM pipeline buildingMITActiveBroadest integration ecosystem
LlamaIndexRAG-focused data frameworkMITActiveRetrieval-augmented pipelines
Semantic KernelStructured prompt/skill compositionMITActive (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.

Compare in directory

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.

Mistake 1: Expecting DSPy to orchestrate multiple agents

DSPy's Modules compose into a single pipeline, not a team of communicating agents. Teams that need agents delegating sub-tasks to each other should evaluate CrewAI, AutoGen, or LangGraph instead — DSPy can optimize the prompts inside a step of one of those pipelines, but it is not a replacement for the orchestration layer itself.

Mistake 2: Never running an optimizer

Writing Signatures and Modules without ever compiling the program with an optimizer like BootstrapFewShot or MIPROv2 skips the part of DSPy that actually improves on hand-written prompts — a Module run with default, un-optimized prompting can underperform a carefully hand-tuned prompt in a traditional workflow.

Mistake 3: Confusing dspy-ai and dspy on PyPI

Older tutorials reference pip install dspy-ai, the project's original PyPI package name from before it reclaimed the shorter dspy name. Current installs should use pip install dspy to get the maintained, up-to-date package.

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.

Sources

← Back to Power Local LLM