Back to docsRecipe
Per-customer LLM cost attribution
Track token consumption and compute cost per API key, customer ID, or project tag — without modifying your inference code.
Why this matters
LLM bills are opaque. A single $4k monthly invoice tells you nothing about which customer drove the spend. Meridian intercepts every request/response pair, extracts token counts from provider headers, and writes per-customer line items to your existing analytics stack.
How it works
- Deploy the Meridian sidecar on your inference hosts.
- Tag traffic with a header:
X-Meridian-Customer. - Meridian reads
x-ratelimit-remaining-tokensand usage headers from every provider response. - Cost is computed against your negotiated pricing table and emitted as structured logs or OTLP metrics.
Example output
{
"customer": "acme-corp",
"model": "gpt-4o",
"tokens_in": 12400,
"tokens_out": 3100,
"cost_usd": 0.087,
"timestamp": "2026-01-18T14:22:01Z"
}Next steps
Read the sidecar deployment guide to get Meridian running in your environment, then configure your pricing table in the dashboard.