Skip to main content
Menu
Account / Usage API
Account

Usage API

Read your organization's requests, tokens and spend from code, grouped by model, project, key, tier, region or day.

4 minute readUpdated 15 November 2026curl · Python · TypeScript

What it returns#

GET /v1/usage returns your organization's aggregated requests, tokens and spend for a time range: one row per group in data, and the sums in totals. Amounts are what was billed, in integer nano-USD (cost_nano_usd) and formatted in USD (cost_usd).

FieldAlways presentTypeNotes
requestsYesinteger
input_tokensYesinteger
cached_input_tokensYesinteger
output_tokensYesintegerIncludes reasoning tokens.
reasoning_tokensNointeger
imagesNointeger
audio_secondsNointeger
cost_nano_usdYesintegerAmount billed, in nano-USD.
cost_usdYesstringThe same amount formatted in USD.
A usage report grouped by model
{
  "from": 1790000000,
  "to": 1792592000,
  "group_by": "model",
  "data": [
    {
      "model": "z-ai/glm-5.3",
      "requests": 1200,
      "input_tokens": 1800000,
      "cached_input_tokens": 0,
      "output_tokens": 600000,
      "reasoning_tokens": 0,
      "cost_nano_usd": 12480000000,
      "cost_usd": "12.48"
    }
  ],
  "totals": {
    "requests": 1200,
    "input_tokens": 1800000,
    "cached_input_tokens": 0,
    "output_tokens": 600000,
    "reasoning_tokens": 0,
    "cost_nano_usd": 12480000000,
    "cost_usd": "12.48"
  },
  "next_cursor": null
}

output_tokens includes reasoning tokens. Where an upstream shares its prompt cache across its customers, cached input is billed and reported as ordinary input, and cached_input_tokens stays 0 for those requests (Prompt caching).

Choose a time range#

from (inclusive) and to (exclusive) are Unix seconds. to defaults to now, and one range spans at most 366 days.

ParameterRequiredValuesLimitsNotes
fromYesintegerStart of the range, inclusive, Unix seconds.
toNointegerEnd of the range, exclusive, Unix seconds. Defaults to now. The range may span at most 366 days.
projectNostringpattern ^prj_[0-9A-Za-z]+$Restrict to one project (`prj_…`).
modelNostringRestrict to one canonical model id.
group_byNomodel, project, key, tier, region, dayDimension to group rows by. Without it the response has one row for the whole range.
limitNointegermin 1; max 200Page size.
cursorNostringOpaque cursor from a previous response's `next_cursor`.

Group and filter#

group_by takes one dimension: model, project, key, tier, region or day (a UTC day). Each row then names its group in the matching field. Without group_by the response has one row for the whole range. project and model restrict the rows to one project or one canonical model id.

Spend per model for a month
curl "https://api.panward.ai/v1/usage?from=1790000000&to=1792592000&group_by=model" \
  -H "Authorization: Bearer $PANWARD_API_KEY"

Pagination#

Lists in the API use cursor pagination. limit sets the page size (default 50, at most 200). Pass the response's next_cursor as cursor to get the next page; it is null on the last page.

One project per day for the last week, every page
import os
import time
import requests

headers = {"Authorization": f"Bearer {os.environ['PANWARD_API_KEY']}"}
end = int(time.time())
start = end - 7 * 86400

rows = []
cursor = None
while True:
    response = requests.get(
        "https://api.panward.ai/v1/usage",
        headers=headers,
        params={"from": start, "to": end, "group_by": "day", "project": "prj_01JB2K9P6W", "limit": 200, "cursor": cursor},
    )
    response.raise_for_status()
    report = response.json()
    rows.extend(report["data"])
    cursor = report["next_cursor"]
    if cursor is None:
        break

for row in rows:
    print(row["day"], row["requests"], row["cost_usd"])

Freshness#

Figures come from hourly rollups and appear within a few minutes of the request.

Scope of a key#

The call needs a key with the usage.read scope and returns the figures of the key's organization. A key with only usage.read cannot call models: an inference request with it is refused with 403 permission_denied. Give reporting jobs a key of their own with this scope (Scopes).

Reconcile with statements and receipts#

Usage totals equal the lines of the monthly statement under Billing. Receipts carry the token counts of each request and no prices, so a sum over receipts reconciles tokens, not money (How a request is priced).

Exports in the console#

For larger ranges, the console's Usage screen exports a CSV file in the background, one row per interval and group, from the same rollups. It holds no request-level rows.

The request log in the console lists single requests, with their receipt ids. It holds metadata only, never prompt or response content.
Was this page helpful?Suggest an edit