skillfed

dspy-ai

DSPy

dspy-ai v3.3.0 909.7K downloads/30d#4,748 on PyPI37,189
Permissive license MIT License Active released

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-ai

uv

uv add dspy-ai

poetry

poetry add dspy-ai

Installing 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

language model programming frameworkprompt optimization and compilationmodular AI system builderRAG pipeline frameworkLLM application developmentdeclarative language model callsself-improving AI pipelines
llm-frameworkprompt-optimizationrag

More Artificial Intelligence packages