For the complete documentation index, see llms.txt. This page is also available as Markdown.

Usage Logs

GET https://api.aimlapi.com/v2/logs

GET /v2/logs returns one row per request — what it cost, how many tokens it used, whether it succeeded, and the ids you need to tie it back to your own systems. The time window and key-selection rules are identical to API Key Usage; use that endpoint when you want totals rather than individual requests.

Unlike /v2/usage, this endpoint lists failed requests too, with a zero cost. A failed request is billed nothing — the hold is rolled back — so it never appears in the usage totals. That is why a row count here can exceed the requests figure /v2/usage reports for the same window.

Get request logs

Returns the requests made in the window, with cost, tokens and correlation ids.

get
Query parameters
periodstringOptional

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.

Example: 7d
startstringOptional

Window start, ISO-8601. A value without a UTC offset is read as UTC. Must be used together with end.

Example: 2026-07-01T00:00:00Z
endstringOptional

Window end, ISO-8601. Must not be earlier than start, and the window must not exceed 92 days.

Example: 2026-07-28T00:00:00Z
key_prefixstringOptional

Prefix of the key to report on. Omit it to list the requests made with the key you are authenticating with. Listing the requests of a different key requires a management key.

Example: abcd1234
modelstringOptional

Keep only requests made to this model. Accepts source/alias (openai/gpt-5) or a bare alias (gpt-5), matched exactly. Repeat the parameter once per model to pass several, up to 50 values; a comma-separated list is read as one long name and matches nothing.

Example: openai/gpt-5
statusstring · enumOptional

Keep only requests with this outcome. Repeat the parameter to accept both (?status=succeeded&status=failed); a comma-separated value is not a valid status and returns 400.

Example: succeededPossible values:
limitinteger · min: 1 · max: 100Optional

Rows per page, 1-100.

Default: 50Example: 50
offsetintegerOptional

Rows to skip before the page starts.

Default: 0Example: 0
Responses
200

One row per request made in the window, newest first.

application/json
get/v2/logs
curl -L \
  --request GET \
  --url 'https://api.aimlapi.com/v2/logs?period=7d&model=openai/gpt-5&status=failed&limit=50' \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>'
200

One row per request made in the window, newest first.

{
  "data": [
    {
      "created": "2026-07-02T03:04:05.000Z",
      "status": "succeeded",
      "origin": "api",
      "model": "openai/gpt-5",
      "cost": {
        "usd": 0.25,
        "credits": 500000
      },
      "tokens": {
        "input": 10,
        "output": 20,
        "total": 30
      },
      "request_id": "req-1",
      "inference_id": "inf-1",
      "client_request_id": "customer-42"
    }
  ],
  "pagination": {
    "limit": 50,
    "offset": 0,
    "total": 1,
    "has_more": false
  }
}

Errors

Code
When

400

Neither period nor start+end, or both; a malformed date or period; end earlier than start; window over 92 days

401

Missing or invalid key

403

A regular key naming another key's prefix

404

The prefix is not yours, or is outside your key's scopes

429

Over 200 requests per 60 seconds

These figures come from the analytics pipeline and are meant for attribution and budgeting. For the account ledger — what actually moved your balance, including top-ups — use GET /v2/billing/transactions.

Last updated

Was this helpful?