# Privacy and logging

> What Lykia stores for each request by default, why prompt and response text is only kept when a project opts in and how much of it is kept, how long records are kept, and how to pass app and user details.

Lykia keeps a record of each request that reaches a provider; billing, usage charts and debugging all depend on it. By default, that record does **not** contain the text of your prompts or the responses. Storing the text is something only you can turn on, one project at a time.

## Stored by default

A record is written when the request finishes. It covers requests that were answered, failed at the providers or were cancelled; requests rejected before any provider was tried (an invalid key, an empty balance, an unknown model) are not recorded. For each request, Lykia records:

- the project, the API key and the time of the request
- the model requested, the model that served it, the provider and the provider's own name for the model
- whether the response was streamed
- token counts: input, output, reasoning, read from cache and written to cache, and whether they were estimated
- the cost, the list-price equivalent and any BYOK fee
- the usage type: `credits`, `byok` or `free`
- total latency and, for streamed requests, the time to the first chunk
- the finish reason and status (`ok`, `error`, `cancelled`), plus the error message if there was one
- the providers that were tried: provider, outcome, latency and error for each attempt
- app details (the `HTTP-Referer` and `X-Title` headers), the request's `user` and `metadata` tags and the preset name, if there were any
- the endpoint (`chat.completions` or `embeddings`)

You can see these records in the dashboard's request logs; the company owner, company managers and project managers assigned to the project can view them. Any API key of the project can fetch a single record with [`GET /generation`](https://www.getlykia.com/en/docs/api-reference/generation).

> **Note:** API keys, provider keys and other secrets never appear in a log record, an error message or a response. Error text that a provider sends back is cleaned of anything that looks like a key before Lykia stores or returns it.

## Prompt and response text (opt-in)

Prompt and response text is not stored by default. If you want to see it, to debug or to review quality, turn on **prompt logging** in the project's settings. While it is on, the request body and the response of that project's requests become part of the record; turn it off and subsequent requests are stored without text again.

Each stored body is capped in size (64 KB by default; Lykia can change the cap). A longer body is cut off at the cap, and the record is marked as truncated. For streamed requests, the stored response is the text, reasoning and tool calls assembled from the chunks.

The setting is per project. One approach is to keep production traffic with personal data in a project with prompt logging off, and the traffic you want to debug in a separate project.

> **Warning:** Before turning on prompt logging, review what data your requests contain and what privacy obligations you have. While it is on, the text is visible to every team member allowed to view logs.

## How long records are kept

Request records, including any stored text, are deleted automatically when the retention period ends. The period is set by Lykia (90 days by default) and is fixed for each record when it is written. The daily usage totals needed for billing (request counts, tokens and cost per project, model, provider, key and day) are kept separately, without an end date, and contain no prompt text.

## App and user details

Two optional headers record which application a request came from:

- `HTTP-Referer` (or `Referer`): your application's URL.
- `X-Title`: your application's name.

Put your own user id in the body's `user` field and it is recorded too, which helps when you need to track down abuse or a particularly heavy user. Use an opaque id you generate, not something that identifies a person directly, such as an email address.

**cURL**

```bash
curl https://api.getlykia.com/v1/chat/completions \
  -H "Authorization: Bearer $LYKIA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "HTTP-Referer: https://example.com" \
  -H "X-Title: Example App" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "user": "user_8c1f2a",
    "messages": [{ "role": "user", "content": "Summarise our refund policy in two sentences." }]
  }'
```

**Python**

```python
import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.getlykia.com/v1",
    api_key=os.environ["LYKIA_API_KEY"],
    default_headers={"HTTP-Referer": "https://example.com", "X-Title": "Example App"},
)

completion = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    user="user_8c1f2a",
    messages=[{"role": "user", "content": "Summarise our refund policy in two sentences."}],
)
print(completion.id, completion.choices[0].message.content)
```

**TypeScript**

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.getlykia.com/v1",
  apiKey: process.env.LYKIA_API_KEY,
  defaultHeaders: { "HTTP-Referer": "https://example.com", "X-Title": "Example App" },
});

const completion = await client.chat.completions.create({
  model: "openai/gpt-4o-mini",
  user: "user_8c1f2a",
  messages: [{ role: "user", content: "Summarise our refund policy in two sentences." }],
});
console.log(completion.id, completion.choices[0].message.content);
```

Lykia writes these values to the request's record, so you can tell requests apart by them in the dashboard's logs. They stay with Lykia: the two headers and the `user` and `metadata` tags are never forwarded to a provider, not even with your own provider key. You can add your own key-value `metadata` as well and break usage down by it; see [Tags and usage breakdown](https://www.getlykia.com/en/docs/guides/tags-and-usage). Lykia also never turns on storage at the provider: OpenAI always receives `store: false`, even when your request says otherwise. See [What is sent to the provider](https://www.getlykia.com/en/docs/api-reference/chat-completions#what-is-sent-to-the-provider).

With prompt logging off, the prompt and the answer are not written anywhere: not to the request record, not to Lykia's logs, and not to stored error messages, since a provider's error text can echo the prompt. Only measurements and tags are kept.

## Related

- [Projects](https://www.getlykia.com/en/docs/guides/projects): prompt logging and other project settings.
- [`GET /generation`](https://www.getlykia.com/en/docs/api-reference/generation): the record of a single request.
- [API reference overview](https://www.getlykia.com/en/docs/api-reference/overview): all request headers.
