DSPy
Frameworks Open source (MIT)
GitHub stars38.7k
Forks3.4k
LicenseMIT
Last activityOct 20, 2026
Open issues809
Repository: stanfordnlp/dspy ยท Data checked Oct 2026
About
DSPy is Stanford's framework for programming language-model software declaratively instead of hand-tuning prompts. You define your agent as Python modules like ChainOfThought and ReAct, then DSPy's optimizers compile better prompts and few-shot examples automatically from your data. It flips the usual workflow: you declare what good looks like, and the framework figures out the wording. MIT licensed, pip install, and the closest thing to a compiler for agent behavior.
Details
Open source. You run it yourself.
Auth: Open source (MIT)
Rate limit: None, runs locally (uses your model API)
Verified: 2026-09-19
Best for: developer
Setup
- Run pip install dspy
- Define your task as a DSPy signature: inputs in, outputs out
- Build a small training set of example input-output pairs
- Run an optimizer and let it compile the best prompt for your task
Example
pip install dspyUse cases
- Replace fragile hand-written prompts with optimized programs
- Systematically improve agent quality with training data
- Build ReAct agents with compiled few-shot examples