Generation
Look up cost and usage for one request.
GET /generation?id= returns the cost and token counts of one earlier request.
Take the id from the X-Generation-Id header of that request, or from the id of a chat, completions, Responses or embeddings answer. A /messages answer has a msg_ id, so use the header there. An embeddings id starts with gen-emb-.
An id that does not start with gen- returns 400. An id from another account, or one not yet recorded, returns 404; a new id can take a moment to appear.
model is the id of the model that served the request, without a :floor or :nitro suffix. After a model fallback it is the fallback model. total_cost and usage are the charge in USD. streamed says whether the answer was streamed. provider_responses lists each host tried, in order, with its status.
workspace_id is the id of the workspace of the key that sent the request.
api_type is completions for the chat, completions, Messages and Responses endpoints, and embeddings for an embeddings request. An embeddings generation has streamed false, and null completion tokens, cached tokens and finish reasons, as on OpenRouter.
Request
curl 'https://api.plaingateway.com/api/v1/generation?id=gen-6f2d0c5e9a1b4c7d8e3f2a10' \ -H "Authorization: Bearer $PLAINGATEWAY_API_KEY"
Response
HTTP/1.1 200
{
"data": {
"created_at": "1970-01-01T00:00:00Z",
"model": "openai/gpt-5.6-luna",
"app_id": null,
"external_user": null,
"streamed": true,
"cancelled": false,
"latency": 1036,
"moderation_latency": null,
"generation_time": 1036,
"tokens_prompt": 6,
"tokens_completion": 7,
"native_tokens_prompt": 12,
"native_tokens_completion": 11,
"native_tokens_completion_images": 0,
"native_tokens_reasoning": 0,
"native_tokens_cached": 0,
"num_media_prompt": null,
"num_input_audio_prompt": null,
"num_media_completion": 0,
"num_search_results": null,
"num_fetches": null,
"web_search_engine": null,
"origin": "",
"is_byok": false,
"finish_reason": "stop",
"native_finish_reason": "completed",
"service_tier": "default",
"usage": 1.56e-05,
"router": null,
"user_agent": "curl/8.7.1",
"http_referer": null,
"request_id": "req-1792038846-SYcf5HD6fusXxy4YDYmB",
"session_id": null,
"preset_id": null,
"api_type": "completions",
"id": "gen-6f2d0c5e9a1b4c7d8e3f2a10",
"upstream_id": "resp_0a1b2c3d4e5f60718293a4b5",
"provider_responses": [
{
"endpoint_id": "eebea444-34a5-4642-a766-cb319471d33a",
"id": "resp_0a1b2c3d4e5f60718293a4b5",
"is_byok": false,
"latency": 426,
"model_permaslug": "openai/gpt-5.6-luna-20260709",
"provider_name": "OpenAI",
"status": 200
}
],
"total_cost": 1.56e-05,
"cache_discount": null,
"upstream_inference_cost": 0,
"provider_name": "OpenAI",
"response_cache_source_id": null,
"data_region": "global",
"workspace_id": "4b871218-f911-581f-adab-89998b54c9c1"
}
}