> ## 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.

# 生成記録を取得

> 完了した特定の生成のコスト、トークン使用量、メタデータを取得します。

ID によって完了した生成の詳細なメタデータを取得します。このエンドポイントを使用して、過去のリクエストのコストと使用量を確認できます。

## エンドポイント

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

## クエリパラメータ

| パラメータ | 型        | 必須 | 説明                              |
| ----- | -------- | -- | ------------------------------- |
| `id`  | `string` | はい | チャット補完レスポンスの `id` フィールドからの生成 ID |

## リクエスト例

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

## レスポンス例

```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
    }
  }
}
```

## レスポンスフィールド

| フィールド                     | 型         | 説明                     |
| ------------------------- | --------- | ---------------------- |
| `id`                      | `string`  | 生成 ID                  |
| `model`                   | `string`  | レスポンスを生成したモデル          |
| `provider`                | `string`  | リクエストを処理したプロバイダー       |
| `created_at`              | `string`  | ISO 8601 タイムスタンプ       |
| `latency_ms`              | `integer` | リクエストの総レイテンシ（ミリ秒）      |
| `usage.prompt_tokens`     | `integer` | 入力トークン数                |
| `usage.completion_tokens` | `integer` | 出力トークン数                |
| `usage.total_tokens`      | `integer` | 総トークン数                 |
| `usage.cost`              | `number`  | 総コスト（USD）              |
| `usage.is_byok`           | `boolean` | ユーザー提供の key が使用されたかどうか |

## 注意事項

* 生成メタデータは通常、リクエート完了後数秒以内に利用可能になります
* 生成 ID はすべてのチャット補完レスポンスの `id` フィールドで返されます
* 履歴データは 90 日間保持されます
