---
name: "Optimize prompt and agent pipelines with DSPy programs and evaluators"
slug: "optimize-prompt-and-agent-pipelines-with-dspy-programs-and-evaluators"
description: "Use DSPy to define modular LLM programs, metrics, and evaluation sets so an agent can optimize prompts and pipeline behavior with measurable feedback instead of ad hoc prompt editing."
github_stars: 34308
verification: "security_reviewed"
source: "https://github.com/stanfordnlp/dspy"
author: "Stanford NLP"
publisher_type: "open_source_project"
category: "Code Quality & Review"
framework: "Multi-Framework"
tool_ecosystem:
  github_repo: "stanfordnlp/dspy"
  github_stars: 34308
---

# Optimize prompt and agent pipelines with DSPy programs and evaluators

Use DSPy to define modular LLM programs, metrics, and evaluation sets so an agent can optimize prompts and pipeline behavior with measurable feedback instead of ad hoc prompt editing.

## Prerequisites

Python, DSPy, task examples, scoring metric or evaluator, target LLM provider credentials

## Installation

Use the upstream install or setup path that matches your environment:
- pip install dspy
- pip install git+https://github.com/stanfordnlp/dspy.git

Requirements and caveats from upstream:
- DSPy stands for Declarative Self-improving Python. Instead of brittle prompts, you write compositional _Python code_ and use DSPy to **teach your LM to deliver high-quality outputs**. Learn more via our [official docu...

Basic usage or getting-started notes:
- bash
- To install the very latest from main:
- ## 📜 Citation & Reading More

- Source: https://github.com/stanfordnlp/dspy
- Extracted from upstream docs: https://raw.githubusercontent.com/stanfordnlp/dspy/HEAD/README.md

## Documentation

- https://dspy.ai/

## Source

- [Agent Skill Exchange](https://agentskillexchange.com/skills/optimize-prompt-and-agent-pipelines-with-dspy-programs-and-evaluators/)
