Skip to main content
← Frameworks

DSPy

Stanford NLP / Databricks
Open source MIT Prompt optimisation Programmatic LM Academic origins 8 axes checked Active Checked 2026-11-21

Read the two badges separately: the first is whether this page is backed by evidence, the second is whether the product is still maintained. An archived product can have complete evidence; complete evidence does not mean the product is active.

30-second check: should it make your shortlist?

In one line

DSPy turns 'tuning prompts' into a programming problem (MIT, Stanford…

How you use it

Local / self-hosted · Framework / SDK

Licence / commercial use

Open licence

Read the original licence before commercial use
Mainland China

Direct in mainland · Not in filing list

These four cards help you rule things out, not decide for you. The real differences are in the eight questions and sources below.

Information not confirmed

  • The full LM-integration catalog (the official LM-integration docs roll forward; this dossier does not enumerate it)
  • Sample-size rules of thumb per optimizer (official guidance exists; results vary by task, so this dossier fixes no numbers)

DSPy turns 'tuning prompts' into a programming problem (MIT, Stanford NLP/Databricks): signatures declare inputs/outputs, optimizers train prompts as parameters. The dividing line in one sentence: do you have an evaluation metric — with one it is a lever, without one it has nothing to optimize.

When to use it, when not to

Fits: reproducible prompt-optimization flows, multi-model swappable pipelines, mature tasks with metrics. Not a fit: out-of-the-box agent runtimes; exploratory tasks without metrics.

China availability domestic / direct access / CAC filing · snapshot 2026-11-21

Origin
foreign-made Stanford NLP origin, with official Databricks investment lines.
Direct access
direct OK dspy.ai measured 200 direct (2026-10-21).
CAC filing
not in filing list:not in the CAC public registry (searched 2026-10-21); the open-source project does not serve the mainland public, so filing does not apply.

Filing status is quoted from the CAC public registry (updated batch by batch; this site copies the number and does not interpret it). "Direct access" is this site's own reachability measurement from a mainland network, not a vendor promise. GitHub-hosted sites fluctuated on the measurement day — the note says so.

8 questions, one table

8 questions, each comparable item by item with its peers.

Model & openness

Each vendor's LM connects uniformly through dspy.LM (OpenAI/Anthropic/Gemini/local vLLM etc., following the official docs' LM-integration line); its differentiator is treating prompts as programmable parameters — signatures declare inputs and outputs, and optimizers automatically tune prompts and few-shot examples.

Where it runs

A Python library (pip-installed into your process); GitHub 38,850★, last push 2026-10-29 (API verified). Academic origin (Stanford NLP), with industrial-side Databricks investment (per the official narrative).

Local files

The library form runs inside your process; optimization artifacts (program state/examples) land at paths you specify — data never leaves your side.

Tasks after shutdown

A library has no resident semantics; optimization (teleprompting) is an offline batch task that ends when it finishes.

Tools & extensions

ReAct-style agent modules and tool calling are within the official module family; MCP goes through the official bridge: dspy.Tool.from_mcp_tool(session, mcp_tool) turns an MCP tool into a DSPy Tool, and the official tutorial gives an MCP SDK v2 Client + stdio example.

Context & memory

State management follows your program; cross-session memory is not part of its narrative — its "memory" is the optimized examples and weights.

Permissions & limits

No account system; the permission surface is whatever vendors' API keys you connect. The optimization process calls models heavily (a token-cost surface); budget-control parameters sit in the official docs and optimizer configuration, and this dossier fixes no specific values.

Best for

Fits: turning "prompt tuning" into a reproducible optimization process (with metrics, with a training set); pipelines where models are swappable. Does not fit: wanting an out-of-the-box agent runtime; small samples without metrics (optimizers consume metrics — without metrics there is nothing to optimize).

Licence and terms of use

MIT (GitHub API verified 2026-10-21).

Top misconception

  • Treating DSPy as 'yet another prompt template library' — the core is the optimizer (prompts trained as parameters); skipping it wastes the tool
  • Running optimizers without an evaluation metric — optimizers need a metric; without one there is nothing to optimize
  • Leaving optimizer token budgets uncapped — set budget parameters before running (the official docs have controls)

Evidence sources

Checked 2026-11-21,Content updated 2026-11-21。This is the date of the entry, not a claim that every field was rechecked that day.

TypeNameLink
repostanfordnlp/dspy · repository (MIT; 38,850★, last push 2026-10-29, GitHub API verified)https://github.com/stanfordnlp/dspy
docsDSPy · official docshttps://dspy.ai
changelogstanfordnlp/dspy · Releases (changelog)https://github.com/stanfordnlp/dspy/releases
docsDSPy Docs · Use MCP in DSPy (dspy.Tool.from_mcp_tool + MCP SDK v2 Client, 2026-11-04)https://dspy.ai/current/tutorials/mcp/
docsDSPy Docs · Tools and MCP (MCP tool to DSPy Tool schema mapping, direct-fetched 2026-11-21)https://dspy.ai/current/diving-deeper/tools/

Test notes

This site has not completed measured runs.

The test protocol is at protocols/framework/_protocol.md.

Related entries

  • LangChainsame-layer contrast: LangChain orchestrates components, DSPy optimizes prompts — one handles wiring, the other handles training
  • Pydantic AIboth on the "types/structure first" route: Pydantic governs output structure, DSPy governs prompt quality
  • CursorOther layer · AI coding
  • Claude Code (IDE extension)Other layer · AI coding

Same-category peers

Look at these three before reading further

Selected by overlap in jobs, not ranked. Compare where it runs, licence and status first; if one of the three fails, skip it.

ObjectWhereLicenceEvidence / statusWhat it is for
Claude Agent SDKLocal / self-hostedOpen licence8 questions checked
Active
The Python programming interface to Claude Code — a polished coding CLI
Codex SDKLocal / self-hostedOpen licence8 questions checked
Active
"Turns the Codex CLI into an object you can drive inside a Node process"
HaystackLocal / self-hostedOpen licence8 questions checked
Active
Haystack is the RAG framework of the 'retrieval-quality engineering' sch

This page is generated from the ai-handbook data layer (CC BY 4.0). For the judging criteria and method notes, see METHODOLOGY.md.