Lattice
Skip to content

DSPy

librarySelf-hosteddspy.ai

DSPy is a self-hosted library in the Prompt Engineering layer of the AI stack. Declarative prompting that compiles to optimized programs from examples.

By Facts verifiedmethod

Licence
MIT
Language
Python
Cost
free
Owned by
Applied Engineering

Use DSPy when

Compiling prompts into optimised programs from labelled examples.

Skip DSPy when

You have no examples and no way to score them.

Makes the prompt an artifact you can diff and test. See every prompts tool.

Badge this entry
Lattice badge: DSPy verified 2026-09
[![DSPy on Lattice: verified 2026-09](https://lattice.kunjshah.in/prompt-engineering/dspy/badge.svg)](https://lattice.kunjshah.in/prompt-engineering/dspy)

Rules of thumb

  • Prompt changes without evals are guesses. Version prompts and measure before you ship a wording change.
  • Keep prompts out of string literals. A prompt you cannot diff is a prompt you cannot review.
  • Fix the examples before the instructions. Models copy what you show more faithfully than what you tell.

Quick answers

Is DSPy open source?
Yes. DSPy is open source under the MIT licence. It is free to use.
What are the alternatives to DSPy?
The closest alternatives to DSPy are TextGrad and PromptLayer.

Ask an AI about this page

Opens the assistant with this page’s link and a question already filled in.

Compared in

Reading on prompts

Alternatives to DSPy

Listed as an alternative to

  • TextGrad

Also in prompts

  • Instructor
  • Humanloop
  • Guidance
  • PromptLayer
  • Agenta
  • Promptwatch
  • TextGrad
  • Outlines