Skip to main content
DSPy logo

DSPy

Framework for programming language models instead of prompting them

agent-frameworks#prompt-optimization#llm-programming#rag#open-source
Free plan Claimed Self-hosted

About DSPy

DSPy is a Stanford NLP open-source Python framework that treats LLM development as programming, compiling declarative modules into automatically optimized prompts and weights.

DSPy (Declarative Self-improving Python) reframes LLM development as programming rather than prompting. Developers write declarative modules with input-output signatures, specify how the model should reason and define metrics for quality, and DSPy's optimizers search for the best few-shot examples, instructions and configurations automatically. This shifts brittle, manually tuned prompts into a compiled, testable software artifact. Maintained by Omar Khattab and the Stanford NLP group with contributions from a broad research community, DSPy has grown to roughly 34,000 GitHub stars and is on its 3.x line as of 2026. It is MIT-licensed and free to use. The framework is popular for RAG systems, structured extraction, classification and agent pipelines where reproducible, optimizable behavior matters more than one-off prompt crafting.

TL;DR

DSPy is Stanford NLP's open-source framework that compiles declarative modules into optimized prompts, replacing manual prompt engineering.

Company overview

DSPy is a research-driven open-source project from the Stanford NLP group rather than a commercial company. It is led by Omar Khattab with a large community of contributors, and is distributed free under the MIT license.

By 2026 the project reached roughly 34,000 GitHub stars and the 3.x release line, cementing its role as a leading framework for optimizable LLM programs.

Product features

DSPy lets developers define signatures and modules describing tasks, then uses optimizers to search for the best instructions and few-shot examples against a metric. This turns prompt engineering into a compiled, reproducible workflow.

It supports classifiers, RAG pipelines and agent loops, integrates with major model providers and vector stores, and emphasizes measurable quality over ad hoc prompt tweaking.

Target market

DSPy targets ML and NLP engineers, researchers and technical teams building reproducible, optimizable LLM pipelines in Python.

Buyer personas

End users

ML and NLP engineers building LLM pipelines.

Buyers

Engineering leads standardizing on an LLM framework.

Key influencers

AI researchers and open-source contributors.

Ideal customer profile

Technical teams building RAG and reasoning systems that need reproducible, automatically optimized prompts.

Funding & performance

DSPy is an academic open-source project and is not independently venture-funded; verify any commercial or institutional backing directly.

Pros & cons

Pros

  • Removes brittle manual prompt engineering
  • Automatic prompt and few-shot optimization
  • Modular, composable and testable
  • Backed by Stanford NLP research
  • Free and MIT-licensed
  • Large and active community

Cons

  • Steeper conceptual learning curve
  • Python-only
  • Optimization runs can be compute-intensive
  • Less suited to simple single prompts
  • Requires defining good metrics

Pricing plans

Open Source
$0
  • Full framework
  • Prompt and weight optimizers
  • Provider and vector-store integrations
  • Community support

Key features

Self-hosted
Integrations
OpenAI, Anthropic, Hugging Face, local models, vector databases
Input types
text
Output types
text
Best For
RAG pipelines, prompt optimization, LLM researchers

Compare key features

View all alternatives →
Feature
DSPy
Agno
Haystack
Pricing
Free
Freemium
Freemium
Free plan
Yes
Yes
Yes
Free trial
No
Yes
No
API
No
Yes
Yes
Self-hosted
Yes
Yes
Yes
Team support
No
Yes
Yes

Frequently asked questions

What does DSPy stand for?+

Declarative Self-improving Python, reflecting its declarative, self-optimizing approach to programming language models.

Is DSPy free?+

Yes. DSPy is open source under the MIT license; costs come only from the underlying model APIs or compute you use.

Who maintains DSPy?+

It is maintained by Omar Khattab and the Stanford NLP group with contributions from a wider research community.

What is DSPy used for?+

Building modular LLM systems such as RAG pipelines, classifiers and agents with automatically optimized prompts.

How is DSPy different from prompt templates?+

Instead of hand-writing prompts, you declare modules and metrics and let DSPy compile and optimize the prompts for you.

Reviews (0)

Write a review

Pick a rating
Loading reviews…
Compare

Compare DSPy with other AI tools

Side-by-side pages for pricing, features, and best-fit use cases.

All comparisons →

Similar tools you may like