API Key Usage
Choosing the time window
Choosing the key
Get key usage
Relative window: a positive integer followed by h or d, for example 24h or 7d. Provide either period or both start and end, never both.
24hWindow start, ISO-8601. A value without a UTC offset is read as UTC. Must be used together with end.
2026-07-01T00:00:00ZWindow end, ISO-8601. Must not be earlier than start, and the window must not exceed 92 days.
2026-07-28T00:00:00ZPrefix of the key to report on. Omit it to get the spend of the key you are authenticating with. Reporting on a different key requires a management key.
abcd1234Total spend for the key over the requested window.
The requested key prefix, or null when it was omitted and the answer is your own key's spend.
abcd1234Window start, resolved to UTC.
2026-07-26T22:15:00.000ZWindow end, resolved to UTC.
2026-07-27T22:15:00.000ZTotal spend for the key over the window, in USD.
13.704199Spend currency (always USD).
USDNumber of charged requests in the window.
9643curl -L \
--request GET \
--url 'https://api.aimlapi.com/v2/usage?period=24h' \
--header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>'Total spend for the key over the requested window.
{
"api_key_prefix": "abcd1234",
"start": "2026-07-26T22:15:00.000Z",
"end": "2026-07-27T22:15:00.000Z",
"spend": 13.704199,
"currency": "USD",
"requests": 9643
}Get detailed key usage
Relative window: a positive integer followed by h or d, for example 24h or 7d. Provide either period or both start and end, never both.
7dWindow start, ISO-8601. A value without a UTC offset is read as UTC. Must be used together with end.
2026-07-01T00:00:00ZWindow end, ISO-8601. Must not be earlier than start, and the window must not exceed 92 days.
2026-07-28T00:00:00ZPrefix of the key to report on. Omit it to get the spend of the key you are authenticating with. Reporting on a different key requires a management key.
abcd1234Total spend for the key over the requested window, with a per-model breakdown.
The requested key prefix, or null when it was omitted and the answer is your own key's spend.
abcd1234Window start, resolved to UTC.
2026-07-20T22:15:00.000ZWindow end, resolved to UTC.
2026-07-27T22:15:00.000ZTotal spend for the key over the window, in USD. This is the authoritative total: it is computed from the total, not by adding up models, so it can differ from that sum by a few nano-dollars.
12.3456Spend currency (always USD).
USDNumber of charged requests in the window.
842curl -L \
--request GET \
--url 'https://api.aimlapi.com/v2/usage/detail?key_prefix=abcd1234&period=7d' \
--header 'Authorization: Bearer <YOUR_AIMLAPI_MANAGEMENT_KEY>'Total spend for the key over the requested window, with a per-model breakdown.
{
"api_key_prefix": "abcd1234",
"start": "2026-07-20T22:15:00.000Z",
"end": "2026-07-27T22:15:00.000Z",
"spend": 12.3456,
"currency": "USD",
"requests": 842,
"models": [
{
"model": "openai/gpt-5",
"spend": 8.12,
"requests": 500
}
]
}Last updated
Was this helpful?