Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.agno.com/llms.txt

Use this file to discover all available pages before exploring further.

DSPyAgent wraps any DSPy Module so it can be served through AgentOS or used standalone.
import dspy
from agno.agents.dspy import DSPyAgent
from agno.db.sqlite import SqliteDb
from agno.os import AgentOS

dspy.configure(lm=dspy.LM("openai/gpt-5.4"))

agent = DSPyAgent(
    name="DSPy Assistant",
    program=dspy.ChainOfThought("question -> answer"),
)

agent_os = AgentOS(
    agents=[agent],
    tracing=True,
    db=SqliteDb(db_file="tmp/agentos.db"),
)
app = agent_os.get_app()

if __name__ == "__main__":
    agent_os.serve(app="dspy_agent:app", reload=True)

Install

uv pip install dspy
export OPENAI_API_KEY=sk-...

Parameters

ParameterTypeDefaultDescription
namestrNoneDisplay name for the agent.
idstrNoneUnique identifier. Auto-generated from name if unset.
programdspy.ModuleNoneA DSPy module (Predict, ChainOfThought, ReAct, or custom).
input_fieldstr"question"Name of the input field in the DSPy signature.
output_fieldstr"answer"Name of the output field on the Prediction.
lmdspy.LMNoneOptional LM to scope this agent. Falls back to the global dspy.configure(lm=...).
program_kwargsDict[str, Any]{}Extra kwargs passed to the program on every call.
dbBaseDbNoneDatabase for session persistence.

Examples

AgentOS deployment

Serve a DSPy program through AgentOS.

Standalone usage

Call the agent directly with .run() and .print_response().

ReAct with tools

Use dspy.ReAct to call tools from the program.

Sessions

Resume conversations across runs with session_id.

Developer Resources