The Respan Python SDK gives you full observability into every LLM call your application makes. Install the package, initialize with your API key, and every request - inputs, outputs, latency, token usage, and cost - is captured automatically.
The SDK auto-instruments the OpenAI and Anthropic client libraries. For custom pipelines, wrap any block of code in a trace span to capture multi-step agent executions as a single hierarchical trace.
Attach metadata like user IDs, feature flags, and environment tags to any request. Use this data to filter logs, build dashboards, and run targeted evaluations in the Respan platform.
Install the package with pip install respan. Import and initialize the client with your API key - this is the only setup required.
The SDK patches supported LLM client libraries at import time. Every call through the OpenAI or Anthropic SDK is intercepted, logged asynchronously, and forwarded to the Respan platform without adding latency to the request path.
For multi-step pipelines, use the @respan.trace decorator or the with respan.span() context manager to group related calls into a single trace. The platform reconstructs the full execution tree automatically.
python
import respan
import openai
# Initialize - all LLM calls are now traced automatically
respan.init(api_key="YOUR_RESPAN_KEY")
client = openai.OpenAI()
# This call is logged with full input, output, latency, and cost
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Summarize this document..."}],
)
# For multi-step traces, use the decorator
@respan.trace(name="research-agent")
def run_agent(query: str):
# Each LLM call inside is captured as a child span
plan = client.chat.completions.create(...)
result = client.chat.completions.create(...)
return result