Constructor
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | None | None | Respan API key. Falls back to RESPAN_API_KEY env var. |
base_url | str | None | None | API base URL. Falls back to RESPAN_BASE_URL, then https://api.respan.ai/api. |
app_name | str | "respan" | Application name for telemetry identification. |
instrumentations | list | None | None | List of instrumentor instances to activate. |
auto_instrument | bool | None | None | Auto-instrument LLM SDKs via OTEL. Defaults to False. Set True to enable alongside plugins. |
customer_identifier | str | None | None | Default customer/user ID attached to all spans. |
thread_identifier | str | None | None | Default conversation thread ID for all spans. |
metadata | dict | None | None | Default metadata dict merged into all spans. |
environment | str | None | None | Environment name (e.g. "production", "staging"). |
**telemetry_kwargs | Extra kwargs forwarded to RespanTelemetry (e.g. log_level, is_batching_enabled). |
Environment variables
| Variable | Description | Default |
|---|---|---|
RESPAN_API_KEY | Respan API key | — |
RESPAN_BASE_URL | API base URL | https://api.respan.ai/api |
RESPAN_LOG_LEVEL | SDK log level | INFO |
RESPAN_BATCHING_ENABLED | Enable batch processing | true |
Examples
With OpenAI Agents SDK
With OpenAI SDK
With multiple plugins
With default attributes
Attributes set on the constructor are attached to all spans for the lifetime of the instance:propagate_attributes() instead.