Skip to main content
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:
limit
integer
default:"50"
Maximum number of records to return. Maximum value: 50.
offset
integer
default:"0"
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"
  }]
}
usage
array
List of usage log entries.

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

Pagination

Both endpoints support limit and offset query parameters. To page through results:
  1. Fetch the first page: ?limit=50&offset=0
  2. Fetch the next page: ?limit=50&offset=50
  3. Continue until the returned array is empty or has fewer items than limit.
limit is capped at 50 per request.