Setup
- Python
Usage
Once initialized, every DSPy module call and underlying LLM request is traced automatically:What Gets Captured
Run the example
Clone the repo and run a complete agent end-to-end.Python
Run the Python example
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Auto-instrument DSPy modules, signatures, and chain-of-thought reasoning
import traceroot
from traceroot import Integration
traceroot.initialize(integrations=[Integration.DSPY])
import dspy
import traceroot
from traceroot import Integration
traceroot.initialize(integrations=[Integration.DSPY])
# DSPy resolves the API key from OPENAI_API_KEY in the environment.
dspy.configure(lm=dspy.LM("openai/gpt-4o-mini", max_tokens=1024))
class CoTQA(dspy.Module):
"""Chain-of-thought question-answering module."""
def __init__(self):
super().__init__()
self.cot = dspy.ChainOfThought("question -> answer")
def forward(self, question: str):
return self.cot(question=question)
qa = CoTQA()
# The forward call, the chain-of-thought step, and the LLM call are all captured
result = qa(question="Why does ice float on water?")
print(result.reasoning)
print(result.answer)
traceroot.flush()
| Attribute | Description |
|---|---|
| Module calls | Each Module.__call__ / Module.forward invocation |
| Predictors | Predict, ChainOfThought, ReAct, etc. as nested spans |
| Signatures | Input/output fields declared on each signature |
| LLM calls | Raw completion requests to the configured dspy.LM |
| Tokens & Cost | Aggregated token usage and pricing |
| Latency | Duration per module call and per LLM call |