Get generation
GET https://api.dayaai.com/api/v1/management/generation?id=<generation_id>⚠️ 旧版地址已废弃
旧版接口地址 GET /api/v1/generation 已废弃,请迁移至新版地址 GET /api/v1/management/generation。旧版地址将在后续版本中下线。
Get generation 接口用于查询生成信息,如用量和费用等。
TIP
本接口支持查询所有 API 协议的生成信息,包括 OpenAI Chat Completions、OpenAI Responses、Anthropic 和 Vertex AI 协议。
⚠️ 订阅制限制
本接口仅支持 Pay As You Go(按量付费) 的 API Key 查询计费信息。使用订阅制 API Key(以 sk-ss-v1- 开头)调用本接口将无法获取计费相关字段(如 usage、ratingResponses 等)。
如需获取计费信息,请使用 Pay As You Go API Key。详见:
计量与计费信息说明
计量信息(Token Usage)
计量信息(如 nativeTokens 字段中的 token 使用量)会按照不同通信协议原本的方式随请求同步返回:
- OpenAI Chat Completions 协议:在响应的
usage字段中返回 - OpenAI Responses 协议:在响应的
usage字段中返回 - Anthropic 协议:在响应的
usage字段中返回 - Vertex AI 协议:在响应的
usageMetadata字段中返回
计费信息(Billing & Costs)
计费信息(如 usage、ratingResponses 等费用相关字段)暂不支持随请求同步返回,需要在请求完成后 3-5 分钟通过本接口查询获取。
💡 功能升级中
我们正在完善升级计费架构,争取早日实现计费信息随请求同步返回,敬请期待!
Request params
Authorization Header
请求头参数:
Authorization: Bearer <DAYA_API_KEY>- 参数名:
Authorization - 格式:
Bearer <API_KEY> - 说明:你的 Daya API Key
- Pay As You Go API Key:支持查询完整的计量和计费信息
- 订阅制 API Key(以
sk-ss-v1-开头):仅支持查询计量信息,不支持计费信息
generate_id string
查询参数:
Daya API 接口返回的 generation id,可以从以下接口获得:
- Create Chat Completion - OpenAI Chat Completions 协议
- Create a Model Response - OpenAI Responses 协议
- Create Messages - Anthropic 协议
- Generate Content - Vertex AI 协议
Returns
api string
API 类型,根据调用的协议不同,取值如下:
chat.completions- OpenAI Chat Completions 协议responses- OpenAI Responses 协议messages- Anthropic 协议generateContent- Vertex AI 协议
generationId string
当前的 generation id。
model string
模型 ID。
createAt string
服务端收到推理调用请求的时间。
generationTime integer
本次推理从首字到结束的持续时长,单位毫秒。
latency integer
首字延时,单位毫秒。
nativeTokens object
本次推理消耗的用量信息,包含以下字段:
completion_tokensinteger- 完成部分消耗的 token 数prompt_tokensinteger- 提示部分消耗的 token 数total_tokensinteger- 总 token 数completion_tokens_detailsobject- 完成 token 的详细信息reasoning_tokensinteger- 推理部分消耗的 token 数
prompt_tokens_detailsobject- 提示 token 的详细信息cached_tokensinteger- 缓存的 token 数
streamed boolean
是否是流式响应。
finishReason string
模型结束推理的原因。
usage number
本次推理消耗的 credit。
ratingResponses object
计费响应信息,包含以下字段:
billAmountnumber- 账单金额discountAmountnumber- 折扣金额originAmountnumber- 原始金额priceVersionstring- 价格版本ratingDetailsarray- 计费详情数组,每项包含:billAmountnumber- 账单金额discountAmountnumber- 折扣金额feeItemCodestring- 费用项目代码(如completion,prompt)originAmountnumber- 原始金额ratenumber- 费率
requestRetryTimes integer
请求重试次数。
finalRetry boolean
是否为最终重试
curl https://api.dayaai.com/api/v1/management/generation?id=<generation_id> \
-H "Authorization: Bearer $DAYA_API_KEY"{
"api": "chat.completions",
"generationId": "gen_01abc123def456",
"model": "openai/gpt-4o",
"createAt": "2026-03-26T06:00:00.000Z",
"generationTime": 3200,
"latency": 500,
"nativeTokens": {
"completion_tokens": 128,
"prompt_tokens": 32,
"total_tokens": 160,
"completion_tokens_details": {
"reasoning_tokens": 0
},
"prompt_tokens_details": {
"cached_tokens": 0
}
},
"streamed": true,
"finishReason": "stop",
"usage": 0.0052,
"ratingResponses": {
"billAmount": 0.0052,
"discountAmount": 0,
"originAmount": 0.0052,
"priceVersion": "v1",
"ratingDetails": [
{
"billAmount": 0.0016,
"discountAmount": 0,
"feeItemCode": "prompt",
"originAmount": 0.0016,
"rate": 0.00005
},
{
"billAmount": 0.0036,
"discountAmount": 0,
"feeItemCode": "completion",
"originAmount": 0.0036,
"rate": 0.00003
}
]
},
"requestRetryTimes": 0,
"finalRetry": false
}