dspy-ai
DSPy
What it is and what it does
DSPy is a framework that shifts language model development from manual prompt engineering to compositional Python programming. Instead of writing and tweaking prompts by hand, you define your AI system's logic in Python code, then use DSPy's optimization algorithms to automatically improve the prompts and weights that drive your language model's outputs. This approach scales from simple classifiers to complex retrieval-augmented generation pipelines and agent loops.
The framework treats language model calls as compilable, optimizable components rather than black-box function calls. You compose these components into larger systems using standard Python patterns, and DSPy provides tools to teach your language models to deliver high-quality outputs for your specific tasks. The result is more maintainable and iteratively improvable AI applications compared to hand-crafted prompt management.
Use it for:
- Build modular RAG systems where retrieval and generation steps are optimized together
- Create multi-step agent workflows where each language model call's behavior is automatically refined
- Develop classifiers with automatically optimized prompts tailored to your data
- Iterate rapidly on language model applications by recompiling instead of manual prompt rewrites
- Compose reusable language model components into larger systems with clear interfaces
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
DSPy is a framework for building and optimizing modular AI systems through declarative Python code rather than prompt engineering, supporting RAG pipelines and agent loops.
Yes. DSPy is actively maintained, permissively licensed, has low install friction, and addresses a real pain point in language model application development. The framework has strong community adoption (37189 GitHub stars, top 5000 PyPI packages) and zero known vulnerabilities. Install it if you're building anything beyond simple single-prompt use cases.
Install
dspy-ai on PyPI
pip
pip install dspy-aiuv
uv add dspy-aipoetry
poetry add dspy-aiInstalling dspy-ai
Before you install
Installation is straightforward with low friction. The package is actively maintained with a recent release and substantial community engagement (37189 GitHub stars), indicating solid ongoing development.
License in practice
MIT License permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install dspy-ai
import dspy
# Define a simple task using DSPy
class SimpleClassifier(dspy.ChainOfThought):
pass
Requires Python 3.9 or later
Verify before relying
- Whether the framework requires external LLM API keys or supports local models exclusively
- Performance characteristics and scalability limits for production deployments
- Specific version compatibility with popular LLM providers and APIs
Package facts
| License | MIT License (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — dspy |
| Maintenance | actively maintained — 11 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 909,681/month — #4,748 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dspy_ai-3.3.0-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
dspyDSPy is a framework for building and optimizing…
permissive · top 5,000 on PyPI
ell-aiell-ai is a functional prompt engineering…
permissive · top 15,000 on PyPI
rayRay is a distributed computing framework that…
permissive · top 1,000 on PyPI
gepaGEPA optimizes textual system…
permissive · top 5,000 on PyPI
databricks-bundlesExtends Databricks Declarative Automation…
unclear · top 5,000 on PyPI
adam-atan2-pytorchProvides an Adam optimizer variant using atan2…
permissive · top 15,000 on PyPI
google-tunixTunix is a JAX-based library for post-training…
permissive · top 15,000 on PyPI
autogluonAutoGluon automates machine learning model…
permissive · top 15,000 on PyPI
autogluon.tabularAutomates machine learning model training and…
permissive · top 15,000 on PyPI
autogluon.timeseriesAutoGluon TimeSeries automates machine learning…
permissive · top 15,000 on PyPI