# DSPy

CreateWithAI Hub page: https://createwithaihub.com/open-source/dspy
Latest version of this file: https://createwithaihub.com/open-source/dspy.md

- Type: Library · Category: Libraries & Open Source
- Publisher: Stanford NLP
- Pricing: Free · License: MIT
- Runs on: macOS, Windows, Linux

Stanford NLP framework for programming language-model pipelines in Python and optimizing their prompts and weights.

DSPy (Declarative Self-improving Python) is a framework for building modular AI systems by writing Python code instead of hand-tuned prompts. You declare tasks as typed signatures, choose modules such as Predict, ChainOfThought or ReAct to run them, and use optimizers like GEPA or MIPROv2 to improve prompts and weights against examples and a metric. It is aimed at developers and researchers building classifiers, RAG pipelines and agent loops.

Useful for: Replacing brittle prompt strings with testable modules, or automatically optimizing a multi-step LLM pipeline against a labelled dataset.

## Key features

- Signatures: typed inputs and outputs instead of prompts
- Modules such as dspy.Predict, dspy.ChainOfThought and dspy.ReAct
- Optimizers such as GEPA and MIPROv2
- Works for classifiers, RAG pipelines and agent loops
- Provider/model string configuration via dspy.LM

## Connection

- Language: Python
- Focus: LLM orchestration

## Install steps from the official documentation

pip:

```
pip install dspy
```

## Limitations

- Recent releases changed the LM integration; a migration guide covers breaking changes

## Official links

- Website: https://dspy.ai
- Source repository: https://github.com/stanfordnlp/dspy
- Documentation: https://dspy.ai
- Source: https://github.com/stanfordnlp/dspy (Description, install, LM migration note; MIT; not archived)
- Source: https://dspy.ai/ (Signatures, modules, optimizers)
