Skip to main content
  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

Overview

respan-tracing is a Python SDK built on OpenTelemetry that captures telemetry for your LLM applications. It records workflows, tasks, agents, and tools as hierarchical spans, tracks timings and errors, and sends traces to Respan for visualization and debugging.
pip install respan-tracing

Core concepts

ConceptDescription
WorkflowAn end-to-end agent run. Creates a root trace span.
TaskA single operation within a workflow (LLM call, data processing, validation).
AgentAn autonomous entity with decision-making capabilities. Sets workflow name context for nested spans.
ToolA callable operation used by agents or tasks (search, calculator, API call).
TraceThe full tree of spans sent to Respan for visualization.

Public API

Initialization

ExportDescription
RespanTelemetryMain entry point. Initializes tracing, configures exporters, and enables auto-instrumentation.
get_client()Returns a RespanClient bound to the singleton tracer for span operations.

Decorators

DecoratorDescription
@workflowMarks a function or class as a traced workflow (root span).
@taskMarks a function or class as a traced task (child span).
@agentMarks a function or class as a traced agent span.
@toolMarks a function or class as a traced tool span.
All decorators accept name, version, method_name, and processors parameters.

Context managers

ExportDescription
respan_span_attributes()Attaches Respan-specific attributes (customer_identifier, metadata, etc.) to spans within the context.

Instrumentation

ExportDescription
InstrumentsEnum of 30+ supported auto-instrumentations (OpenAI, Anthropic, LangChain, vector DBs, etc.).

Types

ExportDescription
RespanParamsPydantic model for Respan-specific parameters (customer_identifier, trace_group_identifier, metadata).

Quick example

from respan_tracing import RespanTelemetry, workflow, task
from openai import OpenAI

telemetry = RespanTelemetry(
    api_key="your-api-key",
    app_name="my-app",
)

client = OpenAI()

@task(name="generate_joke")
def generate_joke(topic: str):
    response = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": f"Tell me a joke about {topic}"}],
    )
    return response.choices[0].message.content

@workflow(name="joke_workflow")
def joke_workflow():
    return generate_joke("tracing")

result = joke_workflow()
print(result)

Next steps