Skip to main content

LiteLLM AI Gateway

Customer Management

Budget and charge your agent's customers.

Agent trafficAI GatewayMeter cost · Apply budgets{ } Usage APICustomer ManagementCustomer ManagementUsage chargesBudgetCustomer organizationAcme$750.00$1,000Customer teamSupport$192.00$250Customer memberAlice$39.00$50Same request. Three levels of attribution.Illustrative customer traffic · $0.50 per highlighted request

Illustrative customer traffic flows through LiteLLM into Customer Management. Organization, team, and member budgets use three views of the same request cost.

Today we're launching LiteLLM Customer Management for AI-native companies using the gateway. If you're building an agent on LiteLLM and need to track spend and set budget limits for your customers by their organizations, teams, and individual members, this is for you.

Who is this for?​

For AI-native companies building production agents using LiteLLM AI Gateway who need to run their agents profitably, with positive ROI.

The problem​

With B2B AI agents, cost tracking gets complicated across customer organizations, teams, and individual members. If you sell pay-as-you-go credits or usage-based plans, actual spend can exceed what your customer paid and hurt your margin.

Customer credits and spend
Before customer budgets
$100
Customer CreditsActual spend

Actual spend exceeds the credits your customer bought.

Credits shown at their purchase value. Illustrative profit margin excludes other expenses.

Different models, providers, and request parameters multiply that complexity.

B2B agent costs
ModelsProvidersParameters
Model, provider, and parameter combinations add more costs to track.

Track that spend by customer organization, team, and member:

Your customers
Customer organizationSalesCustomer teamEngineeringCustomer teamCustomer memberCustomer memberCustomer memberCustomer memberCustomer organizationSalesCustomer teamEngineeringCustomer teamCustomermemberCustomermemberCustomermemberCustomermember
The blue path links a customer's member to their team and organization.

That's a bunch of glue code to build around your agent. Since LiteLLM is already your source of truth for model costs, we're exposing APIs to track customer spend, set budgets, and build these controls into your product.

How to use LiteLLM AI Gateway for this problem​

Point your agent to LiteLLM AI Gateway and send your customer's organization alias and member ID:

import os

from openai import OpenAI

client = OpenAI(
api_key=os.environ["LITELLM_API_KEY"],
base_url=f"{os.environ['LITELLM_BASE_URL'].rstrip('/')}/v1",
)
raw_response = client.responses.with_raw_response.create(
model=os.environ["LITELLM_MODEL"],
input="Write a short welcome message.",
max_output_tokens=128,
extra_headers={
"x-litellm-customer-org-alias": "Acme",
"x-litellm-customer-member-id": "acme-alice",
},
)
response = raw_response.parse()
print(response.output_text)
print("LiteLLM call ID:", raw_response.headers.get("x-litellm-call-id"))

Install with pip install openai.

That's it for attributing the call. LiteLLM resolves the member's customer team and organization and records the spend. The same headers work with Responses, Chat Completions, and Anthropic Messages.

Use your application key and a gateway model alias. LITELLM_BASE_URL is the gateway root URL; register the customer first, and select their identity from your authenticated session.

A saved request's Customer section shows its customer organization, team, and member, alongside $0.14 cost and 120 tokens in Metrics.
Follow a request into spend logs to see its customer organization, team, member, and cost. Demo data. View full size.

Set customer budgets that protect your margin​

If a member buys $100 in credits, set a $60 budget for actual spend to protect your margin. Set separate budgets for the customer organization, each team, and each member:

Customer budget checksLiteLLM
% of each entity budget$100 in member credits
Customer
organization
$360/ $1,000
$640 left
Customer
team
$160/ $250
$90 left
Customer
member
$60/ $60
Limit reached
Member cap reached · Requests pausedProfit margin 40% after actual spend
Illustrative overlapping views of the same member usage. Do not add organization, team, and member spend together.

The same request's cost rolls up from the member to their team and organization. Here, the member hits their $60 cap while both parents still have room, so further requests pause.

Choose the organization cap and default member profile when you onboard a customer. These examples use a 30-day budget period:

curl --fail-with-body --request POST \
"$LITELLM_BASE_URL/management/v1/customer_organizations" \
--header "Authorization: Bearer $LITELLM_ADMIN_KEY" \
--header "Content-Type: application/json" \
--data '{
"customer_org_id": "org-acme",
"alias": "Acme",
"budget": {
"max_budget": 1000,
"budget_duration": "30d"
},
"default_budgets": [{
"name": "default-user",
"max_budget": 60,
"soft_budget": 48,
"budget_duration": "30d"
}],
"default_budget_template": "default-user"
}'

