Use case
How to track AI cost per customer
The provider invoice is one number for your whole company. Here is how to split it by customer.
Send a x-customer-id header on every request you proxy through Spendline. Spendline resolves the cost of that call the moment it happens and records it against that customer ID in an append-only ledger, no batch job, no end-of-month reconciliation guesswork.
How Spendline does this
Every proxied call already carries the provider, model, and token counts needed to price it. Spendline adds one more piece: the x-customer-id header your application sends alongside the request. That triple, cost, customer, timestamp, is written to the ledger (ai_calls) as the call completes, using a server-controlled timestamp so a client can never misattribute which month or which customer a call belongs to.
x-customer-id: cust_4f21aWhy it matters
Without per-call attribution, "cost per customer" is a spreadsheet exercise someone reconstructs manually from provider logs, usually wrong, always late, and useless for a customer that churns mid-month. With it, the number exists the instant the call is made.
Frequently asked questions
What if a call cannot be tied to one customer, a background job, for example?
Tag it with whatever dimension is true for it (a workflow, a team, a cost centre) using x-spendline-tags, or leave it untagged and it still appears in the aggregate ledger. Attribution is per-header, not all-or-nothing.
Does this work across more than one AI provider?
Yes. The same x-customer-id header works whether the call goes to OpenAI, Anthropic, or any of the other providers Spendline proxies, so per-customer cost is comparable across providers in one ledger rather than reconstructed from separate invoices.
See where this stands in your own setup
This page describes the mechanism. The 5 minute assessment scores your own attribution, enforcement, and reconciliation setup, so you know exactly which of these problems you actually have today.
Run the 5 minute assessment