API Reference
Generation lookup
Per-request cost and token stats by request ID
GET /v1/generation
Look up token usage and cost for a completed gateway request (OpenRouter-compatible).
curl "https://gateway.yahagateway.io/v1/generation?id=YOUR_REQUEST_ID" \
-H "Authorization: Bearer yaha.YOUR_KEY"Parameters
| Query | Required | Description |
|---|---|---|
id | yes | Gateway request_id (same value as X-Request-ID when provided) |
Response
{
"id": "abc123",
"model": "openai/gpt-4o",
"provider": "openai",
"tokens_prompt": 120,
"tokens_completion": 40,
"total_cost": 0.00038,
"usage": {
"prompt_tokens": 120,
"completion_tokens": 40,
"total_tokens": 160,
"cost": 0.00038
},
"fallback_attempts": 0,
"latency_ms": 842
}Stats are scoped to the project that owns the Yaha key. Data is written asynchronously after the request completes (typically within seconds).