How to Track Your Team's AI and API Spend
AI and API costs sprawl across teams and cards until an invoice surprises you. A lightweight way to track spend — an inventory, budgets, a usage ledger, automatic sync where providers allow it, and alerts before renewals and overruns.
To track AI and API spend across a team, start with an inventory of every paid API (owner, plan, budget, renewal date), record usage against each budget in one ledger — entered by hand, posted by a webhook, or synced from the provider's billing API where one exists — and alert at thresholds like 80% of budget and a week before each renewal. The goal isn't accounting precision; it's seeing an overrun while you can still act, instead of on the invoice.
Why AI spend is different
Most software costs are flat: seats times price. API costs, and AI costs especially, move with usage:
- Spiky. A new feature, a prompt that grew, or a loop that calls a model per row can double token use overnight.
- Scattered. Different teams sign up with different cards: one for OpenAI, one for Anthropic, a transcription API, a maps API, an email service.
- Invisible until billed. Provider dashboards exist, but nobody looks at six of them weekly.
The FinOps Foundation describes cloud financial management as bringing financial accountability to variable spend, with engineering, finance and product sharing responsibility. The same idea applies to APIs at small scale: someone owns each line, and everyone can see the total.
Step 1: the inventory
List everything you pay for:
| Field | Example |
|---|---|
| Product | Anthropic API |
| Owner | Priya (platform) |
| Plan / pricing model | Usage-based, monthly invoice |
| Monthly budget | $300 |
| Billing cycle / renewal | 1st of each month |
| Paid from | Engineering budget, company card |
| Used by | Support assistant, internal summarizer |
Most teams can't produce this list on request. Producing it is half the value: it finds forgotten subscriptions, duplicate tools and APIs nobody owns.
Step 2: a ledger of usage
For each product, record spend entries: date, amount, and optionally units (tokens, requests, emails). Three ways to fill it, in order of effort:
- Manual entries — someone enters the provider dashboard figure weekly. Crude, and enough to see trends.
- An ingestion webhook — your own services POST usage as they go (
{ product, amount, units }), authenticated with a per-product secret. Good for internal meters, like counting your own AI calls. - Provider billing APIs — some providers expose usage and cost programmatically. Anthropic, for example, documents a Usage and Cost API for organizations using an admin key. A scheduled job pulls daily totals.
LetRelay's API spend tracker supports all three, with optional connectors that sync OpenAI and Anthropic spend automatically. A self-reported ledger plus optional connectors means the tracker keeps working even when a connector breaks — which matters, because billing API shapes change.
Step 3: budgets and alerts
Budgets turn a ledger into decisions. For each product:
- Threshold alerts at, say, 50%, 80% and 100% of the monthly budget.
- Forecast alerts — if spend to date, extended to the end of the month, will exceed budget, say so now. A simple linear projection (spend so far ÷ days elapsed × days in month) catches most runaways by day five.
- Renewal reminders a week before annual renewals, with the owner named, so "do we still need this?" gets asked before the charge, not after.
The major clouds build the same mechanism into their billing — Google Cloud and AWS both offer budgets with threshold alerts — which is a good sign it's the right primitive. For APIs outside a cloud bill, you need your own.
Schedule the checks in the database (LetRelay uses pg_cron) so alerts don't depend on anyone opening the dashboard.
Step 4: protect the keys
Connectors need admin or billing keys for each provider, and those keys are powerful. Handle them like secrets:
- Encrypt at rest with an authenticated cipher. LetRelay uses AES-256-GCM (the mode NIST specifies in SP 800-38D) with the encryption key held in a server-only environment variable, not in the database.
- Never send them to the browser, even to admins. Show "key saved · ends in …7Q2" and a replace button.
- Use read-only or usage-scoped keys where the provider offers them.
- Fail safe. If a connector's key is revoked, the sync fails quietly, the connector shows an error, and everything else in the tracker keeps working.
Step 5: reduce spend, not just watch it
Visibility is step one. The usual savings, roughly in order of effort:
- Cancel what nobody uses — the inventory finds these.
- Right-size models. Routing, classification and extraction often work on a small, cheap model; save the large one for answers that need it. See a free AI gateway with Gemini and Groq failover.
- Shrink prompts. Token cost scales with prompt size. LetRelay cut its how-to prompt from 2,200–2,600 tokens to about 1,900 by sending fewer, more relevant guide pages.
- Cache repeated answers that don't depend on private data.
- Skip the model for inputs a rule can handle. More in the case for AI that degrades gracefully.
- Meter per team or customer so one heavy user is visible, and can be limited — see rate limiting without Redis.
A worked example: catching a runaway
A realistic scenario for a 40-person company:
- Day 1. The support team ships an AI summarizer that condenses long request threads for agents. Budget for the model API: $200 a month.
- Day 3. The ledger shows $48 spent. Projected month-end: $48 ÷ 3 × 30 = $480. The forecast alert fires: "Anthropic API projected at 240% of budget."
- Day 3, an hour later. The owner looks at the usage entries. The summarizer runs on every page view of a request, not once per request update — so each thread is summarized dozens of times a day.
- Day 4. The fix caches the summary and regenerates it only when a new message arrives. Daily spend drops by about 90%.
- Month end. $95 spent, under budget.
Without the forecast, the first signal would have been a ~$480 invoice four weeks later, and the conversation would have been about blame rather than a one-line cache. Note what made it work: an owner named on the line item, a budget, a daily data point, and an alert that projects rather than waiting for the threshold.
What not to build
A spend tracker is tempting to over-engineer. Skip:
- Per-request cost attribution across every service — valuable at scale, expensive to build; start with per-product totals.
- Exact reconciliation with invoices — finance does that monthly; the tracker's job is early warning.
- Dependence on any single billing API — they change and break. Manual entry must always work.
A monthly review in 15 minutes
- Spend vs budget per product; any over?
- The biggest month-over-month change, and why.
- Renewals in the next 30 days — keep, downgrade or cancel.
- Any product without an owner.
Write the outcome in one line per product. Over a few months, that history is what lets you forecast next year's budget instead of guessing.
FAQ
How do I track OpenAI and Anthropic API costs across a team?
Keep one inventory and ledger for all providers, sync spend automatically where a provider offers a usage or cost API, and add manual or webhook entries for the rest. Set monthly budgets with threshold and forecast alerts.
What's a good alert threshold for API budgets?
Alerts at 50%, 80% and 100% of the monthly budget, plus a forecast alert when the projected month-end spend exceeds the budget.
Should I store provider API keys in my database?
Only encrypted with an authenticated cipher like AES-256-GCM, with the encryption key outside the database, and never sent to the browser. Prefer read-only or usage-scoped keys.
How can I reduce AI API costs?
Use smaller models for simple tasks, shrink prompts, cache repeated non-private answers, skip the model when a rule suffices, and meter usage per team or customer.
Sources
Building Relay — the internal request desk with AI triage and SLA tracking.
Run your internal requests on LetRelay
AI triage, SLA-tracked queues, and bottleneck analytics — the help desk your team actually likes. Free to start.
Keep reading
LLM Tool Calling for Internal Assistants: Design Choices
How to give an internal AI assistant tools — reading workspace data with the user's permissions, formatting results for the model, native function calling vs a routing step, limits on how many tools run, and answers that stay inside the data.
Building a Multilingual Chatbot That Handles Romanized Text
Real users mix languages and scripts — Nepali in Devanagari and in Latin letters, Hinglish, English with local words. How to route, retrieve, parse dates and reply in the right script, with lessons from a production assistant.
Stop Your Product Chatbot from Hallucinating Features
A help chatbot that invents buttons, settings and features is worse than no chatbot. How we fixed ours — a feature registry checked against the real UI, retrieval that finds the right page, strict grounding rules, link guards and must-not-include evals.