跳转到主要内容
通过 ID 获取已完成生成的详细元数据。使用此端点可以查看任何历史请求的费用和用量。

端点

GET /api/v1/generation

查询参数

参数类型必需描述
idstring来自聊天补全响应 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
    }
  }
}

响应字段

字段类型描述
idstring生成 ID
modelstring生成响应的模型
providerstring处理请求的提供商
created_atstringISO 8601 时间戳
latency_msinteger请求总延迟(毫秒)
usage.prompt_tokensinteger输入 Token 数
usage.completion_tokensinteger输出 Token 数
usage.total_tokensinteger总 Token 数
usage.costnumber总费用(USD)
usage.is_byokboolean是否使用了用户提供的 key

说明

  • 生成元数据通常在请求完成后数秒内即可获取
  • 生成 ID 在每个聊天补全响应的 id 字段中返回
  • 历史数据保留 90 天