Skip to content

Generations

Lists the request records of the calling key's project, newest first, with cursor paging and filters for user, preset, model, metadata and time range.

Markdown
On this page
GET/v1/generations

Returns the project's request records, newest first, in pages. Each record has the same fields as GET /generation. Use it to total the cost of one end user or one feature, to reconcile your own billing, or to find a request without knowing its id. Any API key of the project can read the project's records, and only those. Records are deleted when the retention period ends (90 days by default).

Query parameters

limitinteger

Records per page, 1 to 200. Defaults to 50.

afterstring

A cursor: the next_cursor of the previous page. Returns the records that come after it.

fromstring

Only records created at or after this time (ISO 8601 date or date-time).

tostring

Only records created at or before this time.

userstring

Only records with this user tag.

presetstring

Only records made through this preset (the name, with or without @).

modelstring

Only records served by this model.

metadata.<key>string

Only records whose metadata has this key with this value, for example metadata.feature=ticket-summary. Up to 16 such filters; all must match.

An invalid parameter returns 400 with the code invalid_query.

Example

Total what one end user's ticket summaries cost, page by page:

curl "https://api.getlykia.com/v1/generations?limit=20&user=tenant-42&metadata.feature=ticket-summary" \
  -H "Authorization: Bearer $LYKIA_API_KEY"
200 OK
{
  "data": [
    {
      "id": "gen-1795457068-0edlh4VVDNydM3Ro",
      "created_at": "2026-11-23T18:04:28.933Z",
      "model": "openai/gpt-4o-mini",
      "model_resolved": "openai/gpt-4o-mini",
      "provider": "openai",
      "streamed": false,
      "usage_type": "credits",
      "status": "ok",
      "finish_reason": "stop",
      "tokens": {
        "prompt": 412,
        "completion": 96,
        "reasoning": 0,
        "cache_read": 0,
        "cache_write": 0
      },
      "cost": 0.000119,
      "list_cost": 0.000119,
      "byok_fee": 0,
      "latency_ms": 1180,
      "ttft_ms": null,
      "attempts": [
        {
          "provider": "openai",
          "status": "ok",
          "latency_ms": 1143,
          "error": null
        }
      ],
      "app": {
        "referer": null,
        "title": null
      },
      "user": "tenant-42",
      "endpoint": "chat.completions",
      "preset": "text",
      "metadata": {
        "feature": "ticket-summary"
      },
      "cost_details": {
        "upstream_cost": 0.000119,
        "platform_fee": 0,
        "is_byok": false
      },
      "kind": "chat"
    }
  ],
  "next_cursor": "gen-1795457068-0edlh4VVDNydM3Ro"
}

Response

dataarray

Request records, newest first. Each record has the fields described in GET /generation, including user, endpoint, kind, preset, metadata, cost_details and, on media records, media.

next_cursorstring | null

Pass it as after to get the next page; null on the last page.