Respan instrumentation plugin for Instructor
Project description
respan-instrumentation-instructor
Respan instrumentation plugin for Instructor. This package instruments Instructor's native patch() and Instructor.create() paths directly and emits Respan-compatible chat spans without using openinference-instrumentation-instructor.
Configuration
1. Install
pip install respan-instrumentation-instructor
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/api. |
Quickstart
3. Run Script
import os
import instructor
from dotenv import load_dotenv
from openai import OpenAI
from pydantic import BaseModel
from respan import Respan
from respan_instrumentation_instructor import InstructorInstrumentor
load_dotenv()
respan_api_key = os.environ["RESPAN_API_KEY"]
respan_base_url = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api")
# Route OpenAI traffic through the Respan gateway.
os.environ["OPENAI_API_KEY"] = respan_api_key
os.environ["OPENAI_BASE_URL"] = respan_base_url
class UserInfo(BaseModel):
name: str
age: int
respan = Respan(
api_key=respan_api_key,
base_url=respan_base_url,
app_name="instructor-quickstart",
instrumentations=[InstructorInstrumentor()],
)
client = instructor.from_openai(OpenAI())
user_info = client.create(
response_model=UserInfo,
messages=[{"role": "user", "content": "Ada Lovelace is 36 years old."}],
model="gpt-4o-mini",
)
print(user_info.model_dump())
respan.flush()
4. View Dashboard
After running the script, traces appear on your Respan dashboard.
Further Reading
Runnable examples with full setup instructions:
- Python: python/tracing/instructor
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_instructor-0.1.0.tar.gz.
File metadata
- Download URL: respan_instrumentation_instructor-0.1.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.12 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67b5a4350e15959c2e742d15b03bed9cbd1ba752217484372ef31b3527464d36
|
|
| MD5 |
e8b19c3c09c518b4b9dda8f71a8466ca
|
|
| BLAKE2b-256 |
2a2e890d6ff8fcd37d0148a2fa23ed4bc82cd9e6aecf808a549ac93e04647811
|
File details
Details for the file respan_instrumentation_instructor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: respan_instrumentation_instructor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.12 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1a231c97af16eaeacc0242a051fd6807a99293135877f14d136e787a0973eeb
|
|
| MD5 |
4988a2f59b2a2d8feeb5aa4be8507c3e
|
|
| BLAKE2b-256 |
31347d904fdac58d1fdcd0d56d12e9b41e153e6485a18ec53ff6f10be07639dd
|