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.
MarkdownOn this page
/v1/generationsReturns 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
limitintegerRecords per page, 1 to 200. Defaults to 50.
afterstringA cursor: the next_cursor of the previous page. Returns the records that come after it.
fromstringOnly records created at or after this time (ISO 8601 date or date-time).
tostringOnly records created at or before this time.
userstringOnly records with this user tag.
presetstringOnly records made through this preset (the name, with or without @).
modelstringOnly records served by this model.
metadata.<key>stringOnly 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"import os
import requests
params = {"limit": 50, "user": "tenant-42", "metadata.feature": "ticket-summary"}
total = 0.0
while True:
response = requests.get(
"https://api.getlykia.com/v1/generations",
headers={"Authorization": f"Bearer {os.environ['LYKIA_API_KEY']}"},
params=params,
timeout=30,
)
response.raise_for_status()
page = response.json()
total += sum(record["cost"] for record in page["data"])
if not page["next_cursor"]:
break
params["after"] = page["next_cursor"]
print(f"tenant-42 ticket summaries cost {total:.6f} USD")type Generation = { id: string; cost: number; preset: string | null; user: string | null };
type Page = { data: Generation[]; next_cursor: string | null };
const params = new URLSearchParams({ limit: "50", user: "tenant-42", "metadata.feature": "ticket-summary" });
let total = 0;
for (;;) {
const response = await fetch(`https://api.getlykia.com/v1/generations?${params}`, {
headers: { Authorization: `Bearer ${process.env.LYKIA_API_KEY}` },
});
if (!response.ok) throw new Error(`Lykia returned ${response.status}: ${await response.text()}`);
const page = (await response.json()) as Page;
total += page.data.reduce((sum, record) => sum + record.cost, 0);
if (!page.next_cursor) break;
params.set("after", page.next_cursor);
}
console.log(`tenant-42 ticket summaries cost ${total.toFixed(6)} USD`);package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
)
type page struct {
Data []struct {
ID string `json:"id"`
Cost float64 `json:"cost"`
} `json:"data"`
NextCursor *string `json:"next_cursor"`
}
func main() {
params := url.Values{"limit": {"50"}, "user": {"tenant-42"}, "metadata.feature": {"ticket-summary"}}
total := 0.0
for {
req, err := http.NewRequest(http.MethodGet, "https://api.getlykia.com/v1/generations?"+params.Encode(), 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)
}
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
if resp.StatusCode != http.StatusOK {
panic(fmt.Sprintf("Lykia returned %d: %s", resp.StatusCode, body))
}
var p page
if err := json.Unmarshal(body, &p); err != nil {
panic(err)
}
for _, record := range p.Data {
total += record.Cost
}
if p.NextCursor == nil {
break
}
params.Set("after", *p.NextCursor)
}
fmt.Printf("tenant-42 ticket summaries cost %.6f USD\n", total)
}{
"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
dataarrayRequest 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 | nullPass it as after to get the next page; null on the last page.