The framework for programming—rather than prompting—language models.
Actively maintained. Last release 3 weeks ago, commits in 25 of the last 26 weeks. A safe choice.
pip install dspy
DSPy: Programming—not prompting—Foundation Models
Documentation: DSPy Docs
DSPy is the framework for programming—rather than prompting—language models. It allows you to iterate fast on building modular AI systems and offers algorithms for optimizing their prompts and weights, whether you're building simple classifiers, sophisticated RAG pipelines, or Agent loops.
DSPy stands for Declarative Self-improving Python. Instead of brittle prompts, you write compositional Python code and use DSPy to teach your LM to deliver high-quality outputs. Learn more via our official documentation site or meet the community, seek help, or start contributing via this GitHub repo and our Discord server.
Documentation: dspy.ai
Please go to the DSPy Docs at dspy.ai
Installation
pip install dspy
To install the very latest from main:
pip install git+https://github.com/stanfordnlp/dspy.git
The current LM integration uses bundled native lm15 engines, without a LiteLLM runtime dependency or fallback. See the LM migration guide for breaking changes to provider options, custom LMs, text completions, and embeddings.
📜 Citation & Reading More
If you're looking to understand the framework, please go to the DSPy Docs at dspy.ai.
If you're looking to understand the underlying research, this is a set of our papers:
[Jul'25] GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning [Jul'24] [Jun'24] [Feb'24] [Jan'24] [Dec'23] [Dec'22]