查询前缀缓存
更新时间:2025-11-07
GET
https://qianfan.baidubce.com/v2/caching/{cache_id}
查询上下文缓存
权限说明
调用本文API,需使用API Key鉴权方式。使用API Key鉴权调用API流程,具体调用流程,请查看 认证鉴权。
请求参数
Headers 参数
除公共头域外,无其它特殊头域
URL 参数
cache_id
string
此次请求查询的缓存id
必选
请求结构
GET /v2/caching/{cache_id} HTTP/1.1
Host: qianfan.baidubce.com
Authorization: Bearer <API Key>
Content-Type: application/json
示例代码
Shell
curl --location 'https://qianfan.baidubce.com/v2/caching/{cache_id}' \
--header 'Authorization: Bearer bce-v3/ALTAK-*********/614fb**********' \
--header 'Content-Type: application/json' \
返回响应
Headers 参数
除公共头域外,无其它特殊头域
返回参数
id
string
本次请求的cache ID。
必选
model
string
本次请求使用的大模型ID。
必选
mode
string
本次请求创建的上下文缓存的类型。
必选
ttl
integer
本次请求创建的上下文缓存过期时长(单位:秒)。
必选
usage
object {3}
token统计信息。
必选
显示子属性
隐藏子属性
prompt_tokens
integer
输入的 prompt token 数量。
必选
completion_tokens
integer
模型生成的 token 数量。
必选
total_tokens
integer
本次请求消耗的总 token 数量,包括输入和输出的数量。
必选
expire_at
integer
缓存最后一次使用时间,Unix 时间戳,未使用过时为null(单位:秒)。
必选
JSON
{
"id": "cache-20251106141838-0gf3xx5179",
"model": "deepseek-v3.1-think-250821",
"mode": "common_prefix",
"ttl": 3600,
"usage": {
"prompt_tokens": 70,
"completion_tokens": 0,
"total_tokens": 70
},
"expire_at": 1762413518
}
JSON
{
"error": {
"code": "invalid_id",
"message": "id cache-20251106141838-0gf3xx51 not found",
"type": "invalid_request_error"
},
"id": "as-suxgjt86we"
}
错误码
如果请求错误,服务器返回的JSON文本包含以下参数。
| 名称 | 描述 |
|---|---|
| code | 错误码 |
| message | 错误描述信息,帮助理解和解决发生的错误 |
| type | 错误类型 |
更多相关错误码,请查看模型错误码说明。
