vantageaiops
LLM cost tracking and AI API monitoring SDK for TypeScript and JavaScript.
Track token usage, cost, latency and quality for OpenAI, Anthropic, Google and Mistral — with one line of code.

Install
npm install vantageaiops
npm install openai
npm install @anthropic-ai/sdk
Quickstart — OpenAI
import { init, createOpenAIProxy } from "vantageaiops";
import OpenAI from "openai";
init({ apiKey: "vnt_your_key" });
const openai = createOpenAIProxy(new OpenAI());
const res = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello!" }],
});
Quickstart — Anthropic
import { init, createAnthropicProxy } from "vantageaiops";
import Anthropic from "@anthropic-ai/sdk";
init({ apiKey: "vnt_your_key" });
const client = createAnthropicProxy(new Anthropic());
const res = await client.messages.create({
model: "claude-3-5-sonnet-20241022",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello!" }],
});
Manual tracking
import { getClient } from "vantageaiops";
getClient().capture({
eventId: crypto.randomUUID(),
provider: "openai",
model: "gpt-4o",
promptTokens: 500,
completionTokens: 120,
totalCostUsd: 0.0035,
latencyMs: 842,
team: "search",
environment: "production",
});
Agent / multi-step traces
import { init, trace } from "vantageaiops";
import OpenAI from "openai";
init({ apiKey: "vnt_your_key" });
const traceId = crypto.randomUUID();
const step1 = await trace(
() => openai.chat.completions.create({ model: "gpt-4o", messages: [...] }),
{ traceId, spanDepth: 0, team: "agent" }
);
const step2 = await trace(
() => openai.chat.completions.create({ model: "gpt-4o-mini", messages: [...] }),
{ traceId, spanDepth: 1, team: "agent" }
);
Traces appear in the Agent Traces tab of your dashboard with per-span cost breakdown.
Cost calculator
import { calculateCost, findCheapest } from "vantageaiops";
const cost = calculateCost("gpt-4o", 10_000, 2_000);
console.log(`Cost: $${cost.totalCostUsd.toFixed(4)}`);
const alt = findCheapest("gpt-4o", 10_000, 2_000);
console.log(`Save ${((cost.totalCostUsd - alt.costUsd) / cost.totalCostUsd * 100).toFixed(0)}% with ${alt.model}`);
Configuration
import { init } from "vantageaiops";
init({
apiKey: "vnt_your_key",
org: "acme",
team: "platform",
environment: "production",
ingestUrl: "https://api.vantageaiops.com",
flushInterval: 2,
batchSize: 50,
debug: false,
});
Links