DSPy
Stanford's framework for programming, not prompting, language models, with optimisers for prompts and weights.
Sources and review
Checked against public documentation on . Suitability guidance is our editorial judgment; this is not a performance benchmark or an endorsement.
Systems where you can define a metric and want prompts tuned automatically instead of by hand.
About DSPy
DSPy (Declarative Self-improving Python) replaces hand-written prompts with compositional Python modules and provides algorithms that optimise a program's prompts and weights against your metric. It is used for classifiers, RAG pipelines and agent loops alike.
DSPy is an open-source project written primarily in Python, with 38k stars on GitHub. It was last updated in September 2026.
pip install dspy