Tokens and cost per model per day, for the whole project
Model usage for every agent and monitor in the project, per model per UTC day, and per agent over the range. Read from the daily dependency aggregate LastPing computes as spans arrive (kept 90 days), never from raw spans, so it answers in one read whatever the volume.
A range covers every UTC day that overlaps it: 24h reads yesterday and today. Costs a model call did not report are estimated from LastPing's price table and labelled estimated.
Request
- Base URL: https://app.lastping.dev
- URL: https://app.lastping.dev/api/v1/agents/usage
- Auth: API key in header X-Api-Key
Query parameters
24h, 7d (default) or 30d. The data is daily, so a range covers every UTC day that overlaps it: 24h reads yesterday and today.
Only usage from the traced runs of this project: runs whose Claude Code hook start carried this label (Run.project, the name of the folder that holds the git repository the session worked in, or the folder's name when it is not in a repository; a name, never a path). days is then read from those runs' own totals (each run's tokens and cost, as the Runs list shows them): ONE row per UTC day of the run's start, with model and provider empty (a run's totals are not split by model), and origin: traces. Usage reported only through a metrics export carries no project and is left out (project_scope). by_project narrows to the label too. Cleaned like GET /api/v1/runs's project; a value that cleans to nothing is refused with 400 INVALID_FILTER.
Response
The project's usage.
Example response
{
"range": "7d",
"days": [
{
"day": "2026-09-20",
"model": "claude-sonnet-4-5",
"provider": "anthropic",
"tokens_in": 182340,
"tokens_out": 20411,
"tokens_cache_read": 95012,
"tokens_cache_write": 4100,
"cost_usd": "0.853221",
"cost_source": "estimated",
"origin": "traces"
}
],
"by_agent": [
{
"id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"name": "Nightly ETL bot",
"calls": 412,
"tokens_in": 1203400,
"tokens_out": 90022,
"tokens_cache_read": 600000,
"tokens_cache_write": 12000,
"cost_usd": "4.120000",
"cost_source": "estimated"
}
],
"project_scope": "traces_only",
"by_project": [
{
"project": "reddit-bot",
"runs": 14,
"tokens_in": 1402211,
"tokens_out": 38120,
"tokens_cache_read": 1190455,
"tokens_cache_write": 60102,
"cost_usd": "3.412210",
"cost_source": "mixed"
}
]
}Changes
No recorded changes to this operation across all 2 revisions of this API.