Why wrap() throws today
rollout.wrap() exists on the TypeScript core API but currently throws, because generic provider wrappers are not implemented yet. Until they are, instrument the OpenAI JS SDK with manual spans, or use wrapAISDK for Vercel AI SDK apps.
Note
The Python SDK does support rollout.wrap() for OpenAI and Anthropic — see Provider integrations. This limitation is specific to TypeScript.
An llm span by hand
Open an llm span inside your trace, record the input, make the provider call, then record the output and token usage off the response:
import OpenAI from "openai";import { Rollout } from "@mv37/rollout";const rollout = new Rollout({ apiKey: process.env.ROLLOUT_API_KEY });const openai = new OpenAI({ baseURL: "https://openrouter.ai/api/v1", apiKey: process.env.OPENROUTER_API_KEY,});await rollout.trace("support_agent", async (trace) => { trace.message({ role: "user", content: "Where is my order?" }); const completion = await trace.span("llm", async (span) => { const messages = [{ role: "user" as const, content: "Where is my order?" }]; span.recordInput({ messages }); const res = await openai.chat.completions.create({ model: "openai/gpt-4o-mini", messages, }); span.recordOutput(res); span.setUsage({ input_tokens: res.usage?.prompt_tokens ?? 0, output_tokens: res.usage?.completion_tokens ?? 0, }); return res; }, { name: "model.call", model: "openai/gpt-4o-mini", provider: "openai" }); trace.message({ role: "assistant", content: completion.choices[0]?.message.content ?? "", });});await rollout.shutdown();Tool spans
Record a tool call as a paired tool.call / tool.resultusing a tool span, passing the model's tool-call id so the two link to the assistant message:
await trace.span("tool", async (span) => { span.recordInput({ city: "Paris" }); const result = await getWeather("Paris"); span.recordOutput(result);}, { name: "get_weather" });Or use the AI SDK
If you are already on the Vercel AI SDK, prefer wrapAISDK — it records the LLM span, previews, usage, finish reason, and tool callbacks for you, so you do not write span blocks by hand.