Skip to content

Generation

Returns Lykia's record of a single request: model, provider, token counts, cost, timing and the providers that were tried.

Markdown
On this page
GET/v1/generation

Lykia keeps a record of each request that reached a provider, and this endpoint returns the record for the request id you pass. The id is the id field of a POST /chat/completions response (it starts with gen-), and also comes in its X-Generation-Id header; in a streamed response every chunk carries the same id. Requests rejected before any provider was tried, such as a 402 for an empty balance, have no record.

The record is written when the request finishes, so a request that is still running returns 404; try again a few seconds later. Any API key of the project can read its records, and an id from another project behaves as if it does not exist.

Query parameters

idstringrequired

The request id, for example gen-1795373724-YQhkPKb4HcCr0wWN.

Example

Request
curl "https://api.getlykia.com/v1/generation?id=gen-1795373724-YQhkPKb4HcCr0wWN" \
  -H "Authorization: Bearer $LYKIA_API_KEY"
Response200
{
  "data": {
    "id": "gen-1795373724-YQhkPKb4HcCr0wWN",
    "created_at": "2026-11-22T18:55:24.863Z",
    "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": 27,
      "completion": 34,
      "reasoning": 0,
      "cache_read": 0,
      "cache_write": 0
    },
    "cost": 0.000024,
    "list_cost": 0.000024,
    "byok_fee": 0,
    "latency_ms": 1183,
    "ttft_ms": null,
    "attempts": [
      {
        "provider": "openai",
        "status": "ok",
        "latency_ms": 1182,
        "error": null
      }
    ],
    "app": {
      "referer": "https://example.com",
      "title": "Example Support Bot"
    },
    "user": "user-4821",
    "endpoint": "chat.completions",
    "preset": "text",
    "metadata": {
      "feature": "ticket-summary",
      "plan": "pro"
    },
    "cost_details": {
      "upstream_cost": 0.000024,
      "platform_fee": 0,
      "is_byok": false
    },
    "kind": "chat"
  }
}

Response

dataobject
idstring

The request id.

created_atstring

When the request was made, ISO 8601.

modelstring

The model you asked for.

model_resolvedstring | null

The model that actually served the request (for a failed request, the last one tried); different from model after a fallback.

providerstring | null

The id of the provider that served the request (the last one tried, for a failed request; for example openai). The values are the slug values listed by GET /providers.

streamedboolean

Whether the response was streamed.

usage_typestring

How it was paid for: credits, byok (your own provider key; the provider bills you) or free (a free model).

statusstring

ok, error (every provider failed, or the provider failed during a stream) or cancelled (the client disconnected).

finish_reasonstring | null

Why generation stopped (stop, length, tool_calls…).

tokensobject

Token counts: prompt, completion, reasoning (the model's thinking tokens), cache_read (input read from the cache) and cache_write (input written to the cache).

costnumber

What was deducted from credits, in USD. Always 0 for BYOK requests.

list_costnumber

The request's value at list price, in USD. Equal to cost when you pay with credits; for BYOK, the list-price equivalent of what the provider bills you.

byok_feenumber

The fee for this request when the company's BYOK usage is past the plan's monthly allowance, in USD; otherwise 0. It is deducted from credits the next day, together with the project's other BYOK fees for that day.

latency_msinteger

Total duration of the request, in milliseconds.

ttft_msinteger | null

For streamed requests, the time until the first chunk arrived, in milliseconds. null for requests that were not streamed.

attemptsarray

The providers tried, in order, each with provider, status (ok, error or cancelled), latency_ms and error (the reason it failed, or null). Failed attempts are not billed.

appobject

The HTTP-Referer and X-Title headers sent with the request, as referer and title.

userstring | null

The user tag you sent in the request.

endpointstring

Which endpoint served the request: chat.completions, embeddings, images.generations, videos, audio.speech, audio.transcriptions or audio.voices.

kindstring

What the request produced: chat, embedding, image, video, speech, transcription or voice (a voice clone).

presetstring | null

The preset name when model was @name (without the @), otherwise null. model is then the real model the preset pointed to.

metadataobject

The metadata tags you sent, or {}.

cost_detailsobject

upstream_cost (list-price value), platform_fee (BYOK fee for this request) and is_byok, as in the response's usage.cost_details.

mediaobject

Only on image, video, speech, transcription and voice records:

unitsobject

What was billed, such as image, second, character or tokens.

units_estimatedboolean

true when the provider did not report the units and Lykia's reservation estimate was used.

billed_by_providerboolean

true when the provider charged for a rejected or failed request; that cost is charged.

job_idstring | null

The video job id (the same as the record id).

outputsinteger

How many output files Lykia stored.

A video job's record is written when the job ends; its id is the job id:

200 OK
{
    "data": {
        "id": "gen-1795463406-qOWSYdRnX7cEsv8q",
        "created_at": "2026-11-23T19:50:06.503Z",
        "model": "bytedance/seedance-1.0-pro",
        "model_resolved": "bytedance/seedance-1.0-pro",
        "provider": "bytedance",
        "streamed": false,
        "usage_type": "credits",
        "status": "ok",
        "finish_reason": null,
        "tokens": {
            "prompt": 0,
            "completion": 0,
            "reasoning": 0,
            "cache_read": 0,
            "cache_write": 0
        },
        "cost": 0.2574,
        "list_cost": 0.2574,
        "byok_fee": 0,
        "latency_ms": 33380,
        "ttft_ms": null,
        "attempts": [],
        "app": {
            "referer": null,
            "title": null
        },
        "user": null,
        "endpoint": "videos",
        "preset": null,
        "metadata": {},
        "cost_details": {
            "upstream_cost": 0.2574,
            "platform_fee": 0,
            "is_byok": false
        },
        "kind": "video",
        "media": {
            "units": {
                "tokens": 108000
            },
            "units_estimated": false,
            "billed_by_provider": false,
            "job_id": "gen-1795463406-qOWSYdRnX7cEsv8q",
            "outputs": 1
        }
    }
}

To list several records at once, filtered by user, preset, model or metadata, use GET /generations.

Records are deleted automatically when the retention period set by Lykia ends (90 days by default).