Framework guide
Vercel AI SDK
Record Vercel AI SDK calls as SupaTrace events from Node.
Python SDK: Beta. JavaScript SDK: Coming soon. pip install supatrace==0.1.0 (alpha, Python 3.10+). The JavaScript package is not published to npm. See SDK availability.
Record a call in source mode Coming soon
Source mode is the default. It makes no network request. The SDK checks your events against the server's batch rules and writes one file to a local spool for you to review. The example records the model name and token counts, not the prompt or reply.
npm install ./packages/supatrace-js # from the public repository root. Node 22 or later, ESM onlyimport { init } from "supatrace";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
const trace = init("support-bot", { spool: "./spool" });
const started = new Date().toISOString();
const { usage } = await generateText({ model: openai("YOUR_MODEL"), prompt: "Say hello." });
const result = trace.batch([
{ id: "req-1", time: started, kind: "request", name: "generateText", data: { model: "YOUR_MODEL" } },
{ id: "res-1", time: new Date().toISOString(), kind: "response", name: "generateText", data: { totalTokens: usage.totalTokens } },
]);
console.log(result.report.valid, result.report.path);The SDK reads and writes local files, so run it in a Node runtime such as a route handler or server action, not in the Edge runtime or the browser.
Review, then upload
Read the spooled file. Remove anything you do not want stored. Then upload it as shown in the quickstart. Batch limits apply.
AI SDK telemetry over OTLP Coming soon
The AI SDK can emit OpenTelemetry spans through a tracer you pass in its telemetry settings. With mode: "otlp", an endpoint, a key and the OpenTelemetry packages installed, the SupaTrace handle exposes such a tracer as trace.tracer. This JavaScript SDK tracer hand-off has not been run against the receiver. For a first trace, use a stock exporter from the OpenTelemetry guide.
npm install @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources
export SUPATRACE_OTLP_ENDPOINT="https://supatrace.dev" # SupaTrace SDK OTLP mode (Python Beta; JavaScript source only)
export SUPATRACE_API_KEY="YOUR_WRITE_KEY"import { init } from "supatrace";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
const trace = init("support-bot", { mode: "otlp" });
console.log(trace.capture.sending, trace.capture.skipped);
await generateText({
model: openai("YOUR_MODEL"),
prompt: "Say hello.",
experimental_telemetry: { isEnabled: true, tracer: trace.tracer },
});
await trace.close().shutdown;When the endpoint, the key or a package is missing, trace.capture.sending is false, trace.tracer is not set and trace.capture.skipped says why.