PROVIDER - Declarative prompt and model programming framework
DSPy
DSPy from a Stanford team declares inputs and outputs through Signatures, letting 1 definition swap models and prompting strategies while 3 optimiser families search better prompt and example combinations; the upfront evaluation set and optimisation quota are the costs.
3.8pts
Detailed Notes
Pros 5 items
Cons 4 items
Service Overview
DSPy is a declarative prompt programming framework from a Stanford team that turns prompt engineering from hand-written strings into compilable, optimisable programs.
In the AI platform category it is the prompting and model programming layer, suited to pipelines that need stable quality and continuous iteration.
Key Strengths
- Declarative definitions: Signatures describe I/O
- Automatic optimisation: 3 optimiser families
- Compilable programs: prompts as assets
- Ecosystem fit: embeds into existing RAG
- Academic grounding: papers and courses
Product Ecosystem
Platform capabilities
Signature and Module definitions, optimisers and metric evaluation, automatic example selection, multi-model adaptation, retrieval module composition plus comparison and regression evaluation.
Integrations
Supports mainstream model services and self-hosted endpoints, composing with vector stores and retrieval frameworks.
Typical scenarios
RAG quality tuning, classification and extraction tasks, multi-step reasoning pipelines and prompt regression tests.
Limitations
- Upfront work: evaluation sets and metrics
- Optimisation cost: quota consumed by search
- Concept barrier: abstractions not obvious
- Ecosystem maturity: tooling still filling out
Use Cases
- Quality-driven RAG (★★★★☆): clear optimisation gains
- Regressible prompt iteration (★★★★☆): tested like code
- Fast prototyping (★★★☆☆): manual prompts are quicker
- Tight compute budgets (★★☆☆☆): optimisation needs quota
Pricing
| Item | Price | Notes |
|---|---|---|
| Open source framework | $0 | MIT licence, free to use |
| Model calls | Usage based | Determined by the chosen model service |
| Enterprise support | Contact sales | Available through community or consultants |
FAQ
Does DSPy replace prompt engineering?
It compiles and optimises prompts, but humans still define tasks and metrics.
Is a dataset required?
The optimisation step needs a small labelled sample and evaluation metrics.
Does it support local models?
Yes, self-hosted OpenAI-compatible endpoints work.
How does it relate to LangChain?
DSPy can live inside pipelines built with LangChain or LlamaIndex.
Code Examples
import dspy
lm = dspy.LM("openai/gpt-4o-mini")
dspy.configure(lm=lm)
class QA(dspy.Signature):
"""Answer the question from the context."""
context: str = dspy.InputField()
question: str = dspy.InputField()
answer: str = dspy.OutputField()
qa = dspy.Predict(QA)
print(qa(context="Refunds must be requested within 7 days.", question="How long is the refund window?").answer)
# Install DSPy
pip install -U dspy
Community & Resources
- Website: https://dspy.ai/
- Documentation: https://dspy.ai/learn/
- Source repository: https://github.com/stanfordnlp/dspy
Articles
- 01 OpenAI releases GPT-5.4 as developer platform capabilities continue to improve 03-10
- 02 Cloudflare AI Gateway adds spend limits to help teams control model costs 06-05
- 03 AI Video Editing Tools Review: Best AI Video Platforms to Use in 2026 07-18
- 04 OpenAI Launches GPT-5.6 Series: Three Tiers Reshape AI Price-Performance 08-05
- 05 OpenAI GPT-5 launch: impact analysis for website development and AI deployment 07-12
- 06 AI Customer Service Bot Guide: Building a Smart Support System from Scratch 07-18
- 07 Anthropic Launches Claude Opus 5: Near-Frontier Intelligence at Opus 4.8 Cost 08-05
- 08 AI Model Deployment Guide: 5 ways to host and run open-source LLMs in 2026 07-12
- 09 2026 AI Website Builder Tools Landscape: AI-assisted workflow from design to deployment 07-12
- 10 AI Music Generation Tools Comparison: Suno vs Udio vs MusicFX 07-18