1. Install
The base package pulls in no provider SDKs. Requires Node 20+.
pnpm add @mv37/rolloutIf you instrument a provider, add it as an optional peer where you need it — for example the OpenAI SDK or the Vercel AI SDK:
pnpm add @mv37/rollout openaipnpm add @mv37/rollout ai # Vercel AI SDK2. Get an API key
Create a project in your Rollout workspace and copy its API key. The SDK reads ROLLOUT_API_KEY from the environment by default:
export ROLLOUT_API_KEY="rl_..."export ROLLOUT_ENVIRONMENT="production" # optionalHeads up
The TypeScript SDK is server-side. Never expose a Rollout workspace API key in a browser bundle — instrument from a route handler or edge function instead.
3. Initialize a client
Create a Rollout client and pass it around, or call rollout.init() once for a global client the module-level helpers route through. Both read the same options from arguments or the environment.
import { Rollout } from "@mv37/rollout";// explicit clientconst rollout = new Rollout({ agentName: "support_agent", environment: "production" });// — or — one global client for the whole processimport * as rolloutMod from "@mv37/rollout";rolloutMod.init({ agentName: "support_agent", environment: "production" });4. Send your first trace
A trace is one agent run. Open it with a callback, record the conversation with trace.message(...), wrap model calls in a span, and record usage. The trace flushes when you shut down.
import { Rollout } from "@mv37/rollout";const rollout = new Rollout({ agentName: "support_agent" });await rollout.trace("support_agent", async (trace) => { trace.message({ role: "user", content: "Where is my order?" }); await trace.span("llm", async (span) => { span.recordInput({ messages: [{ role: "user", content: "Where is my order?" }] }); span.recordOutput({ content: "Your order has shipped." }); span.setUsage({ input_tokens: 120, output_tokens: 24 }); }, { name: "model.call", model: "gpt-4.1-mini", provider: "openai" }); trace.message({ role: "assistant", content: "Your order has shipped." }); trace.feedback("thumbs_up", true);});await rollout.shutdown();5. Verify the connection
check() sends a short completed diagnostic trace through POST /v1/events:batch — the fastest way to confirm your key and base URL work:
const result = await rollout.check();console.log(result.ok, result.message);Next steps
- Wrap the Vercel AI SDK to instrument
generateText/streamTextwithout writing span blocks by hand. - Record manual provider spans for the OpenAI JavaScript SDK.
- Run on the edge — request-scoped tracing for Vercel Edge and Workers.
- Optimize a TypeScript agent with a fetch-handler target.