Lattice
Skip to content

DSPy

dspy.ailibraryself-hosted

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 Lattice editorial · Facts verified · method

licence
MIT
language
Python
cost
free

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. — that is what this layer of the stack is answerable for. See the full Prompt Engineering section for the rest of the options.

Visit dspy.aiCompare with another 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)

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.

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