Skip to main content
Retrieve detailed metadata for a completed generation by its ID. Use this endpoint to check cost and usage for any past request.

Endpoint

GET /api/v1/generation

Query Parameters

ParameterTypeRequiredDescription
idstringYesGeneration ID from the id field of a chat completion response

Example Request

curl "https://api.arouter.ai/api/v1/generation?id=gen-1775226820-719aea642d4b4d279c897793" \
  -H "Authorization: Bearer lr_live_xxxx"

Example Response

{
  "id": "gen-1775226820-719aea642d4b4d279c897793",
  "model": "anthropic/claude-sonnet-4.6",
  "provider": "Google",
  "created_at": "2026-04-03T12:00:00Z",
  "latency_ms": 1240,
  "usage": {
    "prompt_tokens": 14,
    "completion_tokens": 6,
    "total_tokens": 20,
    "cost": 0.000132,
    "is_byok": false,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "cache_write_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0
    },
    "cost_details": {
      "upstream_inference_cost": 0.000132,
      "upstream_inference_prompt_cost": 0.0000420,
      "upstream_inference_completions_cost": 0.000090
    }
  }
}

Response Fields

FieldTypeDescription
idstringGeneration ID
modelstringModel that generated the response
providerstringProvider that served the request
created_atstringISO 8601 timestamp
latency_msintegerTotal request latency in milliseconds
usage.prompt_tokensintegerInput tokens
usage.completion_tokensintegerOutput tokens
usage.total_tokensintegerTotal tokens
usage.costnumberTotal cost in USD
usage.is_byokbooleanWhether a user-provided key was used

Notes

  • Generation metadata is typically available within a few seconds of the request completing
  • Generation IDs are returned in the id field of every chat completion response
  • Historical data is retained for 90 days