Browse the docs

Report tokens and cost

Report tokens per step with the model that produced them, so AMC prices each run correctly for ROI and budgets.

Before you startAn endpoint that serves `/status`. See [Run status and steps](/developers/byo-run-status/).View as Markdown

AMC reads GET /runs/{id}/tokens and GET /runs/{id}/status on every poll, so report running totals while the run is live: department budget spend counts in-flight runs.

GET /runs/{id}/tokens
{
  "orchestratorRunId": "run_5f2c0e8a41b94c55",
  "agentTokens": 4810,
  "hostTokens": 0,
  "totalTokens": 4810,
  "inputTokens": 4200,
  "outputTokens": 610,
  "costUsd": 0
}
FieldMeaning
agentTokensTokens your agent's steps used.
hostTokensTokens a separate host-side model call used, if you have one. Otherwise 0.
totalTokensagentTokens + hostTokens.
inputTokens, outputTokensThe run's prompt and completion split.
costUsdThe run's cost in US dollars if you price it yourself, else 0.

Per-step fields

Step fieldMeaning
inputTokensPrompt tokens, including cached ones.
cachedInputTokensThe cached part of inputTokens, priced at the cheaper cached rate.
outputTokensCompletion tokens.
modelThe model id that produced the step. AMC looks it up in its rate table, ignoring case.
modelUsageWhen one step used several models: [{ "model", "inputTokens", "outputTokens", "cachedInputTokens" }].

How AMC prices a run

  1. If /tokens reports costUsd greater than zero, that is the run's cost.
  2. Otherwise AMC prices each step: by modelUsage when present (each model at its own rate, summed), else by model and the step's tokens. A missing or unknown model uses AMC's default rate.
  3. If that comes to zero (no split reported), ROI estimates cost from totalTokens at a flat per-token rate.
Per-step price
uncached = inputTokens - cachedInputTokens
cost     = uncached          / 1,000,000 x input rate
         + cachedInputTokens / 1,000,000 x cached input rate
         + outputTokens      / 1,000,000 x output rate

Report costUsd when your provider gives you an exact figure (for example, the Claude Agent SDK's total cost). It wins over any recompute. Keep reporting tokens and model anyway: they drive the per-step and per-model breakdown people see.

Failed and cancelled runs

Spend before a failure is real. Keep the tokens on the step that failed and in /tokens, or the failed run prices at zero. On cancel, AMC reads /tokens one last time, so report what the run spent up to the cancel.

A step that used two models
{
  "stepId": "research",
  "name": "Research",
  "status": "completed",
  "tokenCount": 51200,
  "inputTokens": 48000,
  "outputTokens": 3200,
  "cachedInputTokens": 30000,
  "model": "<orchestrator-model-id>",
  "modelUsage": [
    { "model": "<orchestrator-model-id>", "inputTokens": 40000, "outputTokens": 2500, "cachedInputTokens": 28000 },
    { "model": "<subagent-model-id>", "inputTokens": 8000, "outputTokens": 700, "cachedInputTokens": 2000 }
  ]
}

Last updated 2026-10-21