Python SDKAPI ReferenceComponents
GenerationResponseData - Python SDK
GenerationResponseData - Python SDK
GenerationResponseData method reference
The Python SDK and docs are currently in beta. Report issues on GitHub.
Generation data
Fields
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
api_type | Nullable[components.APIType] | ✔️ | Type of API used for the generation | |
app_id | Nullable[int] | ✔️ | ID of the app that made the request | 12345 |
cache_discount | Nullable[float] | ✔️ | Discount applied due to caching | 0.0002 |
cancelled | Nullable[bool] | ✔️ | Whether the generation was cancelled | false |
created_at | str | ✔️ | ISO 8601 timestamp of when the generation was created | 2024-07-15T23:33:19.433273+00:00 |
data_region | components.DataRegion | ✔️ | The data region this generation was routed through. ‘europe’ for EU-routed requests, ‘global’ otherwise. | global |
external_user | Nullable[str] | ✔️ | External user identifier | user-123 |
finish_reason | Nullable[str] | ✔️ | Reason the generation finished | stop |
generation_time | Nullable[float] | ✔️ | Time taken for generation in milliseconds | 1200 |
http_referer | Nullable[str] | ✔️ | Referer header from the request | |
id | str | ✔️ | Unique identifier for the generation | gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG |
is_byok | bool | ✔️ | Whether this used bring-your-own-key | false |
latency | Nullable[float] | ✔️ | Total latency in milliseconds | 1250 |
model | str | ✔️ | Model used for the generation | sao10k/l3-stheno-8b |
moderation_latency | Nullable[float] | ✔️ | Moderation latency in milliseconds | 50 |
native_finish_reason | Nullable[str] | ✔️ | Native finish reason as reported by provider | stop |
native_tokens_cached | Nullable[int] | ✔️ | Native cached tokens as reported by provider | 3 |
native_tokens_completion | Nullable[int] | ✔️ | Native completion tokens as reported by provider | 25 |
native_tokens_completion_images | Nullable[int] | ✔️ | Native completion image tokens as reported by provider | 0 |
native_tokens_prompt | Nullable[int] | ✔️ | Native prompt tokens as reported by provider | 10 |
native_tokens_reasoning | Nullable[int] | ✔️ | Native reasoning tokens as reported by provider | 5 |
num_fetches | Nullable[int] | ✔️ | Number of web fetches performed | 0 |
num_input_audio_prompt | Nullable[int] | ✔️ | Number of audio inputs in the prompt | 0 |
num_media_completion | Nullable[int] | ✔️ | Number of media items in the completion | 0 |
num_media_prompt | Nullable[int] | ✔️ | Number of media items in the prompt | 1 |
num_search_results | Nullable[int] | ✔️ | Number of search results included | 5 |
origin | str | ✔️ | Origin URL of the request | https://openrouter.ai/ |
preset_id | Nullable[str] | ✔️ | ID of the preset used for this generation, null if no preset was used | a9e8d400-592a-494f-908c-375efa66cafd |
provider_name | Nullable[str] | ✔️ | Name of the provider that served the request | Infermatic |
provider_responses | List[components.ProviderResponse] | ✔️ | List of provider responses for this generation, including fallback attempts | |
request_id | OptionalNullable[str] | ➖ | Unique identifier grouping all generations from a single API request | req-1727282430-aBcDeFgHiJkLmNoPqRsT |
response_cache_source_id | OptionalNullable[str] | ➖ | If this generation was served from response cache, contains the original generation ID. Null otherwise. | |
router | Nullable[str] | ✔️ | Router used for the request (e.g., openrouter/auto) | openrouter/auto |
service_tier | Nullable[str] | ✔️ | Service tier the upstream provider reported running this request on, or null if it did not report one. | priority |
session_id | OptionalNullable[str] | ➖ | Session identifier grouping multiple generations in the same session | |
streamed | Nullable[bool] | ✔️ | Whether the response was streamed | true |
tokens_completion | Nullable[int] | ✔️ | Number of tokens in the completion | 25 |
tokens_prompt | Nullable[int] | ✔️ | Number of tokens in the prompt | 10 |
total_cost | float | ✔️ | Total cost of the generation in USD | 0.0015 |
upstream_id | Nullable[str] | ✔️ | Upstream provider’s identifier for this generation | chatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946 |
upstream_inference_cost | Nullable[float] | ✔️ | Cost charged by the upstream provider | 0.0012 |
usage | float | ✔️ | Usage amount in USD | 0.0015 |
user_agent | Nullable[str] | ✔️ | User-Agent header from the request | |
web_search_engine | Nullable[str] | ✔️ | The resolved web search engine used for this generation (e.g. exa, firecrawl, parallel) | exa |