Retrieve per-request usage logs and aggregate statistics for your account.
Authentication: Authorization: Bearer YOUR_JWT_TOKEN
Get usage log
GET https://modelswitch.io/api/usage
Returns a paginated list of individual inference requests with token counts and charges.
Query parameters:
Maximum number of records to return. Maximum value: 50.
Number of records to skip. Use with limit for pagination.
curl "https://modelswitch.io/api/usage?limit=50&offset=0" \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Response:
{
"usage": [{
"id": 1,
"model": "gpt-4o",
"promptTokens": 523,
"completionTokens": 214,
"chargedAmount": 0.00345,
"createdAt": "2024-01-15T14:22:05Z"
}]
}
List of usage log entries.
Model ID used for this request.
Number of tokens in the prompt.
Number of tokens in the completion.
Amount charged in USD for this request.
ISO 8601 timestamp of the request.
Get usage statistics
GET https://modelswitch.io/api/usage/stats
Returns aggregate totals across all requests, plus a per-model breakdown.
curl https://modelswitch.io/api/usage/stats \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Response includes:
- Overall totals: total requests, total tokens, total spend
- Per-model breakdown with the same metrics grouped by model ID
Both endpoints support limit and offset query parameters. To page through results:
- Fetch the first page:
?limit=50&offset=0
- Fetch the next page:
?limit=50&offset=50
- Continue until the returned array is empty or has fewer items than
limit.
limit is capped at 50 per request.