dspy-adapters

Installation
SKILL.md

Control Prompt Formatting with DSPy Adapters

Adapters sit between your DSPy modules and the language model. They control how signatures get turned into prompts and how LM responses get parsed back into typed Python objects. Most of the time the default adapter just works -- but when you need tighter control over structured output, or you are working with reasoning models that struggle with formatting, adapters give you that control.

What adapters do

Every time a DSPy module calls an LM, an adapter handles two jobs:

  1. Format -- Convert the signature, few-shot demos, and inputs into a prompt (system message + user/assistant messages).
  2. Parse -- Extract the output fields from the LM's raw text response and cast them to the declared Python types.

You never call adapters directly. You configure one globally or per-module, and DSPy uses it behind the scenes.

The four built-in adapters

Adapter How it formats How it parses Best for
ChatAdapter Field markers like [[ ## field_name ## ]] Splits on field headers General use (default)
JSONAdapter Requests JSON output with field schema json_repair + type casting Reliable structured output
Related skills

More from lebsral/dspy-programming-not-prompting-lms-skills

Installs
6
GitHub Stars
5
First Seen
Mar 17, 2026