Usage API
Usage API
The Usage API provides live and historical usage for the current account, plus aggregate usage, details, and rankings for descendant accounts.
export BASE_URL="https://api.yairouter.com"
export API_KEY="sk-Xvs..."Endpoints
| Method and path | Scope | Description |
|---|---|---|
GET /dashboard/live | Current account | Live totals for the day and month |
GET /dashboard/bill | Current account | Trends and model details by date |
GET /x-bill | Descendant accounts | Aggregate trends, model details, and account ranking |
All endpoints require:
Authorization: Bearer sk-Xvs...Current-account live usage
curl "$BASE_URL/dashboard/live" \
-H "Authorization: Bearer $API_KEY"In addition to account information, the response provides:
| Field | Description |
|---|---|
daily_usage | Live total for the current day |
monthly_usage | Live total for the current month |
Requests | Request count |
Prompt | Input tokens |
Completion | Output tokens |
Reasoning | Reasoning tokens |
CreditUsed | Credits used |
ModelUsage | Requests, tokens, and credits grouped by model |
Use this endpoint for dashboard polling. Use /dashboard/bill for historical trends.
Current-account historical usage
GET /dashboard/bill
GET /dashboard/bill?date=2026-07-18
GET /dashboard/bill?start=2026-07-01&end=2026-07-18
GET /dashboard/bill?days=7With no parameters, the endpoint returns usage for the current day.
| Parameter | Description |
|---|---|
date | One day in YYYY-MM-DD format |
start / end | Inclusive date range |
days | A recent time window |
curl "$BASE_URL/dashboard/bill?start=2026-07-01&end=2026-07-18" \
-H "Authorization: Bearer $API_KEY"Descendant-account usage
/x-bill reports descendants below the current account and does not include the current account itself. The caller must have account-management access.
GET /x-bill
GET /x-bill?date=2026-07-18
GET /x-bill?start=2026-07-01&end=2026-07-18
GET /x-bill?days=7
GET /x-bill?user=42&days=30With no date parameters, the endpoint returns the current day. user accepts an account ID, name, or email. When omitted, usage is aggregated across all descendants.
curl "$BASE_URL/x-bill?start=2026-07-01&end=2026-07-18" \
-H "Authorization: Bearer $API_KEY"Aggregate response
/dashboard/bill and /x-bill share the same core usage structure:
| Field | Description |
|---|---|
daily_costs | Daily usage; line_items break each day down by model |
usage_summary | Per-model totals across the full range |
total_requests | Total requests |
total_prompt | Total input tokens |
total_completion | Total output tokens |
total_reasoning | Total reasoning tokens |
total_credit_used | Total credits used |
token_summary | Cached, uncached input, and output token totals |
Simplified response:
{
"object": "bill_info",
"daily_costs": [
{
"date": "2026-07-18",
"total_requests": 24,
"total_prompt": 18200,
"total_completion": 3600,
"total_credit_used": 1.42,
"line_items": [
{"name": "gpt-5-nano", "cost": 1.42, "usage": {}}
]
}
],
"usage_summary": {"gpt-5-nano": {}},
"total_requests": 24,
"total_prompt": 18200,
"total_completion": 3600,
"total_reasoning": 0,
"total_credit_used": 1.42,
"token_summary": {
"input_total": 18200,
"output_total": 3600,
"processed_total": 21800
}
}Descendant ranking
/x-bill adds usage_users to the core statistics and sorts entries by credits used, descending:
| Field | Description |
|---|---|
id, name, alias, email | Account identity |
top_cost_model | Model with the highest credit usage |
top_request_model | Model with the most requests |
total_requests | Requests made by this account |
total_prompt, total_completion, total_reasoning | Token usage for this account |
total_credit_used | Credits used by this account |
usage_analysis.request_percentage | Share of all descendant requests |
usage_analysis.cost_percentage | Share of all descendant credit usage |
{
"usage_users": [
{
"id": 42,
"name": "developer-a",
"alias": "Engineering A",
"email": "[email protected]",
"top_cost_model": "gpt-5",
"top_request_model": "gpt-5-nano",
"total_requests": 50,
"total_prompt": 42000,
"total_completion": 8000,
"total_reasoning": 0,
"total_credit_used": 3.52,
"usage_analysis": {
"request_percentage": 62.5,
"cost_percentage": 61.97
}
}
]
}Accounts with no requests are omitted from usage_users.
Choose an endpoint
- Current balance plus live daily and monthly totals:
/dashboard/live - Current-account usage for a day, date range, or model breakdown:
/dashboard/bill - Overall usage and ranking for all descendants:
/x-bill