Spanlens Docs
LLM observability in 60 seconds. Record every OpenAI, Anthropic, and Gemini call with cost, latency, full request/response, agent traces, PII detection, and cheaper-model suggestions.
Drop this into your app
import { createOpenAI } from '@spanlens/sdk/openai'
const openai = createOpenAI() // reads SPANLENS_API_KEY from env
const res = await openai.chat.completions.create({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'Hi' }],
})tsAlready have OpenAI / Anthropic / Gemini calls in your code? npx @spanlens/cli init rewrites them in one pass. See the Quick start for both paths.
What's in the docs
Quick start
30-second wizard setup or manual integration in two lines of code.
@spanlens/sdk
TypeScript and Python SDK reference: createOpenAI, observe, span helpers, trace API.
@spanlens/cli
One-command setup: AST-rewrites every OpenAI / Anthropic / Gemini call to use Spanlens. Dry-run safe.
Direct proxy (any language)
Use Python, Ruby, Go, or raw HTTP. Just swap the base URL.
OpenTelemetry (OTLP)
Already using an OTel SDK? Point it at Spanlens. Python, Go, Java, Node.js all work.
Self-hosting
Run Spanlens on your own infra with one Docker command. Your data stays yours.
Frequently asked
Does Spanlens add latency to my requests?
Typical overhead is 10–50ms per call, a thin pass-through proxy. Your requests flow to OpenAI / Anthropic / Gemini and responses stream back. Logging is fire-and-forget via Vercel's waitUntil, so it never blocks the response.
Is my provider key safe?
Yes. Provider keys are AES-256-GCM encrypted at rest in your Supabase. They're only decrypted in memory when forwarding a request, never logged. For extra control, self-host.
Can I run Spanlens alongside my existing Langfuse / Helicone setup?
Yes. Spanlens is a drop-in replacement at the baseURL level. Keep both running side-by-side during migration, then turn the other off. Why Spanlens vs Helicone / Langfuse →
Looking for Privacy, Terms, DPA, or Subprocessors? All four live in the footer of every page. For a countersigned DPA or a security questionnaire, email support@spanlens.io.