Short answer: AI API cost tracking comes down to attribution. Give every service and environment its own key, tag every request with the feature (and, if it matters, the customer) it belongs to, and review spend weekly by model, project and person. Then the three questions you'll be asked (what are we spending, on what, and is it worth it) each have a one-screen answer. The LazySusan API does the bookkeeping for you: every response carries its cost, every request lands in a searchable log, and the dashboard breaks spend down by member, key, project, environment, model and provider.
This guide is for the engineering manager who owns the bill but doesn't want to own a spreadsheet.
The three questions you'll get asked
Sooner or later, finance or leadership will ask:
- What are we spending on AI? A number, by month, with a trend.
- On what? Which products, features and teams, and which models.
- Is it worth it? Cost per unit of something the business cares about: per ticket resolved, per document processed, per active customer.
The first one is easy with any provider. The second and third are where teams struggle, because the data you need has to be captured when the request is made. You can't reconstruct "which feature was this?" from a token count after the fact.
How an AI API request is priced
Before you track costs, it helps to know where they come from. A chat request costs:
input tokens × input rate + output tokens × output rate
Reasoning ("thinking") tokens count as output. Cached input, where a repeated prompt prefix is reused, is billed at a lower rate on models that support it. Images are priced per image and video per clip.
On LazySusan, rates are in credits, and 1 credit is $0.001. Here's what one typical request, about 1,500 tokens in and 400 out, costs on a few models from the rate card at the time of writing:
| Model | Credits per request | Per 100,000 requests |
|---|---|---|
| Claude Haiku 5.5 | about 0.4 | about $40 |
| GPT-6 Luna | about 0.4 | about $40 |
| DeepSeek V4.1 Flash | about 1.1 | about $107 |
| Gemini 3.8 Flash | about 3 | about $302 |
| Claude Sonnet 5.5 | about 8 | about $805 |
| GPT-6.1 Sol | about 8 | about $805 |
| Gemini 3.1 Pro | about 9 | about $897 |
| Claude Opus 5.5 | about 16 | about $1,610 |
| GPT-6 Astra | about 40 | about $4,025 |
The spread between the cheapest and the most expensive is roughly a hundred times. That one table explains most AI bills: the biggest cost driver isn't volume, it's which model the default points at.
Step 1: give every service its own key
Attribution starts with keys. One shared key makes every request look the same; one key per service and environment means the dashboard can tell production from staging and the support bot from search without anyone tagging anything.
On LazySusan, every API account is a team. Invite developers by email, and each key is created with a project (such as support-bot) and an environment (production, staging, development or test). How to give every developer their own API key has a naming convention and a policy you can copy.
Step 2: tag every request
Keys tell you which service. Tags tell you which feature, customer or experiment. Add metadata to any chat, image or video call:
const r = await ls.chat.create({
model: "google/gemini-3.8-flash",
messages,
maxTokens: 500,
metadata: {
feature: "ticket-summary",
customer: account.id,
plan: account.plan,
},
});
// Every response says what it cost
log.info({ requestId: r.requestId, credits: r.usage.costCredits });You can add up to 16 tags per request. Keys are 1 to 40 letters, digits or _ . : -, and values are strings up to 200 characters. Don't put secrets or personal data in tags; an account id is fine, an email address isn't.
The tags worth standardising across the codebase:
- feature: the product surface (
ticket-summary,draft-reply,search-answer) - customer: your account id, if you want cost per customer
- experiment: for A/B tests and model bake-offs, so you can exclude them from baselines
A small wrapper that adds the standard tags makes this automatic, and reviewers can reject any AI call that doesn't go through it.
Step 3: a fifteen-minute weekly review
Once keys and tags are in place, the console's dashboard charts spend, requests, tokens, errors and latency over any range up to a year, by hour or by day, and every filter applies to the chart, the breakdowns and the request log at once. A weekly routine:
- Total spend vs last week. If it moved more than 20%, find out why before anything else.
- Break down by project. Which product grew? Was that expected?
- Break down by model. Is anything running on a flagship model that doesn't need to?
- Break down by environment. Staging and test should be a small share. If they're not, someone is load testing on production models.
- Break down by member. Not to police anyone. Large personal-key spend usually means a script that should be a service.
- Check errors. A rising error rate usually means retries, and retries mean spend.
- Spot-check the request log. Filter by
feature=..., sort by cost, and look at the most expensive requests. They're often the same prompt with a runaway context.
Export anything you need to share as CSV (up to 50,000 rows per export).
Step 4: turn spend into unit economics
"We spent $3,100 on AI in September" isn't an answer to "is it worth it?". Divide by something the business already counts:
| Feature | Monthly spend | Business unit | Cost per unit |
|---|---|---|---|
| ticket-summary | $310 | 41,000 tickets | $0.0076 per ticket |
| draft-reply | $1,450 | 9,800 replies sent | $0.15 per reply |
| search-answer | $1,340 | 22,000 searches | $0.06 per search |
Now the conversation is concrete. A support agent's minute costs far more than fifteen cents, so draft replies are cheap if agents use them. If they don't, that's the feature to question, not the AI bill as a whole.
The customer tag does the same for pricing: if a handful of customers account for most of the spend, that's a packaging conversation for your product team, and you'll want the numbers before it happens.
The usual cost leaks
Most surprise bills come from a short list of causes:
- A flagship model as the default. Someone prototyped on GPT-6 Astra or Claude Opus 5.5 and nobody changed it. Test the cheaper model on real examples; for summaries, classification and extraction it's often enough. The routing cheat sheet has sensible defaults per task.
- Growing context. Chat features resend the whole conversation every turn, so cost per message climbs with thread length. Trim or summarise old turns.
- Retries without limits. A loop that retries on every error multiplies spend during an outage. Requests that fail at the provider aren't charged on LazySusan, but a retry that succeeds on a broken prompt is.
- Test traffic on production models. CI and evals should run on cheap models unless they're specifically evaluating the expensive one.
- Generous max tokens. You pay for output that's generated, not the limit, but a confused model with a huge limit can write a lot. Set it to what the feature needs.
- Image quality and video length. High-quality GPT Image renders and 8-second 1080p clips cost several times the draft settings. Draft cheap, finish expensive.
Step 5: guardrails, so tracking isn't the only defence
Tracking tells you what happened. Guardrails decide what's allowed to happen:
- Budgets on each key, each member and the whole team. Requests that would go over are refused before they run.
- Model allowlists so staging can't call the most expensive models.
- Alerts by email: balance below a threshold, daily or monthly spend above one, a key past a share of its budget, or an error rate spike. Each fires once when its condition starts.
Setting AI API budgets per developer, project and environment covers how to size them.
Reporting to finance
Finance usually wants three things, and none of them should need an engineer:
- Access to the numbers. Give them the viewer role: read-only access to all usage, keys and alerts.
- Receipts. Every credit purchase has a receipt in the console.
- A predictable bill. The API runs on prepaid credits, so spend can't exceed what's been bought. Auto top-up keeps the balance from running dry, and the team monthly limit keeps it from running away.
For a forecast, take the last two weeks of daily spend per project, multiply by 30, and add known launches. Video is lumpy, so forecast it per campaign rather than per day.
FAQ
How do I track AI API costs per feature? Tag each request with the feature it belongs to using request metadata, then filter the dashboard and request log by that tag. Give features with their own budget a separate key, too.
How do I see AI API spend per developer? Give each developer their own key under one team account. On the LazySusan API, usage is broken down by member automatically, along with key, project, environment, model and provider.
What's the biggest driver of LLM API costs? Usually model choice. For a typical request, the most expensive chat models cost around a hundred times the cheapest, so the default model matters more than volume.
Can I export AI API usage to a spreadsheet? Yes. The request log can be filtered by key, member, model, status or tag and exported as CSV, up to 50,000 rows at a time.
Do failed requests cost money? Not on the LazySusan API. Requests rejected before they reach a model and requests the provider fails aren't charged, and failed videos are refunded in full.