费用查询

用响应体里的 id(Claude 接口是 message.id,Responses 是 response.id)查这一次请求的 token 数、耗时与费用。Bearer Key 鉴权,只能查自己 Key 发出的请求;保留最近 30 天,找不到返回 404 generation_not_found。结算在响应结束后写入,流式请求请稍等一两秒再查。

请求与响应

GET /api/v1/generation
curl "https://inferstream.cn/api/v1/generation?id=chatcmpl-…" \
  -H "Authorization: Bearer $INFERSTREAM_API_KEY"
响应
{
  "id": "chatcmpl-…",
  "request_id": "20260910110743325678000tMNbU2xW",
  "model": "gpt-4o",
  "provider": "OpenAI",
  "created_at": 1789000000,
  "streamed": true,
  "latency_ms": 1830,
  "first_token_ms": 420,
  "tokens_prompt": 1200,
  "tokens_completion": 340,
  "tokens_cached": 800,
  "tokens_reasoning": 0,
  "cost_cny": 0.0123,
  "cost_quota": 842
}

字段说明

字段含义
cost_quota实际扣除的内部额度单位,对账以它为准
cost_cnycost_quota 折算的人民币,保留 4 位小数;极小的请求会显示 0
tokens_prompt / tokens_completion输入与输出 token;推理 token 计入输出
tokens_cached按缓存价计费的那部分输入 token
tokens_reasoning推理 token 数
provider / model实际服务的供应商与模型名(多模型回退后可能不是请求里的第一个)
streamed是否流式请求
latency_ms从收到请求到响应结束的耗时
first_token_ms首字节耗时,只对流式请求有意义,非流式为 0
request_id网关请求号,与响应头 X-Request-Id 相同,反馈问题时请提供

额度单位与人民币的换算见计费;按天、按模型、按 Key 的汇总在控制台用量页,也可通过控制台接口取回。