# dspy

> dspy is an open-source agent framework for ai models and llm tooling. Python framework to program LLM pipelines with typed signatures and auto-tuned prompts. It is available on API, Linux, macOS, Windows and Self-hosted.

- **Kind:** Agent
- **Pricing:** Open source
- **Platforms:** API, Linux, macOS, Windows, Self-hosted
- **Website:** https://dspy.ai
- **Repository:** https://github.com/stanfordnlp/dspy
- **GitHub stars:** 39,351
- **License:** MIT
- **Categories:** [AI models and LLM tooling](https://ai-powered.com/categories/ai-and-llm), [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-01

## About

DSPy lets developers describe what a language model should do as typed inputs and outputs rather than hand-written prompt strings. Tasks are assembled from composable modules that choose how the model reasons, whether it runs ensembles, and whether it calls tools, so the same task definition can be reshaped without rewriting it.

The optimizer side takes a set of labelled examples and a scoring function, then adjusts prompts and demonstrations automatically until the measured quality stops improving. Research papers from the Stanford NLP group back several of the optimization methods.

DSPy is aimed at engineers building classifiers, retrieval-augmented pipelines and agent loops who want their LLM logic to be versioned, testable Python code instead of a collection of prompts. It is installed with pip and is open source under the MIT licence.

## Features

- **Typed signatures:** Define a task by its inputs and outputs so the model interface stays readable and portable.
- **Composable modules:** Swap reasoning strategies, ensembles or tool use without changing the underlying task definition.
- **Automatic prompt optimization:** Tune prompts and demonstrations against examples and a scoring function until quality converges.
- **Research-backed methods:** Optimizers and module types are based on published papers from the Stanford NLP group.
- **Python-native workflow:** Pipelines are ordinary Python code that can be versioned, tested and iterated like any other module.

## Good for

- Building a text classifier whose prompts are tuned against labelled examples
- Assembling retrieval-augmented generation pipelines with swappable components
- Structuring multi-step agent loops that call tools inside a typed program
- Replacing a collection of hand-edited prompts with a maintainable codebase

## FAQ

### How do I install DSPy?

Run pip install dspy. The latest development version can be installed directly from the main branch of the GitHub repository.

### What licence is DSPy released under?

DSPy is released under the MIT licence.

### Where can I find the documentation?

Full documentation is hosted at dspy.ai, and the project has a Discord server for community help.

### Is dspy free?

Yes. dspy is open source, so you can use and self-host it for free.

### What are the best alternatives to dspy?

The closest alternatives to dspy are voice-lab, pydantic-deepagents, pydantic-ai, llama-cpp-agent and DemoGPT.

## Where this comes from

- Description: written from the project's README and the project's website.

## Alternatives

- [voice-lab](https://ai-powered.com/agents/voice-lab): voice-lab is an open-source agent framework for ai models and llm tooling.
- [pydantic-deepagents](https://ai-powered.com/agents/pydantic-deepagents): pydantic-deepagents is an open-source agent framework for ai models and llm tooling.
- [pydantic-ai](https://ai-powered.com/agents/pydantic-ai): pydantic-ai is an open-source agent framework for design and media.
- [llama-cpp-agent](https://ai-powered.com/agents/llama-cpp-agent): llama-cpp-agent is an open-source agent framework for developer tools.
- [DemoGPT](https://ai-powered.com/agents/demogpt): DemoGPT is an open-source agent framework for ai models and llm tooling.
- [thinkgpt](https://ai-powered.com/agents/thinkgpt): thinkgpt is an open-source agent framework for ai models and llm tooling.
- [agentic-context-engine](https://ai-powered.com/agents/agentic-context-engine): agentic-context-engine is an open-source agent framework for multi-agent frameworks.
- [AgentPilot](https://ai-powered.com/agents/agentpilot): AgentPilot is a freemium open-source agent for ai models and llm tooling.

---
Source: https://ai-powered.com/agents/dspy
