For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
  • API Guides
    • Overview
    • Streaming
    • Embeddings
    • Limits
    • Authentication
    • Parameters
    • Errors and Debugging
  • API Reference
      • GETGet request & usage metadata for a generation
      • GETGet stored prompt and completion content for a generation
LogoLogo
ModelsChatRankingsDocs
API ReferenceGenerations

Get request & usage metadata for a generation

GET
https://openrouter.ai/api/v1/generation
GET
/api/v1/generation
$curl -G https://openrouter.ai/api/v1/generation \
> -H "Authorization: Bearer <token>" \
> -d id=gen-1234567890
1{
2 "data": {
3 "api_type": "completions",
4 "app_id": 12345,
5 "cache_discount": null,
6 "cancelled": false,
7 "created_at": "2024-07-15T23:33:19.433273+00:00",
8 "external_user": "user-123",
9 "finish_reason": "stop",
10 "generation_time": 1200,
11 "http_referer": "https://openrouter.ai/",
12 "id": "gen-3bhGkxlo4XFrqiabUM7NDtwDzWwG",
13 "is_byok": false,
14 "latency": 1250,
15 "model": "sao10k/l3-stheno-8b",
16 "moderation_latency": 50,
17 "native_finish_reason": "stop",
18 "native_tokens_cached": 3,
19 "native_tokens_completion": 25,
20 "native_tokens_completion_images": 0,
21 "native_tokens_prompt": 10,
22 "native_tokens_reasoning": 5,
23 "num_fetches": 0,
24 "num_input_audio_prompt": 0,
25 "num_media_completion": 0,
26 "num_media_prompt": 1,
27 "num_search_results": 5,
28 "origin": "https://openrouter.ai/",
29 "provider_name": "Infermatic",
30 "provider_responses": null,
31 "router": "openrouter/auto",
32 "service_tier": "priority",
33 "streamed": true,
34 "tokens_completion": 25,
35 "tokens_prompt": 10,
36 "total_cost": 0.0015,
37 "upstream_id": "chatcmpl-791bcf62-080e-4568-87d0-94c72e3b4946",
38 "upstream_inference_cost": 0.0012,
39 "usage": 0.0015,
40 "user_agent": "Mozilla/5.0",
41 "web_search_engine": "exa",
42 "request_id": "req-1727282430-aBcDeFgHiJkLmNoPqRsT",
43 "session_id": null
44 }
45}
Was this page helpful?
Previous

Get stored prompt and completion content for a generation

Next
Built with

Authentication

AuthorizationBearer
API key as bearer token in Authorization header

Query parameters

idstringRequired>=1 character
The generation ID

Response

Returns the request metadata for this generation
dataobject
Generation data

Errors

401
Unauthorized Error
402
Payment Required Error
404
Not Found Error
429
Too Many Requests Error
500
Internal Server Error
502
Bad Gateway Error