dspy is a Python framework for building language model systems by writing compositional Python code instead of brittle prompts. It provides algorithms that optimize the prompts and weights of LM programs to produce high-quality outputs.
Project overview
By treating LM programs as Python code, dspy replaces hand-tuned prompts with programmable modules such as classifiers, RAG pipelines, and agent loops, and adds algorithms that optimize both prompts and model weights toward high-quality outputs.
Project type
AI Agent · Prompt Engineering
Use cases
Automation
Deployment
Refer to project documentation
License
MIT
Best for
Developers and AI engineers who want to build modular LM systems and optimize prompts and weights through Python code rather than hand-written prompts.
Key capabilities
Build modular AI systems such as classifiers, RAG pipelines, and agent loops via Python code.
Algorithms to optimize the prompts and weights of LM programs.
Limitations and risks
Using dspy requires writing Python code.
Getting started
Install with a single command: pip install dspy.
Evidence and sources
README: 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 **optimiz…
README: pip install dspy
README: The current LM integration uses bundled native lm15 engines, without a LiteLLM runtime dependency or fallback.