Use a server-side proxy admin credential as LITELLM_ADMIN_KEY. Add the customer's teams and members; new members inherit the default profile.

Customer member spend in the latest LiteLLM UI, with monthly and yearly budget windows, share of customer spend, tokens, and status.
Customer member spend and budget windows in the latest LiteLLM UI. Seeded demo data. View full size.

At the cap, LiteLLM rejects new requests based on recorded spend. Leave room for accounting delays and requests already in flight.

Give default users and power users different profiles​

Some customers need more allowance. Create a power-user profile, then assign its returned budget_id when you create new members. Use the same APIs in your product so your customer's admins can manage these profiles.

curl --fail-with-body --request POST \
"$LITELLM_BASE_URL/management/v1/customer_organizations/org-acme/default_budgets" \
--header "Authorization: Bearer $LITELLM_ADMIN_KEY" \
--header "Content-Type: application/json" \
--data '{
"name": "power-user",
"max_budget": 90,
"soft_budget": 72,
"budget_duration": "30d"
}'

Trigger a webhook when a customer hits their limit​

Customer credits and spendLiteLLM
Budget alert → temporary increase
$150
Customer CreditsActual spend
Budget cap: $90
CapWebhookApproved increase
Credits shown at their purchase value. Illustrative profit margin excludes other expenses. Your receiver formats Slack alerts; your app approves increases.

When a member reaches their $60 cap, use the budget webhook to alert your team or open an approval request. Your receiver formats the notification from LiteLLM's JSON event. Configure and test delivery; reconcile missed alerts with usage reads because delivery is best effort.

Approve a temporary increase when your customer upgrades​

When the customer buys another $50 in credits, their total becomes $150. After approval, apply a temporary $90 cap on actual spend, as shown above.

Set INCREASE_EXPIRES_AT to a future timestamp with a timezone, then apply the temporary member override:

curl --fail-with-body --request PATCH \
"$LITELLM_BASE_URL/management/v1/customer_members/acme-alice" \
--header "Authorization: Bearer $LITELLM_ADMIN_KEY" \
--header "Content-Type: application/json" \
--data "{
\"budget_override\": {\"max_budget\": 90},
\"budget_override_expires_at\": \"$INCREASE_EXPIRES_AT\"
}"

Your product manages credit purchases and balances. LiteLLM applies the spend allowance until it expires; the organization and team caps still apply. Use the approval APIs if your workflow needs a review queue.

Put the usage and budget controls in your own product​

Put usage next to the customer's credits and top-up options. Our APIs let your backend fetch actual spend and budget settings, so the customer sees the same costs you use for chargebacks:

Customer organization usage in the dark LiteLLM UI, with spend and token totals and a daily trend across three models.
Demo usage across three models, with 13 days of activity. Track the customer's total and inspect the model costs behind it. View full size.

Fetch complete organization totals for a date range:

curl --fail-with-body --silent --show-error --get \
"$LITELLM_BASE_URL/management/v1/customer_organizations/daily/activity/aggregated" \
--header "Authorization: Bearer $LITELLM_ADMIN_KEY" \
--data-urlencode "customer_org_ids=org-acme" \
--data-urlencode "start_date=2026-11-01" \
--data-urlencode "end_date=2026-11-30"

Read metadata.total_spend, total_tokens, and total_api_requests. Fetch caps from the organization, team, and member records; keep admin credentials on your backend and authorize each customer's access. Your billing system applies your prices and collects payment.

Keep serving requests with a lower-cost model​

Give a customer's dedicated virtual key an Opus allowance, then configure a lower-cost fallback for when that model allowance runs out. The customer can keep using your agent while they still have room in their overall budget.

Model budget fallback
AnthropicOpus 5.5Allowance reached
LiteLLM GatewayRoutes the next request
OpenAIGPT-6 LunaServing requests
$100
Customer Credits
$50
Actual spend

Opus: $40 / $40 allowance

Fallback: $10 spend

50% profit margin$10 left in customer budget
Illustrative recorded spend and purchased credit value, before other expenses. Per-model key allowances trigger the switch; customer hard caps still apply.

Set model_max_budget and budget_fallbacks on the key with your configured model aliases. These per-model key budgets require Enterprise. A shared key pools its model budget across callers; customer organization, team, and member hard caps still stop requests when exhausted. See Budget Fallbacks for the API setup.

OSS and Enterprise​

Customer ManagementLiteLLM OSSLiteLLM Enterprise
Customer organizationsUp to 5More than 5
Customer teams per organizationUp to 5More than 5
Customer members per teamUp to 5More than 5

Start with the walkthrough and API reference. For larger customer hierarchies, talk to us about Enterprise.

This draft targets main; a published release containing the complete flow has not been verified. Check availability before deploying.