# DSPy

> The framework for programming, not prompting, language models

Source: https://talira.ai/catalog/dspy-ggnsjfgw
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Framework, Library
- Categories: [ai / agents / frameworks](https://talira.ai/categories/ai/agents/frameworks), [ai / llm / prompt optimization](https://talira.ai/categories/ai/llm/prompt-optimization)
- Licence: MIT[^1]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Self-hostable: yes[^2]
- Supports: [MCP](https://talira.ai/standards/mcp.md)[^3]
- Backed by: [Stanford NLP Group](https://talira.ai/orgs/stanford-nlp.md)

DSPy (Declarative Self-improving Python) is a Python framework from Stanford NLP for building AI systems out of modular code instead of hand-written prompts. You declare what each step takes and returns as a signature, compose modules (chain of thought, ReAct agents, RAG and your own), and let DSPy's optimizers, such as GEPA and the BootstrapFewShot family, tune the prompts and few-shot examples, or fine-tune the weights, against a metric you define. It covers classifiers, extraction, RAG pipelines and agent loops, with tools and MCP, adapters that turn signatures into prompts, caching, streaming and async.

## Links

- Website: https://dspy.ai/
- GitHub: https://github.com/stanfordnlp/dspy
- Docs: https://dspy.ai/

## Problems it solves

- my LLM prompts are brittle and break whenever I change models
- automatically optimize the prompts and few-shot examples in my LLM pipeline against a metric
- write LLM pipelines as composable Python modules instead of long prompt strings
- improve a RAG pipeline's answer quality without hand-tuning every prompt
- build a ReAct agent with tools in Python and tune it on my own examples
- fine-tune a smaller model to match my LLM program's outputs
- get structured typed outputs from an LLM by declaring inputs and outputs
- evaluate an LLM program on a dataset and compare optimizers

## Features

- Signatures declare a step's inputs and outputs instead of a prompt
- Composable modules: Predict, ChainOfThought, ReAct and custom modules
- Optimizers including GEPA and the BootstrapFewShot family tune prompts and examples
- Fine-tuning and experimental RL optimization of weights
- Metrics and evaluation utilities
- Tools and MCP support for agents
- Adapters (Chat, JSON, XML) that turn signatures into prompts
- Caching, streaming, async and saving and loading programs
- Observability and optimizer tracking

## Trust

Overall: 0.27 out of 1.
Signals: backing 0.30, extensibility 0.00.

- backed by Stanford NLP Group

Warnings:

- GitHub activity not fetched yet

## Alternatives

- [LlamaIndex](https://talira.ai/catalog/llamaindex-qn17jtyq.md): A Python toolkit for building LLM-powered agents over your data
- [LangChain](https://talira.ai/catalog/langchain-x3527dp4.md): A framework for building agents and LLM-powered applications
- [Haystack](https://talira.ai/catalog/haystack-11a8e5d9.md): Open-source AI orchestration framework for building production-ready LLM applications in Python

## Sources

[^1]: https://github.com/stanfordnlp/dspy/blob/main/LICENSE (checked 22 Nov 2026)
[^2]: https://github.com/stanfordnlp/dspy (checked 22 Nov 2026)
[^3]: https://dspy.ai/ (checked 22 Nov 2026)
