DSPy is a framework by Stanford that compiles declarative language model calls into self-improving pipelines. Instead of brittle prompt chains, you write modular modules and let DSPy optimize the prompts, few-shot examples, and reasoning structure automatically.