端點
GET /api/v1/generation
查詢參數
| 參數 | 類型 | 必需 | 描述 |
|---|---|---|---|
id | string | 是 | 來自聊天補全回應 id 欄位的生成 ID |
請求範例
curl "https://api.arouter.ai/api/v1/generation?id=gen-1775226820-719aea642d4b4d279c897793" \
-H "Authorization: Bearer lr_live_xxxx"
回應範例
{
"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
}
}
}
回應欄位
| 欄位 | 類型 | 描述 |
|---|---|---|
id | string | 生成 ID |
model | string | 生成回應的模型 |
provider | string | 處理請求的提供商 |
created_at | string | ISO 8601 時間戳 |
latency_ms | integer | 請求總延遲(毫秒) |
usage.prompt_tokens | integer | 輸入 Token 數 |
usage.completion_tokens | integer | 輸出 Token 數 |
usage.total_tokens | integer | 總 Token 數 |
usage.cost | number | 總費用(USD) |
usage.is_byok | boolean | 是否使用了使用者提供的 key |
說明
- 生成元數據通常在請求完成後數秒內即可取得
- 生成 ID 在每個聊天補全回應的
id欄位中回傳 - 歷史資料保留 90 天