LiteLLM (tracing)
LiteLLM (tracing)
LiteLLM provides a unified Python interface for calling 100+ LLM providers using the OpenAI format. Respan’s LiteLLM instrumentation registers a native LiteLLM callback and sends completion spans through respan-tracing, with optional gateway routing through the OpenAI-compatible Respan endpoint.
Set up Respan
Create an account at platform.respan.ai and grab an API key.
Run npx @respan/cli setup to set up with your coding agent.
Use Respan Gateway
See LiteLLM gateway setup to route this integration through the Respan gateway.
Example projects
Setup
Set environment variables
OPENAI_API_KEY (or any provider key) is used for LLM requests. RESPAN_API_KEY is used to export traces to Respan.
Initialize and run
Initialize Respan with the LiteLLM instrumentor. Requests go directly to providers; the callback emits canonical chat spans to Respan.
View your trace
Open the Traces page to see your LiteLLM completions across providers as auto-traced spans.
Configuration
Respan
LiteLLMInstrumentor
See the LiteLLM SDK reference for the full API.
Attributes
Set defaults on Respan(...), or override attributes per request with propagate_attributes.
Async usage
The callback supports async completions automatically.
Multiple providers
LiteLLM’s unified interface means all providers are logged with the same callback.