API Reference
Usage
Track API usage statistics and costs.
Usage
Track your API usage statistics, costs, and performance metrics.
Get Usage Statistics
GET
/v1/usageGet aggregated usage statistics for a date range.
Query Parameters
Prop
Type
Response
{
"data": {
"period": {
"start": "2024-01-01T00:00:00Z",
"end": "2024-01-31T23:59:59Z"
},
"summary": {
"total_requests": 1250,
"total_tokens": 450000,
"total_cost_cents": 125,
"average_latency_ms": 850
},
"by_model": [
{
"model": "anthropic/claude-haiku-4.5",
"requests": 800,
"cost_cents": 95
},
{
"model": "openai/gpt-5.1",
"requests": 450,
"cost_cents": 30
}
]
}
}Example
curl "https://api.assistantrouter.com/v1/usage?start_date=2024-01-01" \
-H "Authorization: Bearer $API_KEY"const response = await fetch(
'https://api.assistantrouter.com/v1/usage?start_date=2024-01-01',
{
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
},
}
);
const data = await response.json();
console.log(data.data.summary);Get Recent Usage
GET
/v1/usage/recentGet a list of recent usage records.
Query Parameters
Prop
Type
Response
{
"data": [
{
"id": "usage_abc123",
"request_id": "req_xyz789",
"assistant_id": "asst_123",
"model": "anthropic/claude-haiku-4.5",
"input_tokens": 150,
"output_tokens": 350,
"total_tokens": 500,
"llm_cost_cents": 0.08,
"tool_cost_cents": 0,
"total_cost_cents": 0.08,
"latency_ms": 1250,
"status": "success",
"error_code": null,
"user_id": "user_123",
"subscription_id": null,
"tools_used": [],
"created_at": "2024-01-15T10:30:00Z"
}
]
}Get Daily Usage
GET
/v1/usage/dailyGet daily usage breakdown.
Query Parameters
Prop
Type
Response
{
"data": [
{
"date": "2024-01-15",
"requests": 45,
"tokens": 15000,
"cost_cents": 3.5
},
{
"date": "2024-01-14",
"requests": 52,
"tokens": 18000,
"cost_cents": 4.2
}
]
}Usage Record Fields
| Field | Description |
|---|---|
id | Unique usage record identifier |
request_id | The API request ID |
assistant_id | The assistant that handled the request |
model | The model used (e.g., anthropic/claude-haiku-4.5) |
input_tokens | Number of input tokens |
output_tokens | Number of output tokens |
total_tokens | Total tokens (input + output) |
llm_cost_cents | Cost of the LLM call in cents |
tool_cost_cents | Cost of tools used (web search, RAG) in cents |
total_cost_cents | Total cost in cents |
latency_ms | Request latency in milliseconds |
status | Request status (success, error) |
error_code | Error code if request failed |
user_id | The end user ID if provided |
subscription_id | The subscription ID if provided |
tools_used | Array of tools used (e.g., ["web_search"]) |
created_at | When the request was made |
Usage data is retained for 90 days. For longer retention, export data periodically using the daily endpoint.