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

# Generation lookup

> Call /generations to retrieve a past generation.

**Method**: `client.get_generation(...)`.

### Example

```ruby theme={null}
require 'ai_stats_sdk'

client = AIStatsSdk::AIStats.new(api_key: ENV.fetch("AI_STATS_API_KEY"))

record = client.get_generation('G-01ABC...')
```

### Parameters

* `id` (string, required): Request id returned by a previous call.

### Returns

Generation record (JSON)

If the gateway stored full request details, the returned record includes `replay_supported` plus `replay_request`, which can be sent back to the original endpoint for a controlled rerun.

Timing fields follow the shared gateway semantics:

* `latency_ms`: time to first token or first output byte/frame when tracked
* `generation_ms`: post-latency generation time when tracked

```json theme={null}
{
  "created_at": "2026-05-05T12:00:00.000Z",
  "request_id": "G-01ABC123",
  "team_id": "team-123",
  "app_id": "app-123",
  "endpoint": "chat/completions",
  "model_id": "openai/gpt-4o-mini",
  "provider": "openai",
  "native_response_id": "chatcmpl-123",
  "stream": false,
  "byok": false,
  "status_code": 200,
  "success": true,
  "error_code": null,
  "error_message": null,
  "latency_ms": 1500,
  "generation_ms": 1400,
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 9,
    "total_tokens": 18
  },
  "cost_nanos": 1000000,
  "currency": "USD",
  "pricing_lines": [],
  "key_id": "key-123",
  "throughput": null,
  "replay_supported": true,
  "replay_request": {
    "model": "openai/gpt-4o-mini",
    "messages": [
      { "role": "user", "content": "Say hello" }
    ]
  }
}
```
