# API: Activity and logs

| Method | Path | What it does | Scope |
|---|---|---|---|
| GET | `/v1/activity` | Usage over a time window (default the last 30 days, at most 92), grouped by model, key, provider or day: requests, errors, tokens, list cost and what was charged | `gateway:read` |
| GET | `/v1/generations` | Requests, newest first: model, provider, key, tokens, list cost and what was charged, latency. Filter by model, key, status and time; prompts and completions are on each request's own page when logging is on | `gateway:read` |
| GET | `/v1/generations/:id` | One request: its model, provider, tokens, cost, charge and timing, and its prompt and completion when logging was on and they're within the retention you chose | `gateway:read` |
| GET | `/v1/generations/export` | The requests as a CSV file (oldest first, at most 100,000 rows, and the X-Export-Truncated header says when there were more: narrow it with from and to; prompts and completions are never exported). Same filters as the list | `gateway:read` |
| GET | `/v1/settings/logging` | Whether prompts and completions are kept (off unless an owner turned it on) and for how many days | `settings:read` |
| PUT | `/v1/settings/logging` | Owners, in the web app: keep prompts and completions for 1, 7 or 30 days, or stop keeping them (turning it off deletes the kept ones at once). Request metadata is kept either way (web app only) | `settings:write` |

## Examples

### GET /v1/activity

Usage over a time window (default the last 30 days, at most 92), grouped by model, key, provider or day: requests, errors, tokens, list cost and what was charged

```bash
curl -s "https://manage.restolayer.com/v1/activity" \
  -H "Authorization: Bearer $LG_API_KEY"
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/activity`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.LG_API_KEY}` },
});
const data = await res.json();
```

### GET /v1/generations

Requests, newest first: model, provider, key, tokens, list cost and what was charged, latency. Filter by model, key, status and time; prompts and completions are on each request's own page when logging is on

```bash
curl -s "https://manage.restolayer.com/v1/generations" \
  -H "Authorization: Bearer $LG_API_KEY"
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/generations`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.LG_API_KEY}` },
});
const data = await res.json();
```

### GET /v1/generations/$ID

One request: its model, provider, tokens, cost, charge and timing, and its prompt and completion when logging was on and they're within the retention you chose

```bash
curl -s "https://manage.restolayer.com/v1/generations/$ID" \
  -H "Authorization: Bearer $LG_API_KEY"
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/generations/${id}`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.LG_API_KEY}` },
});
const data = await res.json();
```

### GET /v1/generations/export

The requests as a CSV file (oldest first, at most 100,000 rows, and the X-Export-Truncated header says when there were more: narrow it with from and to; prompts and completions are never exported). Same filters as the list

```bash
curl -s "https://manage.restolayer.com/v1/generations/export" \
  -H "Authorization: Bearer $LG_API_KEY"
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/generations/export`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.LG_API_KEY}` },
});
const data = await res.json();
```

### GET /v1/settings/logging

Whether prompts and completions are kept (off unless an owner turned it on) and for how many days

```bash
curl -s "https://manage.restolayer.com/v1/settings/logging" \
  -H "Authorization: Bearer $LG_API_KEY"
```

```js
const res = await fetch(`https://manage.restolayer.com/v1/settings/logging`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.LG_API_KEY}` },
});
const data = await res.json();
```

Request and response schemas: [https://www.restolayer.com/openapi.json](https://www.restolayer.com/openapi.json). All resources: [API reference](https://www.restolayer.com/docs/api).
