> ## 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**: `getGeneration()`

### Example

```php theme={null}
<?php

require 'vendor/autoload.php';

use AIStats\Sdk\AIStats;

$apiKey = getenv('AI_STATS_API_KEY');
$client = new AIStats(apiKey: $apiKey);

$record = $client->getGeneration('G-01ABC...');
```

### Parameters

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

### Returns

GatewayGenerationRecord

When request details were stored, the returned record also includes `replay_supported` and `replay_request` so you can resubmit the captured payload to the original endpoint.

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