DSPy is a Stanford framework for declarative LLM programs —Documentation Index
Fetch the complete documentation index at: https://arize-ax.mintlify.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Signature, Predict, and other modules describe the structure of an LLM call without hard-coding prompts. Arize AX captures the DSPy module hierarchy plus the underlying LLM calls (DSPy routes through LiteLLM by default) via the openinference-instrumentation-dspy and openinference-instrumentation-litellm packages — install both for full visibility.
DSPy Tracing Tutorial (Google Colab)
Prerequisites
- Python 3.10+
- An Arize AX account (sign up)
- An
OPENAI_API_KEYfrom the OpenAI Platform
Launch Arize AX
- Sign in to your Arize AX account.
- From Space Settings, copy your Space ID and API Key. You will set them as
ARIZE_SPACE_IDandARIZE_API_KEYbelow.
Install
Configure credentials
Setup tracing
Run DSPy
Expected output
Verify in Arize AX
- Open your Arize AX space and select project
dspy-tracing-example. - You should see a new trace within ~30 seconds containing a DSPy
Predict(BasicQA).forwardparent span (theBasicQAsignature) wrapping LiteLLMcompletionchild spans with the prompt, response, and token usage attached. - If no traces appear, see Troubleshooting.
Troubleshooting
- No traces in Arize AX. Confirm
ARIZE_SPACE_IDandARIZE_API_KEYare set in the same shell that runsexample.py. Enable OpenTelemetry debug logs withexport OTEL_LOG_LEVEL=debugand re-run. - DSPy spans appear but no LLM-call detail. DSPy delegates model calls to LiteLLM; install and instrument
openinference-instrumentation-litellm(already in the install command above). 401from OpenAI. VerifyOPENAI_API_KEYis set and has access togpt-5. Swap the model string indspy.LM("openai/<model>")for one your key can call.- Other LLM providers. DSPy via LiteLLM supports many providers —
dspy.LM("anthropic/claude-3-5-sonnet-20241022"),dspy.LM("groq/llama-3.3-70b-versatile"), etc. The sameLiteLLMInstrumentorcovers them.