dspy is a Python framework for programming language models declaratively, letting developers write compositional Python code instead of hand-written prompts. It provides algorithms for optimizing the prompts and weights of language model programs.
Project overview
dspy reframes LM application development as programming rather than prompting, replacing brittle hand-written prompts with compositional Python code and offering built-in optimization of prompts and weights.
Project type
AI Agent · Workflow
Use cases
Knowledge Q&A · Automation
Deployment
Refer to project documentation
License
MIT
Best for
Developers comfortable writing Python who want to build LM systems as code rather than hand-written prompts
Key capabilities
Build modular AI systems such as classifiers, RAG pipelines, and Agent loops
Offers algorithms for optimizing prompts and weights of LM programs
Write compositional Python code instead of brittle prompts to teach the LM to deliver high-quality outputs
Limitations and risks
Using dspy requires writing Python code; it is a library, not a no-code tool
GPU requirements, external services, model requirements, and telemetry behavior are not documented, so verify these against your environment before adoption
Getting started
Install with a single documented pip command (pip install dspy), import dspy in Python, then build a modular AI program in Python
Evidence and sources
GitHub project description: DSPy: The framework for programming—not prompting—language models
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: ```bash pip install dspy ```
README: If you're looking to understand the underlying research, this is a set of our papers: