plaingateway
API reference

Generation

Look up cost and usage for one request.

GET /generation?id= reads the generation ID from X-Generation-Id or X-PG-Request-Id. Messages uses a msg_ response ID, so use the header for its lookup.

Request

http
GET https://plaingateway.com/api/v1/generation?id=gen-SCRUBBED-1
Authorization: Bearer sk-pg-v1-...

Response

http
HTTP/1.1 200
{
  "data": {
    "created_at": "1970-01-01T00:00:00Z",
    "model": "openai/gpt-5.6-luna-20260709",
    "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": "plaingateway-recorder/1.0",
    "http_referer": null,
    "request_id": "req-1792038846-SYcf5HD6fusXxy4YDYmB",
    "session_id": null,
    "preset_id": null,
    "api_type": "completions",
    "id": "gen-SCRUBBED-1",
    "upstream_id": "resp_SCRUBBED-2",
    "provider_responses": [
      {
        "endpoint_id": "eebea444-34a5-4642-a766-cb319471d33a",
        "id": "resp_SCRUBBED-2",
        "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"
  }
}