See where your AI spend goes.
Marginal tracks the cost of every LLM call and slices it by the fields you care about — customer, feature, environment, model.
import { Marginal } from "marginal-sdk";
const marginal = new Marginal({ apiKey: process.env.MARGINAL_API_KEY });
const response = await openai.chat.completions.create({ /* … */ });
marginal.track({
provider: "openai",
model: response.model,
usage: response.usage,
fields: { customer: "acme-corp", feature: "support-bot" },
});One call per LLM request — the cost is computed server-side from the model price catalog.
Slice by any field
Register your vocabulary — customer, feature, environment — and group or filter spend by it. Unregistered keys are stripped and reported back, so dashboards stay clean.
LLM-aware pricing
Send provider, model, and the response's usage object; cost is computed server-side against a daily-synced model price catalog. Unpriced models are surfaced, never a silent $0.
SDKs that stay out of the way
TypeScript and Python, zero dependencies, buffered and fire-and-forget. track() never throws and never blocks your request path.