Loading...
Loading...
Retrieve detailed metadata and stored content for individual OpenRouter generations. Use when the user wants to inspect a specific request — its cost, latency, token usage, provider routing, or the actual prompt/completion text — or is debugging a failed or unexpected generation.
npx skill4agent add openrouterteam/skills openrouter-generations--api-key <key>OPENROUTER_API_KEYgen-1234567890gen-aBcDeFgHiJkLmNoPqRsTcd <skill-path>/scripts && npm install| Endpoint | Method | Purpose |
|---|---|---|
| GET | Request metadata and usage (tokens, cost, latency, model, provider) |
| GET | Stored prompt and completion text |
idcd <skill-path>/scripts && npx tsx get-generation.ts gen-1234567890
npx tsx get-generation.ts --id gen-1234567890 --jsonmodelprovider_namerouterservice_tiertokens_prompttokens_completionnative_tokens_reasoningnative_tokens_cachedtotal_costusageupstream_inference_costcache_discountlatencygeneration_timemoderation_latencyfinish_reasonstreamedcancelledis_byokcreated_atapp_idexternal_usersession_idrequest_idprovider_responsescd <skill-path>/scripts && npx tsx get-generation-content.ts gen-1234567890
npx tsx get-generation-content.ts --id gen-1234567890 --jsonpromptmessages{role, content}completionreasoningcurl -G https://openrouter.ai/api/v1/generation \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-d id=gen-1234567890curl -G https://openrouter.ai/api/v1/generation/content \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-d id=gen-1234567890/api/v1/generation{
"data": {
"id": "gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG",
"api_type": "completions",
"model": "openai/gpt-4o",
"provider_name": "OpenAI",
"created_at": "2024-07-15T23:33:19.433273+00:00",
"tokens_prompt": 10,
"tokens_completion": 25,
"native_tokens_reasoning": 5,
"native_tokens_cached": 3,
"total_cost": 0.0015,
"usage": 0.0015,
"upstream_inference_cost": 0.0012,
"latency": 1250,
"generation_time": 1200,
"finish_reason": "stop",
"streamed": true,
"is_byok": false,
"cancelled": false,
"router": "openrouter/auto",
"service_tier": "priority",
"provider_responses": [
{
"provider_name": "OpenAI",
"model_permaslug": "openai/gpt-4o",
"status": 200,
"latency": 1200,
"is_byok": false
}
]
}
}/api/v1/generation/content{
"data": {
"input": {
"prompt": "What is the meaning of life?",
"messages": [
{
"content": "What is the meaning of life?",
"role": "user"
}
]
},
"output": {
"completion": "The meaning of life is a philosophical question...",
"reasoning": null
}
}
}# Check what happened — look at finish_reason, provider_responses, and cancelled
cd <skill-path>/scripts && npx tsx get-generation.ts gen-abc123 --jsonfinish_reason"length"finish_reason"content_filter"cancelledtrueprovider_responsescd <skill-path>/scripts && npx tsx get-generation.ts gen-abc123total_costupstream_inference_costcd <skill-path>/scripts && npx tsx get-generation-content.ts gen-abc123request_idsession_idopenrouter-analytics| Status | Meaning |
|---|---|
| 401 | Invalid or missing API key |
| 403 | You don't have access to this generation (belongs to another user) |
| 404 | Generation ID not found |
| 429 | Rate limited — wait and retry |
| 500 | Server error — retry |
| 502 | Upstream failure — retry |
| Field | Type | Description |
|---|---|---|
| string | Generation ID ( |
| string | Model permaslug (e.g., |
| string|null | Provider that served the request |
| string | One of: |
| int|null | Prompt token count |
| int|null | Completion token count |
| int|null | Reasoning/thinking tokens |
| int|null | Cached input tokens |
| number | Total cost in USD |
| number | Usage amount in USD |
| number|null | Provider's cost in USD |
| number|null | Discount from caching |
| number|null | Total latency in ms |
| number|null | Model generation time in ms |
| number|null | Moderation check time in ms |
| string|null | Why generation stopped ( |
| string|null | Raw finish reason from provider |
| bool|null | Whether response was streamed |
| bool | Whether user's own provider key was used |
| bool|null | Whether request was cancelled |
| int|null | OAuth app ID |
| string|null | External user identifier (X-External-User header) |
| string|null | Session grouping ID |
| string|null | Request grouping ID (all gens from one API call) |
| string|null | Router used (e.g., |
| string|null | Provider service tier |
| string|null | Search engine used (e.g., |
| int|null | Number of search results included |
| array|null | Provider attempt chain with per-provider latency/status |
| Field | Type | Description |
|---|---|---|
| string|null | Raw prompt text |
| array|null | Messages array ( |
| string|null | Model's completion text |
| string|null | Chain-of-thought reasoning |