Respan Python SDK
respan.ai | Documentation | PyPI
respan-ai is the unified Python entry point for Respan tracing, decorators, context propagation, and first-party instrumentation plugins. It automatically discovers eligible direct LLM SDK adapters while keeping frameworks, agents, wrappers, and observability bridges explicit to avoid duplicate spans.
Requirements
- Python 3.11, 3.12, or 3.13
- A Respan API key for telemetry export
- The provider SDK used by your application
Installation
Install the facade and your provider SDK. For OpenAI:
pip install respan-ai openai
With Poetry:
poetry add respan-ai openai
Replace openai with the provider SDK your application uses. respan-ai already bundles the supported first-party instrumentation adapters and respan-tracing; provider SDKs remain application-owned dependencies.
Automatic Onboarding
Set your Respan credentials:
export RESPAN_API_KEY="your-api-key-here"
# Optional; this is also the Respan gateway base URL used below.
export RESPAN_BASE_URL="https://api.respan.ai/api"
Construct Respan before the first provider call. Python discovery and activation happen synchronously in the constructor, so there is no separate initialize() call:
import os
from openai import OpenAI
from respan import Respan
# Omit `instrumentations` to use curated direct-LLM automatic discovery.
respan = Respan()
client = OpenAI(
api_key=os.environ["RESPAN_API_KEY"],
base_url=os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api"),
)
response = client.chat.completions.create(
model="gpt-4.1-nano",
messages=[{"role": "user", "content": "Say hello in three languages."}],
)
print(response.choices[0].message.content)
print(respan.get_auto_instrumentation_status())
respan.shutdown()
This example routes inference through the Respan gateway. When calling a provider directly, configure that provider's credentials and endpoint normally; Respan still reads RESPAN_API_KEY for telemetry export.
Automatically Supported Providers
The facade bundles these adapters. Install only the provider SDKs your application actually imports.
| Provider | Application SDK |
|---|---|
| OpenAI and Azure OpenAI | openai |
| Anthropic | anthropic |
| Vertex AI | google-cloud-aiplatform |
| Google GenAI | google-genai |
| AWS Bedrock | boto3 |
| Together AI | together |
| Ollama | ollama |
Only registry entries classified as direct LLM integrations and enabled by default are activated. A missing provider SDK is reported as missing and does not stop application startup. Broad OpenTelemetry entry-point discovery remains disabled.
Inspect Instrumentation Status
for entry in respan.get_auto_instrumentation_status():
print(entry["id"], entry["status"], entry.get("reason"))
Each entry includes the registry ID, runtime name, provider, provider SDK, instrumentation package, status, and optional reason. Status is one of enabled, disabled, missing, or failed.
The dataclass form is also available as respan.auto_instrumentation_status.
Control Automatic Discovery
Disable automatic discovery completely:
from respan import Respan
respan = Respan(is_auto_instrument=False)
Supplying an explicit instrumentation list selects explicit mode and disables automatic discovery by default:
pip install respan-ai respan-instrumentation-openai-agents openai-agents
from respan import Respan
from respan_instrumentation_openai_agents import OpenAIAgentsInstrumentor
respan = Respan(
instrumentations=[OpenAIAgentsInstrumentor()],
)
To deliberately combine an explicit plugin with direct-SDK automatic discovery:
respan = Respan(
instrumentations=[OpenAIAgentsInstrumentor()],
is_auto_instrument=True,
)
Explicit plugins activate first, so a matching automatic adapter is skipped rather than activated twice. Python currently provides a global automatic-discovery switch, but not a per-provider disable option.
Tracing Helpers
The facade re-exports Respan's tracing helpers:
from respan import agent, respan_span_attributes, task, tool, workflow
Use @workflow, @task, @agent, and @tool to structure traces, and use respan_span_attributes or propagate_attributes to attach customer, session, thread, environment, and metadata values.
Lifecycle
Respan()initializes telemetry and activates eligible adapters.respan.flush()exports buffered spans without deactivating adapters.respan.shutdown()deactivates adapters and flushes telemetry.
Examples
Public API
The package exports Respan, the automatic instrumentation registry and status types, OTELInstrumentor, the instrumentation protocol, tracing decorators, RespanClient, get_client, respan_span_attributes, and propagate_attributes.
License
Apache 2.0 — see the repository LICENSE.
Support
- Email: team@respan.ai
- Documentation: https://www.respan.ai/docs
- Issues: GitHub Issues
Metadata
Release files for respan-ai 4.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| respan_ai-4.2.3.tar.gz | 15.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| respan_ai-4.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.2 kB
Release files / respan_ai-4.2.3.tar.gz
| Download URL | respan_ai-4.2.3.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d746235183421cfde8634a47f9741c752fd6a451fc8c2b5e006c6d996f3068da
|
|
BLAKE2b-256 checksum How to use checksums |
49b75c362ec0c75743770dbaed7cb8d0e41d12d253d753ae5a5468f0b4bd8a5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency logRelease files / respan_ai-4.2.3-py3-none-any.whl
| Download URL | respan_ai-4.2.3-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80d251944701be541b6d211556a381e911487c1b4b1e1388921783d0eee049ed
|
|
BLAKE2b-256 checksum How to use checksums |
7fb5d38874921149403aa940d4c87aaf17f6c64ae315942d1cfde9ca8388bddc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency log