> ## Documentation Index
> Fetch the complete documentation index at: https://openrouter-d02e98a0-mintlify-5b6e02fd.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# GetGenerationData - Python SDK

> GetGenerationData method reference

<Warning>
  The Python SDK and docs are currently in beta.
  Report issues on [GitHub](https://github.com/OpenRouterTeam/python-sdk/issues).
</Warning>

Generation data

## Fields

| Field                             | Type                                                       | Required             | Description                                            | Example                                          |
| --------------------------------- | ---------------------------------------------------------- | -------------------- | ------------------------------------------------------ | ------------------------------------------------ |
| `id`                              | *str*                                                      | :heavy\_check\_mark: | Unique identifier for the generation                   | gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG                 |
| `upstream_id`                     | *Nullable\[str]*                                           | :heavy\_check\_mark: | Upstream provider's identifier for this generation     | chatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946    |
| `total_cost`                      | *float*                                                    | :heavy\_check\_mark: | Total cost of the generation in USD                    | 0.0015                                           |
| `cache_discount`                  | *Nullable\[float]*                                         | :heavy\_check\_mark: | Discount applied due to caching                        | 0.0002                                           |
| `upstream_inference_cost`         | *Nullable\[float]*                                         | :heavy\_check\_mark: | Cost charged by the upstream provider                  | 0.0012                                           |
| `created_at`                      | *str*                                                      | :heavy\_check\_mark: | ISO 8601 timestamp of when the generation was created  | 2024-07-15T23:33:19.433273+00:00                 |
| `model`                           | *str*                                                      | :heavy\_check\_mark: | Model used for the generation                          | sao10k/l3-stheno-8b                              |
| `app_id`                          | *Nullable\[float]*                                         | :heavy\_check\_mark: | ID of the app that made the request                    | 12345                                            |
| `streamed`                        | *Nullable\[bool]*                                          | :heavy\_check\_mark: | Whether the response was streamed                      | true                                             |
| `cancelled`                       | *Nullable\[bool]*                                          | :heavy\_check\_mark: | Whether the generation was cancelled                   | false                                            |
| `provider_name`                   | *Nullable\[str]*                                           | :heavy\_check\_mark: | Name of the provider that served the request           | Infermatic                                       |
| `latency`                         | *Nullable\[float]*                                         | :heavy\_check\_mark: | Total latency in milliseconds                          | 1250                                             |
| `moderation_latency`              | *Nullable\[float]*                                         | :heavy\_check\_mark: | Moderation latency in milliseconds                     | 50                                               |
| `generation_time`                 | *Nullable\[float]*                                         | :heavy\_check\_mark: | Time taken for generation in milliseconds              | 1200                                             |
| `finish_reason`                   | *Nullable\[str]*                                           | :heavy\_check\_mark: | Reason the generation finished                         | stop                                             |
| `tokens_prompt`                   | *Nullable\[float]*                                         | :heavy\_check\_mark: | Number of tokens in the prompt                         | 10                                               |
| `tokens_completion`               | *Nullable\[float]*                                         | :heavy\_check\_mark: | Number of tokens in the completion                     | 25                                               |
| `native_tokens_prompt`            | *Nullable\[float]*                                         | :heavy\_check\_mark: | Native prompt tokens as reported by provider           | 10                                               |
| `native_tokens_completion`        | *Nullable\[float]*                                         | :heavy\_check\_mark: | Native completion tokens as reported by provider       | 25                                               |
| `native_tokens_completion_images` | *Nullable\[float]*                                         | :heavy\_check\_mark: | Native completion image tokens as reported by provider | 0                                                |
| `native_tokens_reasoning`         | *Nullable\[float]*                                         | :heavy\_check\_mark: | Native reasoning tokens as reported by provider        | 5                                                |
| `native_tokens_cached`            | *Nullable\[float]*                                         | :heavy\_check\_mark: | Native cached tokens as reported by provider           | 3                                                |
| `num_media_prompt`                | *Nullable\[float]*                                         | :heavy\_check\_mark: | Number of media items in the prompt                    | 1                                                |
| `num_input_audio_prompt`          | *Nullable\[float]*                                         | :heavy\_check\_mark: | Number of audio inputs in the prompt                   | 0                                                |
| `num_media_completion`            | *Nullable\[float]*                                         | :heavy\_check\_mark: | Number of media items in the completion                | 0                                                |
| `num_search_results`              | *Nullable\[float]*                                         | :heavy\_check\_mark: | Number of search results included                      | 5                                                |
| `origin`                          | *str*                                                      | :heavy\_check\_mark: | Origin URL of the request                              | [https://openrouter.ai/](https://openrouter.ai/) |
| `usage`                           | *float*                                                    | :heavy\_check\_mark: | Usage amount in USD                                    | 0.0015                                           |
| `is_byok`                         | *bool*                                                     | :heavy\_check\_mark: | Whether this used bring-your-own-key                   | false                                            |
| `native_finish_reason`            | *Nullable\[str]*                                           | :heavy\_check\_mark: | Native finish reason as reported by provider           | stop                                             |
| `external_user`                   | *Nullable\[str]*                                           | :heavy\_check\_mark: | External user identifier                               | user-123                                         |
| `api_type`                        | [Nullable\[operations.APIType\]](../operations/apitype.md) | :heavy\_check\_mark: | Type of API used for the generation                    |                                                  |
| `router`                          | *Nullable\[str]*                                           | :heavy\_check\_mark: | Router used for the request (e.g., openrouter/auto)    | openrouter/auto                                  |
