From dspy-skills
Guides selection of DSPy adapters (Chat, JSON, XML, TwoStep) and handling of image, audio, and file inputs using typed primitives.
How this skill is triggered — by the user, by Claude, or both
Slash command
/dspy-skills:dspy-adapters-multimodalThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Choose an adapter deliberately and model image, audio, and file inputs with DSPy's typed primitives.
Choose an adapter deliberately and model image, audio, and file inputs with DSPy's typed primitives.
| Adapter | Use it for |
|---|---|
dspy.ChatAdapter() | Default, human-readable field markers, broad model compatibility |
dspy.JSONAdapter() | Structured JSON output and native function calling where supported |
dspy.XMLAdapter() | XML-tagged fields when XML is easier for the target LM to follow |
dspy.TwoStepAdapter() | A separate extraction pass when parsing needs extra help |
Configure globally or for a limited scope:
import dspy
dspy.configure(
lm=dspy.LM("openai/gpt-4o-mini"),
adapter=dspy.JSONAdapter(),
)
with dspy.context(adapter=dspy.XMLAdapter()):
result = dspy.Predict("question -> answer")(question="What is DSPy?")
JSONAdapter enables native function calling by default. ChatAdapter keeps text parsing by default. Override either behavior explicitly:
chat_native = dspy.ChatAdapter(use_native_function_calling=True)
json_manual = dspy.JSONAdapter(use_native_function_calling=False)
DSPy falls back to manual parsing when the configured LM does not support native function calling.
class DescribeImage(dspy.Signature):
image: dspy.Image = dspy.InputField()
description: str = dspy.OutputField()
describe = dspy.Predict(DescribeImage)
result = describe(image=dspy.Image("./diagram.png"))
Pass a local path, HTTP URL, bytes, PIL image, or existing data URI directly to dspy.Image(...).
class SummarizeAudio(dspy.Signature):
audio: dspy.Audio = dspy.InputField()
summary: str = dspy.OutputField()
audio = dspy.Audio.from_file("./meeting.wav")
summary = dspy.Predict(SummarizeAudio)(audio=audio)
class SummarizeFile(dspy.Signature):
file: dspy.File = dspy.InputField()
summary: str = dspy.OutputField()
document = dspy.File.from_path("./research.pdf")
summary = dspy.Predict(SummarizeFile)(file=document)
Provider capabilities vary. Verify that the selected model accepts the media type before deployment.
ChatAdapter; switch only for a measured reason.Image.from_file() and Image.from_url() helpers; call dspy.Image(...).npx claudepluginhub omidzamani/dspy-skills --plugin dspy-skillsDesigns type-safe DSPy signatures with InputField/OutputField, type hints, and Pydantic models for structured LLM outputs.
Teaches idiomatic DSPy 3.2.x patterns: typed Signatures, dspy.Module subclasses, Predict/ChainOfThought/ReAct/ProgramOfThought, save/load. Use when starting a new DSPy project or refactoring prompt-engineering code.
Build type-safe LLM applications with DSPy.rb using signatures, modules, and tools. Use when implementing AI features, agents, or prompt optimization in Ruby.