← Blog

Cost · · 4 min read

Trace your OpenAI and Anthropic bill to finished tasks

Connect OpenAI and Anthropic usage to agent attempts and finished tasks. Separate cached input, retries, shared-key attribution, and missing cost before changing the workflow.

Deixic

An agent researches a customer, drafts a brief, and hands off to a second agent, which repeats the research because it did not inherit the result. The model bill records both attempts but does not explain why the same work happened twice.

A cost review should find that repetition and produce a concrete correction; switching models will not repair a workflow that keeps losing its own work.

The OpenAI and Anthropic connections provide usage and account information. To get cost per finished task, combine the provider-side data with the identity and outcome of the task itself.

Start with an attribution map#

A provider organization, project, workspace, API key, agent, and customer task are separate things. Decide how they relate before treating a provider total as one agent's cost.

A shared key makes a provider report insufficient for that attribution. Record the missing relationship instead of assigning all spend to whichever agent is visible.

Use a mapping that answers:

Question Information to retain
Where did the provider charge occur? Provider, account boundary, project or workspace, and time window
Which execution used it? Agent and attempt identifiers, where your system records them
What business task was it for? Task reference and intended output
What happened? Completion, rejection, failure, or unresolved outcome
What is missing? Unattributed usage or unavailable cost detail

Your task system supplies the link between an execution and a business task; keep it with the provider usage reference.

Keep usage and monetary cost distinct#

OpenAI’s organization usage and cost reference describes time-bucketed reports and grouping dimensions. Anthropic’s Usage and Cost API likewise provides organization-level reporting with its own access requirements and report structure. Inspect the dimensions and retain the report scope when comparing periods.

Raw token totals are not interchangeable bills, because models, input types, output, and other billed usage differ. Preserve currency and period for monetary cost, label usage-only data as usage, and keep any estimate separate from a provider-reported amount.

Missing cost is not zero cost: a task with unattributable usage should not look like your cheapest workflow.

Cached input and repeated tasks are separate questions#

Caching and work reuse answer different questions. A provider processes repeated input differently from new input, while the agent still repeats a search, rebuilds the same explanation, or makes another tool call.

The operator's question is whether the second attempt needed to happen. If an earlier account brief was sufficient and current, preserving it avoids another investigation; if the facts changed, a fresh lookup is right even when the prompt looks similar. Separate these cases:

  • The agent reused a previous result without another provider call.
  • The agent made another call using repeated input.
  • The agent repeated a tool operation whose earlier result was available.
  • The agent deliberately refreshed changing information.

Not all repetition is waste; look for repetition the workflow cannot explain.

Investigate attempts that produced no new result#

Take a renewal account brief. Define completion before looking at cost: a resolved account identity, source references, open questions, and a recommendation the account owner can review.

Group the attempts for that task and look for:

  • Repeated searches with unchanged scope.
  • Retries after an already successful call.
  • Drafts discarded because the destination was wrong.
  • Handoffs that omitted the successful result’s identifiers.

The output is a repair hypothesis, such as: retain the resolved account ID and the reviewed brief at handoff, then refresh only the facts needed for the next decision. That gives the team more to act on than "the total bill is too large."

Use agent spend and action history in Deixic to inspect the activity it records. Keep provider reporting gaps visible and calls routed through Deixic separate from activity elsewhere.

Compare a workflow change against the same job#

Try the revised method on similar representative tasks. Compare whether the work finished, whether the output was accepted, which lookups repeated, and whether cost information is complete.

A lower bill with an incomplete answer is not an improvement, and neither is an agent that avoids every refresh and reuses stale facts. Inspect the outcome alongside cost and waiting time.

Record the period and method so the team can repeat the review, then decide: this handoff retained the right information, this retry rule avoided a duplicate attempt, or this task needs a different tool before it needs a different model.

Preserve the correction so the next task benefits#

Save the reviewed procedure as a skill and retain useful account knowledge through memory, with its scope and a way to revise it. Keep changing usage totals and current account facts out of the permanent instruction.

The next agent begins with the work already done, refreshes only what changed, and spends its effort on the unresolved part.