What is DSPy?
DSPy replaces hand-written prompts with modular programs. Declaratively define AI pipelines that are automatically compiled into optimized prompts. Built by Stanford NLP.
In one sentence: Programmatic LLM framework — declaratively define AI pipelines and auto-compile to optimized prompts. By Stanford NLP — 22k+ stars.
For: AI engineers building reliable LLM pipelines.
Core Concepts
1. Signatures
Declare input/output format.
2. Modules
Composable LLM call units, similar to PyTorch layers.
3. Optimizers
Automatically compile to generate optimal prompts.
FAQ
Q: Does it support Claude?
A: Yes — via dspy.LM("anthropic/claude-sonnet-4-20250514").
Q: How is it different from LangChain? A: LangChain chains hand-written prompts; DSPy automatically optimizes prompts through compilation.