@aivyuh/finops
v0.2.0
Published
V7 AI FinOps SDK — transparent cost telemetry for Anthropic and OpenAI clients
Maintainers
Readme
@aivyuh/finops
Transparent cost telemetry for Anthropic and OpenAI Node.js clients. Part of the V7 AI FinOps platform.
Wrap your existing AI SDK client in one line — @aivyuh/finops captures model, tokens, cost, and latency metadata and sends it to the V7 backend. It never reads or stores prompt or response content.
Install
npm install @aivyuh/finopsQuickstart
Anthropic
import Anthropic from "@anthropic-ai/sdk";
import { wrapClient } from "@aivyuh/finops";
const client = wrapClient(new Anthropic(), {
telemetryEndpoint: "https://finops-api.aivyuh.com/telemetry",
customerId: "cust-123",
apiKey: process.env.AIVYUH_FINOPS_KEY, // per-customer key, sent as X-API-Key
project: "my-app",
tags: { feature: "chat", team: "product" },
});
// Use the client exactly as before — all types and overloads are preserved
const message = await client.messages.create({
model: "claude-sonnet-4-6-20260320",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, Claude!" }],
});OpenAI
import OpenAI from "openai";
import { wrapClient } from "@aivyuh/finops";
const client = wrapClient(new OpenAI(), {
telemetryEndpoint: "https://finops-api.aivyuh.com/telemetry",
customerId: "cust-123",
project: "my-app",
tags: { feature: "search", team: "platform" },
});
// Use the client exactly as before
const completion = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello, GPT!" }],
});Configuration
| Option | Type | Required | Description |
|--------|------|----------|-------------|
| telemetryEndpoint | string | Yes | V7 telemetry ingest URL (https://finops-api.aivyuh.com/telemetry) |
| customerId | string | Yes | Your customer ID for cost attribution |
| apiKey | string | Yes* | Per-customer API key, sent as X-API-Key header. Required by the production V7 ingest endpoint. |
| project | string | No | Project name for grouping costs |
| tags | Record<string, string> | No | Custom key-value tags attached to every request |
| disableTelemetry | boolean | No | Set true to disable (useful in tests) |
Production API Endpoint
https://finops-api.aivyuh.com/telemetryPOST telemetry payloads are accepted with a 202 Accepted response. The endpoint is fire-and-forget — if unreachable, your application is unaffected.
How It Works
wrapClient()detects whether you passed an Anthropic or OpenAI client (duck-typing).- It monkey-patches
messages.create()(Anthropic) orchat.completions.create()(OpenAI). - After each successful call, it extracts usage metadata (model, tokens, latency) and estimates cost.
- A non-blocking
fetch()sends the telemetry payload to V7 — errors are silently swallowed. - Your original response is returned untouched.
Advanced: Individual Wrappers
If you only use one provider, import the specific wrapper to avoid unused type imports:
import { wrapAnthropic } from "@aivyuh/finops";
import { wrapOpenAI } from "@aivyuh/finops";Requirements
- Node.js >= 18 (uses native
fetch) @anthropic-ai/sdk>= 0.40.0 and/oropenai>= 1.50.0 as peer dependencies
License
MIT
