Set up the SDK

Set up tracing with the Respan SDK for your LLM framework.
  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page

Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.

1{
2 "mcpServers": {
3 "respan-docs": {
4 "url": "https://mcp.respan.ai/mcp/docs"
5 }
6 }
7}

The Respan tracing SDK provides decorators and wrappers to instrument your code. This page covers SDK setup for each framework, decorators for structuring traces, and advanced features.


1. Set your API key

$export RESPAN_API_KEY="your-api-key"

For the fastest setup, use the CLI wizard instead: npx @respan/cli setup


2. Auto-instrumented SDKs

These LLM SDKs can be traced automatically — just install Respan and initialize. No instrumentor imports needed.

$pip install respan-ai
1from respan import Respan
2Respan()
3# All supported LLM calls are now auto-traced
SDKPythonTypeScript
OpenAI
Anthropic
Azure OpenAI
Google Vertex AI
AWS Bedrock
Cohere
Together AI
Mistral
Ollama
Groq

3. Agent frameworks (explicit instrumentor)

Agent frameworks require an explicit instrumentor because they capture higher-level spans (agent runs, handoffs, tool calls) beyond raw LLM calls.

$pip install respan-ai respan-instrumentation-openai-agents openai-agents
1from agents import Agent, Runner
2from respan import Respan
3from respan_instrumentation_openai_agents import OpenAIAgentsInstrumentor
4
5Respan(instrumentations=[OpenAIAgentsInstrumentor()])
6
7agent = Agent(name="Assistant", instructions="Reply in one sentence.")
8result = Runner.run_sync(agent, "Explain tracing.")
9print(result.final_output)

Full guide →

Already have OpenTelemetry set up? Send spans directly via Manual ingestion.


Disable auto-instrumentation

By default, Respan auto-instruments all supported providers. You can disable specific ones:

1from respan import Respan
2
3# Disable specific providers
4Respan(
5 block_instruments={"bedrock", "vertexai"}
6)

In Python, you can also enable only specific providers instead of disabling:

1from respan import Respan
2
3# Only instrument OpenAI and Anthropic
4Respan(
5 instruments={"openai", "anthropic"}
6)

Add custom instrumentors

Agent frameworks and custom integrations require explicit instrumentors. Pass them via the instrumentations parameter:

1from respan import Respan
2from respan_instrumentation_openai_agents import OpenAIAgentsInstrumentor
3
4Respan(instrumentations=[OpenAIAgentsInstrumentor()])

When instrumentations are provided, auto-instrumentation is disabled by default to avoid duplicate spans. Pass is_auto_instrument=True (Python) to enable both.


Next steps