Usage

Query the per-request usage ledger for the authenticated API customer.

Returns the per-request rows the router writes to the usage ledger every time the calling customer makes a successful API request. Use it to audit consumption, attribute spend to specific API keys, or reconcile against an internal billing system.

The same data drives the Usage page in the console dashboard — the API exposes it for programmatic access.

GET /v1/usage

Returns paginated usage rows for the calling API key's customer, newest first.

Headers

HeaderNotes
AuthorizationBearer tr-… API key. Required.

Query parameters

ParameterTypeDefaultDescription
limitinteger100Page size. Maximum 1000.
offsetinteger0Number of rows to skip (newest-first ordering).
startstringRFC3339 timestamp. Only return rows with created_at >= start.
endstringRFC3339 timestamp. Only return rows with created_at <= end.
modelstringExact match on the routed model ID (e.g. global/redpill/gpt-oss-120b).
key_prefixstringFilter by the customer-visible API-key prefix (e.g. tr-live-a1b2c3d4). Useful when attributing per-key spend.

Example request

curl "https://api.tresor.co/v1/usage?limit=50&model=global/redpill/gpt-oss-120b" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

200 OK with Content-Type: application/json:

{
  "data": [
    {
      "id": "8a1b3f4c-2d6e-4f9a-9c5b-1e7d8a0c4b2f",
      "model": "global/redpill/gpt-oss-120b",
      "modality": "chat",
      "provider": "redpill",
      "region": "global",
      "billing_unit": "token",
      "audio_seconds": null,
      "prompt_tokens": 42,
      "completion_tokens": 128,
      "cost_eur": 0.000182,
      "discount_applied_pct": 0,
      "receipt_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
      "failover": false,
      "key_prefix": "tr-live-a1b2c3d4",
      "key_name": "Default",
      "created_at": "2026-05-06T10:52:02Z"
    }
  ],
  "total_count": 1234,
  "limit": 50,
  "offset": 0
}
FieldTypeDescription
idstringStable ledger row ID (UUID v4).
modelstringRouted model ID for this request.
modalitystringRequest modality: chat, transcription, or embedding.
providerstringUpstream provider that served the request (e.g. redpill, tinfoil, chutes, privatemode).
regionstringProvider region tag, when applicable. Omitted for region-less providers.
billing_unitstringBilling unit for this row, such as token, audio_minute, audio_second, or request.
audio_secondsnumber | nullDuration metadata recorded for transcription requests when available. null when the provider does not return a duration.
prompt_tokensintegerTokens billed for the input prompt.
completion_tokensintegerTokens billed for the generated completion.
cost_eurnumberNet amount billed in EUR for this request, after any plan discount.
discount_applied_pctintegerPercentage discount applied (e.g. 10 for a 10 % included-tier discount, 0 for pay-as-you-go).
receipt_idstring | nullThe corresponding receipt ID, or null if the caller opted out via X-Tresor-Receipt: false. Fetch the JWS via GET /v1/receipts/{id}.
failoverbooleantrue if routing failover moved the request from the preferred route to a secondary route.
key_prefixstring | nullNon-secret prefix of the API key that issued the request (matches what's shown in the dashboard). null if the key was deleted.
key_namestring | nullOperator-set name of the API key. null if the key was deleted.
total_countintegerTotal number of rows matching the filter (across all pages).
limit / offsetintegerEcho of the pagination parameters.

Pagination

Rows are returned newest-first. To page, increase offset by limit until data comes back empty or shorter than limit. For long ranges, prefer narrowing with start / end over deep paging.

Errors

StatuscodeMeaning
401unauthorizedMissing or invalid API key.
500internalFailed to query the ledger. Retry after a delay.
503service_unavailableUsage data is temporarily unavailable.

Error bodies follow the standard error envelope.

See also