Generations lookup
Use Generations to retrieve usage and metadata for a completed request (streaming or non‑streaming) using its generation ID.
- Endpoint:
GET /api/v1/generations?id=<ID> - Alias:
GET /api/v1/generation?id=<ID>(307 redirect to/api/v1/generations) - Auth:
Authorization: Bearer $API_KEY - Returns:
{ success: true, generation: { ... } }
IDs come from the original response/stream:
- OpenAI Chat Completions (streaming):
idin eachchat.completion.chunk(e.g.,chatcmpl-...). - OpenAI Chat Completions (JSON):
idin the response. - OpenAI Responses (streaming):
response.created/response.in_progressand subsequent events includeresponse.id(e.g.,resp_...). - OpenAI Responses (JSON):
idin the response. - Anthropic Messages (streaming):
message_startincludesmessage.id(e.g.,msg_...). - Anthropic Messages (JSON):
idin the response.
Example (JavaScript)
const id = 'chatcmpl-...';
const res = await fetch('https://api.kushrouter.com/api/v1/generations?id=' + encodeURIComponent(id), {
headers: { Authorization: `Bearer ${process.env.KUSHROUTER_API_KEY}` },
});
if (!res.ok) throw new Error('Generation not found');
const body = await res.json();
console.log(body.generation.usage);Example (Python)
import requests
r = requests.get(
'https://api.kushrouter.com/api/v1/generations',
params={'id': gen_id},
headers={'Authorization': f'Bearer {API_KEY}'},
)
r.raise_for_status()
print(r.json()["generation"]) # usage, endpoint, model, finish_reasonResponse shape
{
"success": true,
"generation": {
"id": "chatcmpl-1731753062-2q7nyc",
"endpoint": "openai.chat.completions",
"stream": true,
"model": "gpt-5-mini-2025-08-07",
"created_at": 1731753062,
"apiKeyId": "ak_...",
"usage": {
"prompt_tokens": 121,
"completion_tokens": 345,
"total_tokens": 466,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
},
"finish_reason": "stop"
}
}Notes:
- Only the API key that created the generation can access it.
- Records are retained for at least 7 days.
endpointindicates which adapter handled the request:openai.chat.completions,openai.responses, oranthropic.messages.- For OpenAI Responses,
statusmay becompletedorrequires_action.