Otis SDK
TypeScript SDK for tracing AI applications, custom functions, and user events.
The Otis SDK (@runotis/sdk) traces AI operations, custom functions, and user events from your app. It works in Node.js, serverless runtimes, and the browser, with first-class Next.js support.
Instrument your products with AI
Otis provides several paths to integrating the SDK and instrumenting your apps using coding agents.
Framework integration guides
Start here to manually integrate the SDK. Each guide is self-contained — follow it end to end and your integration will be correct the first time.
Next.js on Vercel
App Router, streaming chat routes, server + browser.
Node.js server
Long-running servers (Express, Fastify, Hono, NestJS, Node adapters).
Serverless functions
AWS Lambda, Cloudflare Workers, Netlify, Firebase Functions.
Framework reference
Init patterns for Remix, SvelteKit, Nuxt, Astro, NestJS, and more.
MCP servers
Instrument an MCP server so calling agents record intent and file tool feedback.
CLI tools
Instrument a Node CLI so agents like Claude Code record intent and outcomes when they run it.
OpenTelemetry
Integrate with an existing OpenTelemetry setup or OTLP pipeline.
SDK Reference
Deeper details on each part of the SDK. Read these when you want to go beyond what the integration guide covers.
Sessions
Session and chat IDs, auth provider pass-through, cross-domain handling.
Identity and properties
User and group identity, properties, browser identity hook.
Agent traces
wrap(), traced(), span.log, supported AI frameworks.
Custom events
Record user actions and feature usage.
Funnels and artifacts
Record the stages an artifact moves through, and tie AI work to it.
Plan and revenue
Record plan changes and revenue from your billing code.
Errors and exceptions
How Otis records failures, and reporting your own errors.
Feedback signals
Link user ratings and corrections to specific AI responses.
Browser and consent
Cookie identity, GDPR consent, CMP integrations.
Privacy
Client-side and server-side PII redaction, identifier hashing.
Customization
Configuration, beforeSend, debug logging, SDK exports.
What gets captured
Otis is privacy-first
By default, Otis redacts Personally Identifiable Information (PII), and user, session and other identifiers are pseudo-anonymized. Otis also makes it simple to follow consent processes for browser cookies to ensure GDPR compliance.
With otis.wrap(ai) around your AI framework:
- Prompts and responses (user-facing messages, not internal system prompts unless you enable it)
- Model ID and provider
- Token usage (input, output, cache)
- Tool calls with inputs and outputs
- Streaming metrics — time to first token, total duration, tokens per second
- Errors with stack traces
With context passed to wrap() or withContext():
- User, session, chat, and document IDs
- Group memberships (e.g. company, team)
- Custom metadata
With sendEvent(), identifyUser(), sendFeedbackSignal():
- Custom events (document exports, feature usage)
- User identity and persistent properties
- Feedback linked to specific AI responses