Generation
Returns Lykia's record of a single request: model, provider, token counts, cost, timing and the providers that were tried.
MarkdownOn this page
/v1/generationLykia 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
idstringrequiredThe request id, for example gen-1795373724-YQhkPKb4HcCr0wWN.
Example
curl "https://api.getlykia.com/v1/generation?id=gen-1795373724-YQhkPKb4HcCr0wWN" \
-H "Authorization: Bearer $LYKIA_API_KEY"import os
import requests
response = requests.get(
"https://api.getlykia.com/v1/generation?id=gen-1795373724-YQhkPKb4HcCr0wWN",
headers={"Authorization": f"Bearer {os.environ['LYKIA_API_KEY']}"},
timeout=30,
)
response.raise_for_status()
generation = response.json()["data"]
print(generation["model_resolved"], generation["provider"], generation["status"])
print("cost (USD):", generation["cost"], "latency (ms):", generation["latency_ms"])const response = await fetch("https://api.getlykia.com/v1/generation?id=gen-1795373724-YQhkPKb4HcCr0wWN", {
headers: { Authorization: `Bearer ${process.env.LYKIA_API_KEY}` },
});
if (!response.ok) {
throw new Error(`Lykia returned ${response.status}: ${await response.text()}`);
}
const { data: generation } = await response.json();
console.log(generation.model_resolved, generation.provider, generation.status);
console.log("cost (USD):", generation.cost, "latency (ms):", generation.latency_ms);package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, err := http.NewRequest(http.MethodGet, "https://api.getlykia.com/v1/generation?id=gen-1795373724-YQhkPKb4HcCr0wWN", nil)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("LYKIA_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
if resp.StatusCode != http.StatusOK {
panic(fmt.Sprintf("Lykia returned %d: %s", resp.StatusCode, body))
}
var result struct {
Data struct {
ModelResolved string `json:"model_resolved"`
Provider string `json:"provider"`
Status string `json:"status"`
Cost float64 `json:"cost"`
LatencyMs int `json:"latency_ms"`
} `json:"data"`
}
if err := json.Unmarshal(body, &result); err != nil {
panic(err)
}
g := result.Data
fmt.Println(g.ModelResolved, g.Provider, g.Status)
fmt.Println("cost (USD):", g.Cost, "latency (ms):", g.LatencyMs)
}{
"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
dataobjectidstringThe request id.
created_atstringWhen the request was made, ISO 8601.
modelstringThe model you asked for.
model_resolvedstring | nullThe model that actually served the request (for a failed request, the last one tried); different from model after a fallback.
providerstring | nullThe 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.
streamedbooleanWhether the response was streamed.
usage_typestringHow it was paid for: credits, byok (your own provider key; the provider bills you) or free (a free model).
statusstringok, error (every provider failed, or the provider failed during a stream) or cancelled (the client disconnected).
finish_reasonstring | nullWhy generation stopped (stop, length, tool_calls…).
tokensobjectToken counts: prompt, completion, reasoning (the model's thinking tokens), cache_read (input read from the cache) and cache_write (input written to the cache).
costnumberWhat was deducted from credits, in USD. Always 0 for BYOK requests.
list_costnumberThe 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_feenumberThe 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_msintegerTotal duration of the request, in milliseconds.
ttft_msinteger | nullFor streamed requests, the time until the first chunk arrived, in milliseconds. null for requests that were not streamed.
attemptsarrayThe 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.
appobjectThe HTTP-Referer and X-Title headers sent with the request, as referer and title.
userstring | nullThe user tag you sent in the request.
endpointstringWhich endpoint served the request: chat.completions, embeddings, images.generations, videos, audio.speech, audio.transcriptions or audio.voices.
kindstringWhat the request produced: chat, embedding, image, video, speech, transcription or voice (a voice clone).
presetstring | nullThe preset name when model was @name (without the @), otherwise null. model is then the real model the preset pointed to.
metadataobjectThe metadata tags you sent, or {}.
cost_detailsobjectupstream_cost (list-price value), platform_fee (BYOK fee for this request) and is_byok, as in the response's usage.cost_details.
mediaobjectOnly on image, video, speech, transcription and voice records:
unitsobjectWhat was billed, such as image, second, character or tokens.
units_estimatedbooleantrue when the provider did not report the units and Lykia's reservation estimate was used.
billed_by_providerbooleantrue when the provider charged for a rejected or failed request; that cost is charged.
job_idstring | nullThe video job id (the same as the record id).
outputsintegerHow many output files Lykia stored.
A video job's record is written when the job ends; its id is the job id:
{
"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).