# Report tokens and cost

Agent Mission Control developer docs > Bring your own agent

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

**Before you start:** An endpoint that serves `/status`. See [Run status and steps](/developers/byo-run-status/).

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`
```json
{
  "orchestratorRunId": "run_5f2c0e8a41b94c55",
  "agentTokens": 4810,
  "hostTokens": 0,
  "totalTokens": 4810,
  "inputTokens": 4200,
  "outputTokens": 610,
  "costUsd": 0
}
```

| Field | Meaning |
| --- | --- |
| `agentTokens` | Tokens your agent's steps used. |
| `hostTokens` | Tokens a separate host-side model call used, if you have one. Otherwise `0`. |
| `totalTokens` | `agentTokens + hostTokens`. |
| `inputTokens`, `outputTokens` | The run's prompt and completion split. |
| `costUsd` | The run's cost in US dollars if you price it yourself, else `0`. |

## Per-step fields

| Step field | Meaning |
| --- | --- |
| `inputTokens` | Prompt tokens, including cached ones. |
| `cachedInputTokens` | The cached part of `inputTokens`, priced at the cheaper cached rate. |
| `outputTokens` | Completion tokens. |
| `model` | The model id that produced the step. AMC looks it up in its rate table, ignoring case. |
| `modelUsage` | When one step used several models: `[{ "model", "inputTokens", "outputTokens", "cachedInputTokens" }]`. |

> **Important:** `inputTokens` must include the cached tokens. Report only the uncached remainder and a warm cache makes the run look almost free.

## 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`
```text
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`
```json
{
  "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 }
  ]
}
```

## Related

- [Run status and steps](https://www.agentmissioncontrol.ai/developers/byo-run-status/)
- [The amc_sdk Python package](https://www.agentmissioncontrol.ai/developers/byo-amc-sdk/)
- [The integration contract](https://www.agentmissioncontrol.ai/developers/integration-contract/)

---
Source: https://www.agentmissioncontrol.ai/developers/byo-tokens-and-cost/ · Last updated 2026-10-21 · Full index: https://www.agentmissioncontrol.ai/llms.txt
