Why end customer tracking in LiteLLM needs a deliberate design
If your SaaS product calls AI features through a shared LiteLLM gateway, you need to decide how each request is attributed to one of your own customers before you set any per-customer budget. LiteLLM can record spend and usage against an end customer, enforce budgets and rate limits per customer, and show the result in the Admin UI, but it can only do this for requests it can tie to a customer identity. The attribution happens per request, so the design choice is which identifier your application sends and where that identifier comes from.
Team and key budgets answer a different question. A team budget caps what an internal group spends, and a key budget caps what one application or person can spend. These controls work well when your own staff or services are the callers. They are the wrong unit when one virtual key serves thousands of your customers, because a single key budget then covers everyone at once and tells you nothing about which customer drove the cost. Per-customer tracking is the layer to add when your customers, not your departments, are the billable or limited party.
Confirm three things with your engineering team before rollout: which header or field your application will send on every call, whether any caller can supply that value directly, and which LiteLLM version you run. The customers documentation covers the identification order and the JWT claim option, and the LiteLLM customers docs is the natural next read. Customer Usage, which shows per-customer spend in the Admin UI, is available from v1.80.8-stable, so confirm your release line before you plan dashboards around it.
Which identity source fits which application
This table compares the customer identity sources LiteLLM reads, showing who sets each one, whether a caller can change it, and which application pattern it suits. Read it from the top down, since LiteLLM checks sources in a fixed order and a verified JWT claim overrides the rest. The main takeaway is that only the verified JWT claim is tamper-resistant, so client-set values should be used only where the caller is trusted.
| Identity source | Who sets it | Can the client spoof it? | When it fits |
|---|---|---|---|
| x-litellm-customer-id header | Your backend or gateway proxy | Yes, if callers reach LiteLLM directly | Server-to-server calls where your service attaches the customer ID |
| x-litellm-end-user-id header | Your backend or gateway proxy | Yes, if callers reach LiteLLM directly | Apps that already send an end-user identifier on each request |
| Configured custom headers | Your backend, mapped by your LiteLLM config | Yes, if callers reach LiteLLM directly | Existing services that pass a header name you already use |
| OpenAI user field | Client SDK or application code | Yes, the client chooses the value | Low-risk attribution where the caller is your own code |
| Metadata fields | Client request body | Yes, the client chooses the value | Tagging and reporting, not for enforcing budgets |
| Verified JWT claim (end_user_id_jwt_field) | Your identity provider, inside a signed token | No, when the token signature is verified | End-user apps where the customer must be trusted for budgets |
| Network-restricted gateway access | Your network controls | Harder, when only your backend can reach LiteLLM | Multi-tenant products where end users never call LiteLLM directly |
Setting budgets and rate limits per customer
Per-customer budgets and rate limits sit alongside the virtual key, team and rate limit settings that already govern your gateway. The decisions below determine whether a customer's spend is capped on its own, whether it draws down a shared pool, and what the caller sees when a limit is reached.
Confirm what the customer budget covers
Customer Usage in the Admin UI shows per-customer spend and supports budgets and rate limits per customer, from v1.80.8-stable. Before you rely on it, confirm with your own test deployment whether a customer budget is enforced in addition to, or instead of, the key and team budgets the request also passes through. Record the answer, because it sets what a customer can actually consume.
Customer usage docsShared keys or per-customer keys
A shared product key with customer IDs in the request is simpler to issue, but every customer then draws on the same key budget and rate limits. Per-customer virtual keys isolate limits cleanly but multiply the keys you must rotate and track. Decide which model fits your customer count, and test that a noisy customer cannot exhaust the limits of the others.
Budget reset handling
Budgets reset on a schedule you define, and the reset point decides how customer billing periods line up with gateway spend. If your customers are billed on calendar months but budgets reset on a rolling interval, reported spend will drift from invoices. Confirm the reset interval and time zone for each budget, and reconcile one full cycle before you publish limits to customers.
Temporary increases for approved overages
Virtual keys support temporary budget increases, which suit a large customer with an approved one-off project. Treat each increase as an audited change with an owner and an expiry, not a permanent raise. Ask who in your organization may approve an increase, how it is recorded, and how the customer is told when the extra budget ends.
Model restrictions per customer tier
Keys can be restricted to specific models, so a free tier can be limited to a smaller model while a paid tier reaches a larger one. Map each customer plan to an explicit model list and test that a request for a disallowed model is refused before it reaches a provider. Note that model restrictions change cost exposure as much as access.
Behavior when a customer exceeds a limit
A customer that hits a budget or a TPM or RPM limit should receive a clear error that your application can handle, not a silent failure or a shared outage. Decide whether to block, queue, or downgrade to a cheaper model at the limit, then test each path with a deliberately low test budget. Confirm which error code and message callers receive before you document it for customers.
Setting up customer attribution on a LiteLLM gateway
This sequence takes a self-hosted LiteLLM gateway from a confirmed release to per-customer spend, budgets and rate limits that you can verify in the Admin UI before end customers depend on them.
Confirm the release supports Customer Usage
Your platform team checks the running LiteLLM version against the releases page and confirms it is v1.80.8-stable or later, since Customer Usage is available from that release. If the gateway is older, plan the upgrade on the supported release line before continuing, because the per-customer views and budgets described here depend on it. Done when the version reported by the running proxy, not only the version in your deployment manifest, matches or exceeds v1.80.8-stable.
Choose the customer identity source
Your product and security owners decide which value identifies a customer: a header your application sends on every request, a verified JWT claim from your identity provider, or a value carried in the OpenAI user field or metadata. Use a stable internal customer or account identifier, not an email address or a name that can change. Record the decision with the owner of the identifier, because LiteLLM will attribute spend to whatever value arrives first in its lookup order. Done when the team has one written identifier format and one named source for it.
Pass the customer identifier from the application
Application engineers add the chosen identifier to every model call. The simplest path is the x-litellm-customer-id header; LiteLLM checks that header first, then x-litellm-end-user-id, configured custom headers, the OpenAI user field and metadata fields. If you use JWT authentication, configure end_user_id_jwt_field so the verified claim takes precedence over the other sources. Ensure no path sends a second, conflicting identifier for the same customer. Done when a test call with a known identifier is accepted and the request reaches the gateway without errors.
Set budgets and rate limits per customer
Your platform team defines the spend budgets and TPM or RPM limits that apply to each customer, following the customer usage documentation for how budgets and rate limits are attached to a customer. Decide the default for customers who have no explicit limit, and decide who approves a budget increase. Keep the limit values in a configuration source your team controls so changes are reviewed. Done when a test customer with a deliberately low budget is blocked after the threshold is reached, and the block is recorded in the logs.
Verify attribution with test requests
Your QA or platform engineer sends test requests from at least two distinct test customer identifiers, using different models, then opens the Admin UI Customer Usage view. Confirm that each request's spend and token usage appears under the matching customer and nowhere else. Also send one request that carries conflicting identifiers across sources to confirm the lookup order behaves as your documentation says. Done when both test customers show only their own spend and the conflicting-identifier case is attributed to the value you expected.
Confirm spend reconciles with provider usage
Finance and platform engineering compare the per-customer totals from the test window against the provider usage reports for the same keys and models. Differences often come from pricing configuration, cached responses or requests that failed after partial generation, so note each one and its cause. Agree with finance on how gaps will be handled before any customer is billed from these figures. Done when the team has a written reconciliation for the test window and an owner for each unexplained difference.
Monitor customer usage and review limits
Platform operators check the Customer Usage view on a schedule agreed with the product owner and watch for customers approaching their budgets or rate limits. Review whether any identifier appears unexpectedly, which can indicate an application bug that sends the wrong value. Keep the test customers and their limits separate from production so that sample traffic does not distort reporting. Done when the review cadence, alert recipients and escalation path for limit breaches are documented and have been exercised at least once.
How a customer request is attributed before it reaches a model
The diagram starts at the client application, which sends an OpenAI-format request to the LiteLLM gateway. The gateway sits inside the trust boundary and verifies a JWT first when one is configured, because a verified claim takes precedence over every header. It then walks the customer lookup order, checks the customer's budget and rate limits, and only then calls the provider. Check that the gateway rejects unverified tokens and that spend is written against the same customer ID the lookup produced.
Request path from client application through the gateway to the provider and spend records.
Protecting customer identity from spoofing and cross-tenant leakage
Customer attribution is only as trustworthy as the place the customer ID comes from. The cards below cover the spoofing paths, the verification and stripping controls that close them, and the key and log decisions that keep one customer's spend and data from showing up in another's view.
Clients setting another customer's ID
Any caller that can reach the gateway can send an x-litellm-customer-id header, so a client can charge usage to a customer it does not serve. Treat the header as a claim the caller makes, not a fact. Before go-live, test with a key for one customer sending another customer's ID and confirm which spend record the request lands on.
Unverified headers and fallback fields
LiteLLM checks headers, the OpenAI user field and metadata in a fixed order, so a request that omits a higher-priority value falls through to a lower one. If your application forwards these fields from end-user input, a crafted value can redirect attribution. Strip or overwrite customer headers at your own edge and set them only from your authenticated session.
Verified JWT claims as the source of truth
When end_user_id_jwt_field points to a claim from a verified token, that claim takes precedence over headers and body fields. Confirm the JWT verification settings, including issuer, audience and signing keys, are configured on the gateway. A missing or misconfigured verification path leaves the header order in control.
Restricting who calls the gateway
Decide which keys may send customer identifiers at all. Service keys held by your backend should be the only keys that reach the gateway, and end users should never hold them directly. Keys that allow any model and any customer ID widen the blast radius of a leaked key, so scope each key to the team, models and budgets it needs.
Shared keys that hide customer boundaries
If many customers share one virtual key, the gateway sees one spender and per-customer budgets stop being enforceable. Customer usage views then show only what the application reports. Map each customer to a distinct identity path your gateway can verify, and review whether shared keys are acceptable for the data and contracts involved.
Customer usage docsCustomer identifiers in logs
Request logs, spend records and traces can carry customer identifiers, which may be personal data or reveal who your customers are. Decide which fields are stored, who can query them and how long they are kept. Confirm log content and retention with your privacy team before enabling per-customer reporting for other audiences.
Questions teams ask about per-customer budgets in LiteLLM
How much does it cost to set up per-customer budgets in LiteLLM?
No price is published for this work, and a quote follows from the written scope. The cost is driven by how many customer identities you must map, how many applications send traffic, whether customer identity arrives as a verified JWT claim, and how much reporting you need. Ask for the quote to separate one-time items (identity design, header or claim changes, test plan, documentation) from recurring items (upgrades, retainer support, ongoing testing). Ask which of those your own staff would still own after handover.
Can our internal team set up customer tracking in LiteLLM without a partner?
Often yes, if you have engineers who know your application's authentication flow and can run LiteLLM with PostgreSQL and, once more than one proxy instance runs, Redis 7.0 or newer. The hard parts are rarely the header itself. They are deciding which identifier is authoritative, making sure the application cannot spoof it, and testing budget exhaustion and rate limits per customer. Teams that lack a recent LiteLLM deployment or identity provider experience usually find those steps take the longest.
What do we need to provide for a per-customer budget engagement?
Expect to provide access to the application that calls LiteLLM, a staging environment, and someone who owns how customers are identified in your product. If customer identity comes from a JWT, you will also need access to the identity provider or a sample of its tokens, plus test accounts for several customers, including one that will hit its budget or rate limit. Confirm these items before scope is agreed, because missing access is a common reason work stalls.
What drives the time needed to track end customers in LiteLLM?
The main drivers are the number of customer identities and how they are issued, whether the JWT integration needs your identity provider configured, how many applications and environments must send the customer field, and what reporting leaders expect from the Customer Usage view. Changes to application code are usually quicker than agreeing on identity design with the people who own the customer model. Ask for the timeline to list each of these as a separate milestone with its owner.
Does LiteLLM need an Enterprise license to use JWT customer claims?
The page's researched facts say that Enterprise adds JWT authentication with identity provider tokens, so verifying a JWT claim as the customer identifier should be confirmed against your license edition before design begins. The end customer header and metadata fields are part of the customer identification order, but whether each option is available in your edition should be checked in the current LiteLLM documentation. Confirm this with the vendor before you commit the identity design.
How does SSO edition affect per-customer tracking in LiteLLM?
SSO for the admin UI is separate from customer tracking, but the edition you choose affects both. The admin UI supports Google, Microsoft Entra ID, Okta and generic OIDC, and from v1.76.0 SSO is free for up to 5 users, with an Enterprise license needed beyond that. Enterprise also adds SCIM and JWT authentication. If your admins are a small group, the free tier may cover them, while JWT-based customer identity may still require Enterprise. Ask for the edition comparison in writing.
Can a customer spoof another customer's ID, and how do we prevent it?
A customer can spoof an identifier if your application forwards a header from the browser without checking it. The safer pattern is to have your backend set the customer header or a verified JWT claim after authenticating the user, so callers cannot choose their own identity. Because LiteLLM checks headers in a fixed order and lets a verified JWT claim take precedence, the design should be tested by sending conflicting values. Ask the engineers to show that a forged header does not change the budget charged.
How DeployOpen scopes customer tracking on LiteLLM
DeployOpen starts this work with a written fixed scope that fixes the decisions most likely to change cost and timing: where the end-customer identity comes from, which fields the application sends, how budgets and rate limits are set per customer, and which application changes are in or out. The scope names the identity source (for example, whether a verified JWT claim configured with end_user_id_jwt_field supplies the customer ID or whether the application sends x-litellm-customer-id itself), the budget and rate limit model, the Customer Usage views your finance or product team will use, and the test cases that count as accepted. Deliverables and timelines are agreed in writing before work starts, so you can compare the quote against building the same thing with your own team.
Verification is part of the scope, not an afterthought. DeployOpen tests the precedence order with requests that carry conflicting identifiers, confirms that a customer's spend lands on the right record, checks that a per-customer budget blocks traffic at the expected point, and confirms that a tampered or unverified token cannot choose a different customer. Ask for those test cases by name in the quote. Also confirm with your own environment whether the Customer Usage view is available in the LiteLLM version you run, since that feature depends on a minimum release. Application changes such as header injection in your backend are usually the largest variable, so the scope should state which repositories and services are touched.
After go-live, the work can continue under an optional retainer covering LiteLLM upgrades, regression checks of customer attribution after each release, and periodic re-testing of budget and rate limit behavior as your customer base changes. A retainer is priced from the agreed scope and is separate from the one-time build. DeployOpen does not publish a price list, and this page does not claim certifications or partner status for LiteLLM or any other vendor.

