Skip to main content

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:

Metadata

Release files for respan-instrumentation-instructor 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for respan-instrumentation-instructor 0.1.1
File Size Uploaded
respan_instrumentation_instructor-0.1.1.tar.gz 9.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for respan-instrumentation-instructor 0.1.1
File Interpreter ABI Platform
respan_instrumentation_instructor-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.2 kB

Release files / respan_instrumentation_instructor-0.1.1.tar.gz

Download URL respan_instrumentation_instructor-0.1.1.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
eba7b1bffdd76d2271494af4363b037da23b0174ad17c1d1625cba9f17d36a07
BLAKE2b-256 checksum
How to use checksums
6000fe0eca37c432e7c63d19c7e17bcf78f90bfad9933b8c816f60a4eb4023b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / respan_instrumentation_instructor-0.1.1-py3-none-any.whl

Download URL respan_instrumentation_instructor-0.1.1-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a6365c1a88caaecce58b1901402da7ea3bb23647f49f32d1136e9a35fe900bb
BLAKE2b-256 checksum
How to use checksums
8bd69df4ebae89eb27f954f9624b1d30f94d9bf4f883fbba4e18e7fb42756a6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page