Cette page n'est pas encore traduite en Français. La version anglaise d'origine est affichée.

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

idstringobligatoire

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

idstring

The generation id you looked up.

request_idstring

The 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.

modelstring

The 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 | null

Display name of the provider that answered, e.g. "MyIP Local GPU".

total_costnumber

What 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.

usagenumber

Same 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 | null

Our 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_atstring

ISO 8601 timestamp of when the usage record was written.

streamedboolean

Whether the original request had "stream": true.

cancelledboolean

true 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 | null

Milliseconds to the first byte from the winning candidate.

generation_timeinteger | null

Milliseconds for the whole request, from the moment it reached the gateway to settlement.

moderation_latencynull

Always null. We do not run a moderation pass.

finish_reasonstring | null

The normalized finish reason ("stop", "tool_calls", "error", …).

native_finish_reasonstring | null

The upstream engine's own finish reason string, before normalization. Mirrors finish_reason when the upstream doesn't provide one of its own.

tokens_promptinteger

Prompt tokens, same value as native_tokens_prompt.

tokens_completioninteger

Completion tokens (reasoning tokens included), same value as native_tokens_completion.

native_tokens_promptinteger

Identical 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_completioninteger

Identical to tokens_completion, for the same reason.

native_tokens_cachedinteger

Prompt tokens served from cache. Included inside tokens_prompt, not additional to it. See Prompt caching.

native_tokens_reasoninginteger

Reasoning tokens. Included inside tokens_completion, not additional to it. 0 for both of our current catalog models. See Reasoning tokens.

num_media_promptnull

Always null. We do not serve multimodal input today.

num_media_completionnull

Always null.

num_search_resultsnull

Always null. We do not have a web-search plugin.

originstring | null

Same value as http_referer.

http_refererstring | null

The HTTP-Referer header from the original request, if it sent one.

app_idinteger | null

Internal id of the app-attribution row derived from http_referer, or null if none was recorded. See App attribution.

user_agentstring | null

The 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:

json
[{ "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_byokboolean

Always false. We do not support bring-your-own-key.

cache_discountnull

Always 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_typestring

Always "chat".

data_regionstring

Always "kr".

routernull

Always null. There is no auto-router — see Principles.

preset_idnull

Always null. We do not have Presets.

session_idnull

Always null. We do not implement session_id sticky routing — see Prompt caching.

workspace_idnull

Always null. We do not have Workspaces.

external_usernull

Always null.

service_tiernull

Always null.

Response example

bash
curl -s "https://openrouter.myip.co.kr/api/v1/generation?id=gen-7kqmXbT4vRz9pFhLn2wYcJdA3s" \
  -H "Authorization: Bearer $MYIP_API_KEY"
json
{
  "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:

json
{
  "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

Statuserror_typeWhen
400invalid_requestid query parameter missing or empty
401invalid_api_keyNo Authorization header, or the key doesn't parse as either key format
404not_supportedNo 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.

Dernière mise à jour : 5 sept. 2026