Framework guide
DSPy
Use Agent-Gantry with DSPy's ReAct tool-calling module. This page covers basic setup and the first production-friendly path; continue to the advanced page for per-call dynamic retrieval, LLM calls, and operations.
Basic page: register once, adapt at the edge
- Create a Gantry instance near application startup.
- Register deterministic Python functions with descriptions and input schemas.
- Export framework-native tools for DSPy immediately before constructing
dspy.ReAct. - Keep authorization, rate limits, and audit metadata in Gantry instead of duplicating it inside framework glue code.
import dspy
from agent_gantry import AgentGantry
from agent_gantry.dspy import DSPyAdapter
dspy.configure(lm=dspy.LM("openai/gpt-4o-mini"))
gantry = AgentGantry()
def get_order_status(order_id: str) -> str:
"""Return the current shipping status for an order."""
return "in_transit"
gantry.register_tool(get_order_status, tags=["support", "orders"])
adapter = DSPyAdapter(gantry)
framework_tools = await adapter.select("check an order", limit=3) # Native dspy.Tool objects.
react = dspy.ReAct("question -> answer", tools=framework_tools)
pred = react(question="What is the status of order 42?") First tool-calling loop
Let DSPy own the reasoning loop while Gantry owns the tool catalog. Start with a small tool set and assert that the framework receives only safe, documented functions.
dspy.utils.dummies.DummyLM — a scripted, offline stand-in LM — which is useful for exercising a full ReAct run in tests without an API key.Basic LLM call guidance
For early prototypes, use dspy.LM(...) (LiteLLM-backed — OpenAI, Anthropic, and dozens of other providers) already recommended by DSPy. Wrap that client with a thin policy function that records model name, prompt tokens, completion tokens, tool calls, and latency. Once the integration stabilizes, move the policy into Agent-Gantry's LLM adapter layer so other frameworks share the same rules.