> For the list of every page, fetch /llms.txt. The API contract is the OpenAPI file linked from the API reference.

# Usage and cost

Meadow records usage and cost in US dollars for model calls and sandboxes. Read them through the API or with `mdw usage`.

Providers bill you directly. Meadow's cost records help you track spend before the provider's invoice arrives.

## What a cost is

- For a model call: the cost the provider reported, when it reports one. OpenRouter does. Otherwise the provider's token counts times the provider's list price for that model. Input, output, cache reads, cache writes and long cache writes each have their own price.
- For a sandbox: the size the provider granted (CPU, memory, disk, GPU class) times the provider's list price, for the time the provider billed. While a sandbox runs, that time is Meadow's own count: from the moment Meadow asks the provider to create it until the provider confirms it is gone. After it ends, Meadow reads the start and end the provider itself reports and uses those, so the cost of a short sandbox can go down. See [When a sandbox cost is final](#when-a-sandbox-cost-is-final). `sandbox_seconds` always shows Meadow's own count. A create attempt the provider never started costs 0.

A cost leaves out discounts, credits and taxes, and it can lag a price change. Check it against your provider's invoice before you rely on it.

## The prices Meadow uses

[`getPricing`](/reference/api-reference#getpricing), `GET /v1/pricing`, returns the price table, with no key needed. Its `version` is the `price_version` that `GET /v1/usage` reports.

```bash
curl -sS "$MEADOW_BASE_URL/v1/pricing"
```

Each model price is per million tokens, and each sandbox price is per hour, as decimal strings. Every entry names the provider page it was read from (`source`), the day (`checked`), and whether a call has been compared with the provider's bill (`confirmed`). The table has price fields only: Meadow's own notes on each entry are not returned. `prices_as_of` gives the day each provider's entries were last all compared with its page. A provider whose date is more than `stale_after_days` (30) days old, or that has prices and no date, is listed in `stale_vendors`: check its prices on the provider's page before you rely on them.

## The cost of one sandbox

`GET /v1/sandboxes/{sandbox_id}` and `GET /v1/sandboxes` return a `cost` object on each sandbox. A Modal sandbox with 2 CPU and 4096 MB, read on the hosted beta on 2026-11-28 just after it ended, had this one:

```json
{"billed_from":"2026-11-28T06:47:04.352Z","billed_seconds":65.103475,"billed_to":null,"cost":0.006869718682,"cost_per_hour":0.379872,"cost_reason":null,"cost_status":"price_table","currency":"USD"}
```

The fields:

| Field | Meaning |
| --- | --- |
| `cost_per_hour` | The hourly list price of the provider sandbox that serves it. |
| `cost` | What it has cost so far. It includes a provider that Meadow tried first and moved on from. |
| `currency` | `USD`. |
| `cost_status` | `price_table`, `price_estimated` or `price_unknown`. |
| `cost_reason` | Why the cost is an estimate or unknown. |
| `billed_from`, `billed_to`, `billed_seconds` | The time counted. `billed_to` is null while the sandbox is still counting. |

It is the same figure `GET /v1/usage` adds into `sandbox_cost`. Read `cost_status` first. With `price_unknown`, `cost` is null: an unknown cost is never shown as zero. A sandbox younger than about a minute reads `price_unknown` with `cost_reason` `not_recorded`, because usage records are written once a minute.

## When a sandbox cost is final

Meadow's clock runs longer than the vendor's. It starts when Meadow asks the vendor for the sandbox and stops when the vendor confirms it is gone. The vendor starts billing after its own create and stops before Meadow's confirmation. On a short sandbox the gap is large: one Daytona sandbox read 113.2 seconds on Meadow's clock and Daytona billed 50.9.

So Meadow asks the vendor for the time it billed, 2 minutes after a sandbox ends. If the vendor has no answer yet, Meadow asks again. Each wait is as long as the time since the end, so it doubles, up to 6 hours. Meadow stops asking 4 days after the end.

- If the vendor has the billed time 2 minutes after the end, the cost is final within about 4 minutes of the end. The end is recorded up to a minute after the vendor confirms the delete, and the check runs once a minute.
- If the vendor needs longer, call it D after the end, the cost is final within about twice D, and never more than D plus 6 hours, plus those few minutes.
- Until then the `cost` object reads `cost_status` `price_estimated` with `cost_reason` `meadow_clock`, and `GET /v1/usage` counts the sandbox in `estimated_price_cost` and `estimated_price_records`. When a reason about the price also applies, such as `grant_unconfirmed`, `cost_reason` shows that reason.
- If the vendor reports no time within 4 days, the cost stays on Meadow's clock and `cost_reason` becomes `vendor_window_unavailable`.
- Meadow reads the vendor's time with your stored provider key. When you replace or delete a Daytona or Modal key, Meadow first reads the time for every sandbox that has ended and has none yet, with the old key, for up to 20 seconds. A sandbox that ended in the last minute or two may not be at the vendor yet. After a delete, any sandbox still without the vendor's time reads `vendor_window_unavailable`.

Do: store a sandbox's cost as final when `billed_to` is set and `cost_reason` is neither `meadow_clock` nor `vendor_window_unavailable`. Before you delete a Daytona or Modal key, wait a few minutes after your last sandbox ended.

## When a cost is missing

Meadow never shows a guess as a cost. Where it has a list price and must estimate something, the cost is marked as an estimate: see the end of this section. A record has `cost: null` when:

- Meadow holds no price for the model at that provider. Calls through `vertex` have no price today. On `azure`, the listed OpenAI models have prices on a deployment you store as `GlobalStandard` in `deployment_types` ([Provider keys](/set-up-your-account/provider-keys#azure)); other deployment types have no price, and `cost_reason` says why: `deployment_type_unknown`, `provisioned_throughput` or `deployment_type_unpriced`. On `bedrock`, the listed Claude models have prices: a `global.` model ID is priced at AWS's global rates and every other inference profile at AWS's regional rates. A `fireworks` model has a price only when it is one of `kimi-k3`, `glm-5p3` and `glm-5p3-flash`.
- The provider's price depends on the hour of the call (`cost_reason` `time_of_day_price`). Every `deepseek` call has it: DeepSeek's pricing page gives a peak and an off-peak price by UTC hour, on weekdays apart from Chinese public holidays. The tokens are stored as the provider reported them.
- The provider's response names a model other than the one sent, and Meadow holds no price for it (`cost_reason` `served_model_unknown`). A call is priced at the model in the response, `served_model` on the record, and never at the price of the model you asked for.
- The provider reported no token counts, or the stream was cut before they arrived, and the model has no list price. Meadow estimates the tokens and reports them apart, in the `estimated_*` fields. When the model has a list price the call gets an estimated cost instead: see below.
- The call used a service tier, speed or region Meadow holds no price for, audio, or a server tool other than Anthropic web search. Priced: Anthropic US-only inference (`inference_geo` `us`, 1.1 times the list price), Anthropic fast mode, the `priority` and `flex` tiers of the Google and OpenAI models whose pricing pages list them, and xAI `priority` (an estimate at twice the list price). Anthropic's `inference_geo` values `global` and `not_available` (a model older than Claude 4.6, which has no region setting) are the list price. Not priced: Anthropic `priority`, OpenAI `scale` and `ultrafast`, xAI `fast`.
- You asked for a `service_tier` other than the list price and the provider did not say which tier served the call (`cost_reason` `service_tier_unconfirmed`). A priority request can be served at standard and billed at standard, so Meadow does not guess. The tier is priced from the provider's own report of the tier served: for Google the `x-gemini-service-tier` response header, which Meadow returns to you as Google sent it.
- A provider received the request and did not answer it: you left, the provider timed out, or Meadow moved to the next provider. The provider may still have billed. These are counted in `unmeasured_attempts`.

Every such record is counted in `unknown_cost_records`. When that number is above 0, the `cost` beside it is lower than what you were billed.

Some costs are estimates. A model ID that is on no provider price page, a call whose tokens Meadow had to estimate (`cost_reason` `stream_cut` or `usage_not_reported`), a Daytona spot GPU sandbox, a Modal sandbox created with `burst` or a region, and a sandbox whose granted size or GPU type the provider has not confirmed yet are priced with the best figure Meadow has. For a cut stream the estimate counts the text Meadow received, so it can be low when the provider generated more than it delivered. Their rows carry `cost_status` `price_estimated`, and the totals show their sum apart in `estimated_price_cost` with the count in `estimated_price_records`.

A cut stream through OpenRouter is read back from OpenRouter a minute or more later, for calls up to 48 hours old. Its row then holds OpenRouter's own tokens and cost, with `cost_status` `provider_reported` and `cost_reason` `vendor_lookup`. OpenRouter has no list price in Meadow, so until then the row holds estimated tokens and its `cost` is null. It stays that way when the read back cannot work: the account stores no OpenRouter key, OpenRouter rejects the key with a 401 or 403, OpenRouter has no record of a call more than 30 minutes old, or six tries over about 30 minutes fail. Meadow does not try such a row again, even after you add the key back.

## Tokens

- `input_tokens` is the whole prompt. `cache_read_tokens` and `cache_write_tokens` are parts of it.
- `output_tokens` is every token billed at the output price. `reasoning_tokens` is the part of it that was reasoning, as in `completion_tokens_details.reasoning_tokens` on OpenAI and OpenRouter.
- Some providers leave reasoning out of their output count and show it only in their total. Gemini does. Meadow adds the difference to `output_tokens` and to `reasoning_tokens`, and a single record shows it in `unattributed_tokens`.
- On a record, `total_tokens` is `input_tokens` plus `output_tokens`.

## Read usage over a date range

[getUsage](/reference/api-reference#getusage) returns everything a usage page needs in one answer.

```sh
curl -s "$MEADOW_BASE_URL/v1/usage?from=2026-11-18&to=2026-11-25&group_by=model" \
  -H "Authorization: Bearer $MEADOW_API_KEY"
```

`from` is included and `to` is excluded. Both are UTC: a date or an RFC 3339 time. Left out, the range is the 7 days that end now.

| Field | What it holds |
| --- | --- |
| `totals` | Requests, tokens by class, sandbox time and cost for the whole range |
| `series` | The same figures per `bucket` (`day` or `hour`), split by `group_by` (`model`, `provider`, `key`, `project` or `none`). A bucket with no usage has no point |
| `by_model` | Per model and provider: cost, error rate, how often a call fell back and why, the share of input read from cache, and latency (median, 95th and 99th percentile of the whole call and of the first byte) |
| `by_key` | Totals per key, highest cost first |
| `sandboxes` | Sandboxes by status, time and cost per provider, GPU time per GPU class, and how long creates took |

With `bucket=hour` a range may cover 31 days. With `bucket=day` it may cover 366.

Filter with `project_id`, `key_id`, `provider` and `model`. Sandboxes have no model. With `group_by=model` the series holds model calls only, and the totals still include sandboxes. With a `model` filter every section holds model calls only.

## List single calls

[listUsageRequests](/reference/api-reference#listusagerequests) lists model calls, newest first.

```sh
curl -s "$MEADOW_BASE_URL/v1/usage/requests?limit=50" \
  -H "Authorization: Bearer $MEADOW_API_KEY"
```

Each record has the provider and model that answered, why the call was routed there, tokens by class, `cost`, `cost_status`, `cost_reason` (why a cost is missing), `duration_ms`, `first_byte_ms` and two IDs: `id` is the `x-request-id` Meadow returned for the call, and `provider_request_id` is the provider's own ID, which finds the same call in the provider's logs.

A record of `kind` `abandoned_attempt` is a provider attempt that may have been billed without answering. It shares its `id` with the call it belongs to. A call that was at its provider when a Meadow server stopped without warning is an `abandoned_attempt` with `cost_reason` `interrupted`, `cost` `null` and no tokens. It appears about an hour after the call started, once Meadow has read it back from its logs. Its `held_usd` (and `held_tokens` on a key with a token limit) is what the call held against your key limits and hard budgets. Meadow charges that amount to them when the hold ends, 10 minutes after the call started or 2 hours after a stream's first byte, so a limit can move with no priced record: this field is where the amount comes from.

Page with `limit` (1 to 200) and the `next_cursor` of the page before.

## Who can read what

Any key can call both routes. A key with the `admin` scope reads the whole account. Any other key reads only its own usage, and a `key_id` that is not its own returns 400.

## From the command line

```sh
mdw usage --from 2026-11-18 --to 2026-11-25 --group-by model
mdw usage requests --limit 20
```

`mdw usage` prints the totals, one trend line per group, and tables for models, keys and sandboxes. Add `--json` for the API's answer.

## How fresh each figure is

| Figure | When it moves |
| --- | --- |
| A model call in `GET /v1/usage` and `GET /v1/usage/requests` | Within about 2 seconds after the call ends. Records are written in batches every 2 seconds. A write that fails is tried again for about 5 minutes. |
| A sandbox's `cost` and the sandbox part of `GET /v1/usage` | Up to about 2 minutes behind. Sandboxes are copied and priced once a minute. A sandbox younger than about a minute reads `price_unknown` with `cost_reason` `not_recorded`. |
| `usage` on a key with a dollar `limit` | A model call is charged when its response is ready, or when its stream ends. If that write fails, Meadow tries again for up to 2 minutes, then charges the amount it held when the hold ends (10 minutes, 2 hours for a stream). Sandbox time is charged once a minute. |
| Spend on a budget (`GET /v1/budget`, `GET /v1/projects/{project_id}/budget`) | As fresh as the usage records it adds up: about 2 seconds for model calls, up to about 2 minutes for sandboxes. |
| `last_used_at` on a key | Within about 2 seconds after the first call of the minute with that key. |

When a Meadow server stops abruptly, for example when it runs out of memory, the records it had not yet written are missing until a Meadow operator restores them from the server's logs. That does not happen by itself.

## How long Meadow adds to a call

Meadow's own time on a model call is mostly database round trips made before your provider is called. On the hosted beta in the 10 days to 2026-11-28, a non-streaming call spent about 60 ms in Meadow at the median (p99 about 145 ms), on top of the provider's own time. A key with a request, token or dollar limit adds about two more round trips, one before the call and one after it. A sandbox command adds a little more than a model call: one more round trip before the provider and one after. These are measurements, not a promise, and they change as Meadow changes.

<a id="checks-against-your-vendor-accounts"></a>

## Checks against your provider accounts

Several times a day Meadow compares its cost figures with the provider's own, to find sandboxes or calls it missed. It uses the provider key you stored, and it only reads: your Daytona sandbox usage, your Modal billing report, and your OpenRouter key's spend for the day. It changes nothing at the provider. The other providers have no spend API that a normal key can read, so they are not compared.

The same check looks for orphans: sandboxes alive at Daytona or Modal that Meadow already cleaned up. An orphan is matched to the create attempt Meadow made for it, by the vendor's id or by the name Meadow gave it. Each one is logged and counted in the check's result. Meadow's own server deletes them only when its operator sets `MEADOW_ORPHAN_SWEEP_DELETE=true`. A sandbox that carries Meadow's label but matches no attempt, for example one made by another Meadow server with the same vendor key, is reported and never deleted. An orphan's usage record ends when Meadow cleaned up its attempt, so the time it ran after that is missing from Meadow's own figure until the orphan is deleted. The vendor's billed window covers that time where the vendor reports one per sandbox (Daytona).

## How long records are kept

90 days. No request or response content is recorded: a record holds IDs, model names, counts, times and cost.

## How long records are kept

[`getRetention`](/reference/api-reference#getretention) returns how many days usage records are kept before only daily sums remain, and how many days audit log entries are kept. `null` means kept with no limit.

To see every vendor attempt of one request, filter the request log by its id: `GET /v1/usage/requests?request_id=<x-request-id>`. It lists the `call` record and an `abandoned_attempt` record, numbered by `attempt`, for each vendor attempt Meadow gave up on after sending. An attempt that never reached a vendor has no record.