Эта страница ещё не переведена на Русский. Показан английский оригинал.
GET /generation
Tokens, cost and attempt history for one request
Looks up one settled request by its generation id and returns exactly what it cost, how many tokens it used, and which candidates were tried before one answered. This is the endpoint to call when you need to reconcile a charge — total_cost here is not a re-estimate, it is the amount that was actually written to your credit ledger.
GET https://openrouter.myip.co.kr/api/v1/generation?id=gen-…Authentication
Requires a Bearer key — inference (sk-mo-v1-) or management (sk-mo-mgmt-v1-), either works. The generation must belong to the account the key belongs to.
Authorization: Bearer sk-mo-v1-…Query parameters
idstringобязательноThe generation id, e.g. gen-7kqmXbT4vRz9pFhLn2wYcJdA3s. This is the same value returned as the response body's top-level id, and as the X-MyIP-Generation-Id header, on the original chat/completions call. Missing or empty is 400 invalid_request.
When the record exists
A row exists as soon as the originating request settles. For a non-streaming call that's before the response is returned to you, so the record is available immediately. For a streaming call, settlement runs after the stream closes and outside the response's lifetime — if you call GET /generation in the instant right after [DONE], the row can briefly not exist yet. Retry once after a short delay rather than treating that as an error.
Response
idstringThe generation id you looked up.
request_idstringThe request id that produced it (same value as X-MyIP-Request-Id on the original call). Shared across every candidate attempted for that one request.
modelstringThe model that actually answered — served_model_id if the request fell back to a candidate other than the first one you asked for, otherwise the model you requested.
provider_namestring | nullDisplay name of the provider that answered, e.g. "MyIP Local GPU".
total_costnumberWhat was charged, in KRW, rounded to six decimal places. Identical to usage below and to the X-MyIP-Cost-KRW header the original call returned (or the final streaming usage chunk's cost, for a streamed request). This is not recomputed at read time — it is the stored, already-settled amount.
usagenumberSame value as total_cost. Both fields exist because openrouter's shape has historically carried the cost under both names; we keep both rather than pick one and risk breaking a client reading either.
upstream_inference_costnumber | nullOur own cost for this request, in KRW, or null when the candidate that served it has no recorded cost basis (typical for a local GPU model with no per-token USD cost on file).
created_atstringISO 8601 timestamp of when the usage record was written.
streamedbooleanWhether the original request had "stream": true.
cancelledbooleantrue if the client disconnected before the stream finished. A cancelled request is still billed for whatever tokens were generated before the disconnect — see Streaming.
latencyinteger | nullMilliseconds to the first byte from the winning candidate.
generation_timeinteger | nullMilliseconds for the whole request, from the moment it reached the gateway to settlement.
moderation_latencynullAlways null. We do not run a moderation pass.
finish_reasonstring | nullThe normalized finish reason ("stop", "tool_calls", "error", …).
native_finish_reasonstring | nullThe upstream engine's own finish reason string, before normalization. Mirrors finish_reason when the upstream doesn't provide one of its own.
tokens_promptintegerPrompt tokens, same value as native_tokens_prompt.
tokens_completionintegerCompletion tokens (reasoning tokens included), same value as native_tokens_completion.
native_tokens_promptintegerIdentical to tokens_prompt. We report the native tokenizer's count directly rather than re-tokenizing, so there is only one number, exposed under both field names for shape compatibility.
native_tokens_completionintegerIdentical to tokens_completion, for the same reason.
native_tokens_cachedintegerPrompt tokens served from cache. Included inside tokens_prompt, not additional to it. See Prompt caching.
native_tokens_reasoningintegerReasoning tokens. Included inside tokens_completion, not additional to it. 0 for both of our current catalog models. See Reasoning tokens.
num_media_promptnullAlways null. We do not serve multimodal input today.
num_media_completionnullAlways null.
num_search_resultsnullAlways null. We do not have a web-search plugin.
originstring | nullSame value as http_referer.
http_refererstring | nullThe HTTP-Referer header from the original request, if it sent one.
app_idinteger | nullInternal id of the app-attribution row derived from http_referer, or null if none was recorded. See App attribution.
user_agentstring | nullThe User-Agent header from the original request.
provider_responsesobject[]The full attempt log for this request's candidate chain — every candidate tried, in order, whether it succeeded, and how long it took:
[{ "alias": "local::google/gemma-4-26b-a4b", "status": 200, "error": null, "ms": 812 }]status is the HTTP status from that candidate, or a string like "timeout", "connect_error", or "slot_cold_budget_exceeded" when the failure happened before any HTTP response. error is a truncated message, or null on success. This is what you read to understand why a request took longer than expected, or which candidate in a models[] list actually served it. See Model fallbacks.
is_byokbooleanAlways false. We do not support bring-your-own-key.
cache_discountnullAlways null. Cache savings are reflected directly in total_cost (a lower cached_tokens rate was applied); there is no separate discount figure to report.
api_typestringAlways "chat".
data_regionstringAlways "kr".
routernullAlways null. There is no auto-router — see Principles.
preset_idnullAlways null. We do not have Presets.
session_idnullAlways null. We do not implement session_id sticky routing — see Prompt caching.
workspace_idnullAlways null. We do not have Workspaces.
external_usernullAlways null.
service_tiernullAlways null.
Response example
curl -s "https://openrouter.myip.co.kr/api/v1/generation?id=gen-7kqmXbT4vRz9pFhLn2wYcJdA3s" \
-H "Authorization: Bearer $MYIP_API_KEY"{
"data": {
"id": "gen-7kqmXbT4vRz9pFhLn2wYcJdA3s",
"request_id": "req-9dLpQn3kVsWx7mB2tYeRfH6uZa",
"model": "google/gemma-4-26b-a4b",
"provider_name": "MyIP Local GPU",
"total_cost": 0.005310,
"usage": 0.005310,
"upstream_inference_cost": 0.001076,
"created_at": "2026-09-04T09:12:41.000Z",
"streamed": false,
"cancelled": false,
"latency": 812,
"generation_time": 1240,
"moderation_latency": null,
"finish_reason": "stop",
"native_finish_reason": "stop",
"tokens_prompt": 42,
"tokens_completion": 27,
"native_tokens_prompt": 42,
"native_tokens_completion": 27,
"native_tokens_cached": 0,
"native_tokens_reasoning": 0,
"num_media_prompt": null,
"num_media_completion": null,
"num_search_results": null,
"origin": "https://myapp.example",
"http_referer": "https://myapp.example",
"app_id": 14,
"user_agent": "openai-python/1.54.0",
"provider_responses": [
{ "alias": "local::google/gemma-4-26b-a4b", "status": 200, "error": null, "ms": 812 }
],
"is_byok": false,
"cache_discount": null,
"api_type": "chat",
"data_region": "kr",
"router": null,
"preset_id": null,
"session_id": null,
"workspace_id": null,
"external_user": null,
"service_tier": null
}
}A chain with a fallback
When a candidate failed before the one that answered, provider_responses has more than one entry, and model / provider_name reflect the one that actually produced the reply, not the first one requested:
{
"model": "google/gemma-4-26b-a4b",
"provider_name": "MyIP Local GPU",
"provider_responses": [
{ "alias": "local::lgai/exaone-4.0-32b", "status": "slot_budget_exceeded", "error": "wait budget exceeded", "ms": 5000 },
{ "alias": "local::google/gemma-4-26b-a4b", "status": 200, "error": null, "ms": 640 }
]
}Errors
| Status | error_type | When |
|---|---|---|
| 400 | invalid_request | id query parameter missing or empty |
| 401 | invalid_api_key | No Authorization header, or the key doesn't parse as either key format |
| 404 | not_supported | No usage record with that id belongs to your account (or it doesn't exist at all) |
See Errors and debugging for the general error envelope.
Related
- Streaming — why a streamed request's record can lag slightly behind
[DONE] - How costs are calculated — the formula behind
total_cost - Model fallbacks — reading
provider_responsesto see why a request took the path it did
Последнее обновление: 5 сент. 2026 г.