Setup
npm install @tokeven/sdk
export TOKEVEN_INGEST_TOKEN=tkv_ing_...import Anthropic from "@anthropic-ai/sdk";
import { wrap } from "@tokeven/sdk";
const client = wrap(new Anthropic()); // same client, same return valueswrap() also takes an OpenAI client, an OpenAI client pointed at https://api.x.ai/v1 for Grok, or a Google GenAI client.
What it captures
Input, output and cache tokens, modality, tool name and latency for each call, streaming included. Cost is computed by the Tokeven server. Prompt content never reaches Tokeven.
Serverless and edge
Runs on Node 20.16+, Vercel and Cloudflare edge, Deno and Bun. Call await flush() before a serverless or edge handler returns, since background timers do not outlive the request there.