Drop-in proxy for the OpenAI API. One line of code, every call captured.
Spanlens captures every OpenAI request your app makes — chat completions, embeddings, vision, audio, tool use, and structured outputs — without changing your business logic. Swap the SDK import or the baseURL and the existing OpenAI client keeps working with full observability layered underneath.
Sign up at spanlens.io and create a project. Copy the sl_live_* API key from the project dashboard.
The drop-in SDK preserves the OpenAI surface area — same methods, same types — and routes calls through Spanlens.
# TypeScript
npm install @spanlens/sdk
# Python
pip install spanlensReplace the OpenAI import with the Spanlens drop-in. No other code changes needed.
// Before
import OpenAI from 'openai'
const openai = new OpenAI()
// After
import { createOpenAI } from '@spanlens/sdk/openai'
const openai = createOpenAI() // reads SPANLENS_API_KEY from envIf you cannot install an SDK (Ruby, Go, Rust, raw HTTP), point the OpenAI baseURL at the Spanlens proxy and put your Spanlens key in the Authorization header.
curl https://api.spanlens.io/proxy/openai/v1/chat/completions \
-H "Authorization: Bearer sl_live_..." \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"hello"}]}'Every call lands in /requests within ~1 second with full body, model, tokens, latency, and cost. Filter, group, and replay.
Yes. Streaming chunks pass through to your client in real time via body.tee(), and Spanlens captures the full stream including usage data from the final chunk. Streaming responses count as one request.
Yes. Tool calls, tool results, parallel tool calls, and required tool use are all captured. The tool name, arguments, and outputs are visible in the request detail view and surface in agent tracing as separate spans.
Cost is calculated per request from input + output tokens against the model price table. OpenAI returns the dated variant name (gpt-4o-mini-2024-07-18) in the response, and Spanlens matches by exact dated name then falls back to prefix match. Updated model prices ship with each release.
Yes. Your OpenAI key is encrypted at rest with AES-256-GCM and never logged. It is fetched, decrypted, and immediately discarded on each proxy call. The decryption key is held in environment-only configuration.
Yes. Azure OpenAI endpoints are supported through the same proxy mechanism. Specify the Azure resource and deployment in your project settings, and the proxy routes to the right endpoint while logging the same shape of data.
Yes. Assistant runs are captured per LLM step, and thread + run + step IDs surface as tags so you can filter or pivot on them. Multi-step agent flows render as a span tree.
See every OpenAI call in your dashboard within 60 seconds.