OpenAI SDK (tracing)
OpenAI SDK (tracing)
The OpenAI SDK is the official client for OpenAI’s APIs, available for both Python and TypeScript/JavaScript. It supports Chat Completions and the Responses API. Respan gives you full observability over every OpenAI call, streamed response, and tool invocation — and gateway routing to 250+ models with prompt management.
Set up Respan
Create an account at platform.respan.ai and grab an API key.
Run npx @respan/cli setup to set up with your coding agent.
Use Respan Gateway
See OpenAI SDK gateway setup to route this integration through the Respan gateway.
Example projects
Setup
Configuration
Attributes
In Respan()
Set defaults at initialization — these apply to all spans.
With propagate_attributes
Override per-request using a context scope.
Decorators (optional)
Decorators are not required. All OpenAI calls are auto-traced by the instrumentor. Use @workflow and @task (Python) or withWorkflow and withTask (TypeScript) to add structure when you want to group related calls into a named workflow with nested tasks.
Examples
Streaming
Streaming responses are auto-traced like regular completions.
Tool calls
Function calling is auto-traced. Wrap the workflow with @workflow and @task decorators for a structured trace tree.
Structured output
JSON mode with Pydantic models is auto-traced.