Why the invoice isn't enough
OpenAI, Anthropic, Google and the cloud marketplaces bill per API key or project. They can't tell which of your services, features or customers made each call. When the bill goes up, the question “what changed?” has no answer unless you recorded it at the call site.
How the cost of one call is calculated
cost = uncached input tokens × input price
+ cached input tokens × cached input price
+ cache write tokens × cache write price
+ output tokens × output price (reasoning tokens count as output)The price depends on where the call ran, not just the model name:
| Where the call ran | What changes |
|---|---|
| Provider API (global) | The provider's list price |
| Azure OpenAI | Global, data zone and regional deployments are priced differently |
| Google Vertex AI | Regional endpoints can cost more than global |
| Amazon Bedrock | Prices vary by region, and cross-region inference profiles have their own |
| Your fine-tunes or negotiated rates | Your own price, not the list price |
Alye picks the most specific price it knows for each call and records which one it used, so estimates are labelled as estimates.
Split spend by service, model and customer
Name each service when you start the SDK. To see spend per customer, tag requests with your own customer ID (an account or tenant ID, not a name or email):
# Python
with alye.context(customer_id="northwind"):
answer = run_agent(ticket)
// Node.js
await alye.context({ customerId: "northwind" }, () => runAgent(ticket));Every call is then priced and counted under its service, model and customer, and each request becomes a trace you can open to see which steps cost the most.
Set budgets and alerts
- A spend alert when a service, model or customer passes a limit in an hour or a day.
- A forecast alert when the month is on track to exceed your budget.
- A monthly budget per customer, so you know before a customer's usage outgrows their plan.
- Delivery by email, Slack or Microsoft Teams, checked every minute.
Where the savings usually are
- One service or prompt is often most of the bill. Sort spend by service, then open its most expensive traces.
- Retries cost twice. Rising rate-limit errors usually mean paying for calls that failed.
- A smaller model is often enough for classification, routing and extraction steps.
- Cached input tokens are cheaper. Keep long, stable instructions at the start of the prompt so they can be cached.
- Watch tokens per call after each prompt change; growth there is easy to miss.
Start tracking
Add the SDK to one service and your first priced calls show up within minutes. See the docs and pricing, or read what LLM observability covers beyond cost.