Respan instrumentation plugin for direct OpenAI SDK usage
Project description
respan-instrumentation-openai
Respan instrumentation plugin for direct OpenAI SDK usage. Wraps opentelemetry-instrumentation-openai with Respan-specific prompt capture and trace export.
Configuration
1. Install
pip install respan-instrumentation-openai
2. Set Environment Variables
| Variable | Required | Description |
|---|---|---|
RESPAN_API_KEY |
Yes | Your Respan API key. Authenticates both proxy and tracing. |
RESPAN_BASE_URL |
No | Defaults to https://api.respan.ai. |
All vendor-specific variables (e.g. OPENAI_API_KEY) are derived from these in your application code.
Quickstart
3. Run Script
import os
from openai import OpenAI
from respan import Respan
from respan_instrumentation_openai import OpenAIInstrumentor
respan_api_key = os.environ["RESPAN_API_KEY"]
respan_base_url = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai")
respan = Respan(
api_key=respan_api_key,
base_url=respan_base_url,
instrumentations=[OpenAIInstrumentor()],
)
client = OpenAI(
api_key=respan_api_key,
base_url=f"{respan_base_url}/api/openai",
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
respan.flush()
4. View Dashboard
After running the script, traces appear on your Respan dashboard.
Further Reading
See the examples/openai-sdk/ directory for runnable examples including streaming, tool use, Responses API, and gateway routing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file respan_instrumentation_openai-1.0.1.tar.gz.
File metadata
- Download URL: respan_instrumentation_openai-1.0.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.9.6 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
337f0984e9b31b3b4e4656c24a01ace3ae1cd86b2bb1bd5147360648d6212582
|
|
| MD5 |
e35da7c79b3605bdd852e7a7c0b49048
|
|
| BLAKE2b-256 |
586900d06959c993e5570127c3da1b3b00cc93b674d1f5510691740f7c12ad43
|
File details
Details for the file respan_instrumentation_openai-1.0.1-py3-none-any.whl.
File metadata
- Download URL: respan_instrumentation_openai-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.9.6 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ee9954bda377fdc6321add901348bc909bbd5c6d425d8288ef0297af406f233
|
|
| MD5 |
e60d88bf799c8f88737c4e93bc50a696
|
|
| BLAKE2b-256 |
0e51f4a1d76435a65aebd6804f110cdef0bc22aac71db71a81c5822aa2757062
|