Documentation
TypeScript SDK
Track Vercel AI SDK calls with a single wrapper.
TypeScript SDK
The TypeScript SDK integrates with the Vercel AI SDK and Next.js server actions.
Getting started
1. Install
bun add @revenuetrack/core @revenuetrack/ai
2. Set environment variables
REVENUETRACK_API_KEY=rt_...
3. Track AI SDK calls
import { init } from "@revenuetrack/core";
import { track } from "@revenuetrack/ai";
import { anthropic } from "@ai-sdk/anthropic";
import { generateText } from "ai";
init(); // reads REVENUETRACK_API_KEY
const { text } = await generateText({
model: track(anthropic("claude-sonnet-4-20250514")),
prompt: "Hello!",
});
console.log(text);
Wrap your model with track() and all calls are tracked automatically. Events are auto-flushed in the background.
What gets recorded
- Token usage (prompt/completion/total)
- Latency and status
- Provider, model, and operation name