> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arouter.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Generation

> Retrieve cost, token usage, and metadata for a specific completed generation.

Retrieve detailed metadata for a completed generation by its ID. Use this endpoint to check cost and usage for any past request.

## Endpoint

```
GET /api/v1/generation
```

## Query Parameters

| Parameter | Type     | Required | Description                                                     |
| --------- | -------- | -------- | --------------------------------------------------------------- |
| `id`      | `string` | Yes      | Generation ID from the `id` field of a chat completion response |

## Example Request

```bash theme={null}
curl "https://api.arouter.ai/api/v1/generation?id=gen-1775226820-719aea642d4b4d279c897793" \
  -H "Authorization: Bearer lr_live_xxxx"
```

## Example Response

```json theme={null}
{
  "id": "gen-1775226820-719aea642d4b4d279c897793",
  "model": "anthropic/claude-sonnet-4.6",
  "provider": "Google",
  "created_at": "2026-04-03T12:00:00Z",
  "latency_ms": 1240,
  "usage": {
    "prompt_tokens": 14,
    "completion_tokens": 6,
    "total_tokens": 20,
    "cost": 0.000132,
    "is_byok": false,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "cache_write_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0
    },
    "cost_details": {
      "upstream_inference_cost": 0.000132,
      "upstream_inference_prompt_cost": 0.0000420,
      "upstream_inference_completions_cost": 0.000090
    }
  }
}
```

## Response Fields

| Field                     | Type      | Description                           |
| ------------------------- | --------- | ------------------------------------- |
| `id`                      | `string`  | Generation ID                         |
| `model`                   | `string`  | Model that generated the response     |
| `provider`                | `string`  | Provider that served the request      |
| `created_at`              | `string`  | ISO 8601 timestamp                    |
| `latency_ms`              | `integer` | Total request latency in milliseconds |
| `usage.prompt_tokens`     | `integer` | Input tokens                          |
| `usage.completion_tokens` | `integer` | Output tokens                         |
| `usage.total_tokens`      | `integer` | Total tokens                          |
| `usage.cost`              | `number`  | Total cost in USD                     |
| `usage.is_byok`           | `boolean` | Whether a user-provided key was used  |

## Notes

* Generation metadata is typically available within a few seconds of the request completing
* Generation IDs are returned in the `id` field of every chat completion response
* Historical data is retained for 90 days
