> For the complete documentation index, see [llms.txt](https://docs.fastrouter.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fastrouter.ai/api-reference/generations.md).

# Generations

## Get Generation Details

> Retrieves detailed usage and performance metrics for a past generation request. Returns cost breakdown, model/provider info, token counts, latency, throughput, and BYOK status.

```json
{"openapi":"3.1.0","info":{"title":"FastRouter API Reference","version":"1.0.0"},"tags":[{"name":"Generation Details","description":"Retrieve detailed information about API requests and responses."}],"servers":[{"url":"https://api.fastrouter.ai","description":"Production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"FastRouter API Key. Get yours at https://fastrouter.ai\n\nFormat: `Authorization: Bearer YOUR_API_KEY`"}},"responses":{"UnauthorizedError":{"description":"Invalid Credentials - Your API key is invalid, missing, or disabled. Check your credentials.\n\nNote: the 401 error body uses `code`, `message`, `param`, and `type` (there is no `status` field), and `type` is `invalid_request_error`.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"param":{"type":"string","nullable":true},"code":{"type":"string"}}}}}}}},"RateLimitError":{"description":"Rate Limited - You have exceeded your request limits (TPM/RPM). Slow down or increase your limits.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"},"status":{"type":"integer"}}}}}}}}}},"paths":{"/api/v1/generation":{"post":{"operationId":"getGenerationDetails","tags":["Generation Details"],"summary":"Get Generation Details","description":"Retrieves detailed usage and performance metrics for a past generation request. Returns cost breakdown, model/provider info, token counts, latency, throughput, and BYOK status.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["generation_id"],"properties":{"generation_id":{"type":"string","description":"The generation ID returned in the API response. Can be chat_id, request_id, or similar ID field from any FastRouter API endpoint response."}}}}}},"responses":{"200":{"description":"Generation details retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"Generation ID (same as requested)"},"model":{"type":"string","description":"Model used for this generation in provider/model format"},"provider_name":{"type":"string","description":"Provider that processed the request"},"api_key":{"type":"string","description":"Hashed API key used for the request (for auditing)"},"credits_used":{"type":"number","description":"Total credits consumed by this request"},"query_time":{"type":"string","format":"date-time","description":"ISO 8601 timestamp of when the request was made"},"avg_response_time_minutes_per_transaction":{"type":"number","description":"Average response time in minutes per transaction"},"avg_tokens_per_nano":{"type":"number","description":"Average tokens processed per nanosecond (throughput metric)"},"input_token_size":{"type":"integer","description":"Number of tokens in the input/prompt"},"output_token_size":{"type":"integer","description":"Number of tokens in the generated output/completion"},"is_byok":{"type":"boolean","description":"Whether this request used Bring Your Own Key (BYOK). True if customer's own API key was used."},"endpoint":{"type":"string","description":"API endpoint used for the request"},"created_at":{"type":"integer","description":"Unix timestamp of request creation"},"request":{"type":"object","description":"Full request body that was sent (if available)"},"response":{"type":"object","description":"Full response body that was returned (if available)"},"usage":{"type":"object","description":"Detailed token usage information","properties":{"prompt_tokens":{"type":"integer","description":"Tokens in the prompt"},"completion_tokens":{"type":"integer","description":"Tokens in the completion"},"total_tokens":{"type":"integer","description":"Total tokens used"},"cost":{"type":"number","description":"Cost in USD"}}},"timing":{"type":"object","description":"Timing information","properties":{"started_at":{"type":"integer","description":"Unix timestamp when processing started"},"completed_at":{"type":"integer","description":"Unix timestamp when processing completed"},"duration_ms":{"type":"integer","description":"Total duration in milliseconds"}}},"metadata":{"type":"object","description":"Additional metadata about the request"}}}}}},"400":{"description":"Bad Request - Invalid generation ID format"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"description":"Not Found - Generation ID not found or expired"},"429":{"$ref":"#/components/responses/RateLimitError"},"500":{"description":"Internal Server Error"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fastrouter.ai/api-reference/generations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
