agent-costsNovember 10, 2026
How to track spending across OpenAI, Claude and paid APIs
Build a workflow cost record across model APIs and paid tools. Keep units, billing sources, estimates and budgets separate so you count each charge once.
To track spending across OpenAI, Claude and paid APIs, collect costs by billing source, attach them to a workflow and count each purchase once. Vaaya supplies a shared purchase history for supported calls routed through its account, including model and paid-tool purchases. Direct OpenAI or Anthropic calls still belong in their provider records; Vaaya does not automatically import those bills or your software subscriptions. Vaaya spending overview.
The useful total is the cost of completing the job. A model bill answers only part of that question when the agent also buys searches, generates media or runs a sandbox.
Map the bills before collecting the numbers
List the routes a workflow can take. A model request might use your OpenAI account, your Anthropic account or a service account held by an intermediary. A tool request might go through Vaaya or directly to another vendor. Record who charges you for each route.
Include provider-hosted tools when the provider bills for them. A tool call is not automatically an outside purchase, and model-provider cost reports can contain more than inference. Anthropic's analytics documentation, for example, separates cost types such as tokens, web search and code execution. Anthropic cost analytics.
Keep subscriptions, hosting and other fixed expenses in a separate section. If you allocate part of a monthly software bill to a workflow, label the allocation rule. It should not look like an extra API charge produced by the run.
Funding also needs a separate record. Adding money to a prepaid balance and then spending it are different events. Adding both to the workflow's usage total counts the same funding twice.
Give every run an owner and a stable identifier
Create a workflow identifier before the first request. Carry it in application logs and supported metadata, and keep a mapping to provider request IDs or payment records. Include an agent name, environment and responsible team. Separate a production research job from a developer testing the same prompt.
Where a service does not accept your identifier, retain the association in your application. Do not assume every provider exposes the same fields or that a purchase history automatically groups an entire multi-provider run.
Record timestamps in a consistent timezone and preserve the original timestamp. A job that starts before midnight and finishes afterwards can otherwise look like missing spend when two reports use different day boundaries.
Preserve units before converting to money
Store the original quantity, unit, currency and price source with each record. Input tokens, output tokens, cached tokens, search requests and sandbox seconds should not become one undifferentiated usage number.
When a trace tool calculates cost, preserve that fact. Langfuse distinguishes ingested cost from cost inferred using submitted usage and model-price definitions. Those are useful operational records, but their origin should remain visible during reconciliation. Langfuse cost tracking.
Check the units of the money field too. Anthropic's current analytics API returns decimal strings in cents; its reported cost is after discounts and before credits. Preserve the original value before normalizing it. Anthropic amount definitions.
Avoid rounding each tiny call to whole cents before summing. Keep enough precision to reconcile the aggregate, then round the displayed total. Record any currency conversion separately from the original charge.
Count a purchase once, even when several tools record it
Here is an illustrative research run. The amounts are invented to show the accounting; they are not current provider prices.
| Record | Billing source | Unit retained | Illustrative amount | Treatment |
|---|---|---|---|---|
| OpenAI inference | Direct OpenAI account | Token categories | $0.12 | Include reported cost |
| Claude inference | Direct Anthropic account | Token categories | $0.18 | Include reported cost |
| Web searches | Vaaya | Requests | $0.06 | Include Vaaya charge |
| Sandbox work | Vaaya | Seconds | $0.24 | Include Vaaya charge |
| Trace of the first OpenAI request | Observability record | Token categories | $0.12 | Link to the first row; exclude duplicate |
The provisional variable cost is $0.60. Adding the trace estimate would produce $0.72 for the same work. The trace helps explain the first charge; it does not create another one.
If the OpenAI request had instead been purchased through Vaaya, use the corresponding Vaaya charge as the amount you paid. A model-rate estimate attached to that request can help with analysis, but it is not another bill owed to OpenAI.
Reconcile the run against provider records
Use request-level records to investigate the workflow and provider cost reports to check the billing period. OpenAI's official guide demonstrates retrieving usage and aggregated costs, including costs grouped by line item. OpenAI usage and Costs API guide.
When totals differ, first align the account, date range and currency. Then inspect missing requests, retries, cached-token treatment, different rates and later adjustments. Keep incomplete or disputed records marked as such. Do not force them to zero to make a report close.
A timeout needs investigation: the client failing to receive a result does not, by itself, establish the provider's billing outcome. Retain request IDs and check the applicable record before removing the amount or submitting the work again.
Assign the budget across the routes the agent can use
Give the workflow one owner and an overall allowance, then allocate it across the actual billing routes. Three independent $20 limits can permit $60 of spending; they do not enforce a shared $20 workflow budget.
For Vaaya-routed work using developer keys, set categories and period limits. Fixed-price calls also support a maximum quoted cost. Check session, OAuth and metered-service behavior separately; direct provider spending needs its own controls. Vaaya spending controls explains the settings, and giving an agent a budget covers their use.
Keep already-running work visible when authorizing the next step. Use alerts and hard limits for the response you need, and the monitoring-tool comparison to choose where each record comes from. Start with one workflow and reconcile it fully before extending the same reporting to the rest of your agents.
Questions
Can I see OpenAI, Claude and paid API costs in one place?
Yes, if you collect the relevant billing and usage records into one report. Vaaya provides a shared purchase history for supported calls routed through Vaaya. Direct provider calls and separate subscriptions still need their own reporting sources.
Should I add trace costs to my provider bill?
Only if they represent different purchases. A trace estimate and a provider charge for the same request are two records of one cost. Link them for reconciliation and count the charge once.
How should I budget for a workflow that uses several providers?
Assign a workflow owner and an overall allowance, then allocate limits to the routes the agent can use. Keep already-running work and incomplete cost records visible when deciding whether another paid step can start.