Generations lookup

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): id in each chat.completion.chunk (e.g., chatcmpl-...).
  • OpenAI Chat Completions (JSON): id in the response.
  • OpenAI Responses (streaming): response.created / response.in_progress and subsequent events include response.id (e.g., resp_...).
  • OpenAI Responses (JSON): id in the response.
  • Anthropic Messages (streaming): message_start includes message.id (e.g., msg_...).
  • Anthropic Messages (JSON): id in 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_reason

Response 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.
  • endpoint indicates which adapter handled the request: openai.chat.completions, openai.responses, or anthropic.messages.
  • For OpenAI Responses, status may be completed or requires_action.