获取模型列表
权限说明
调用本文API,需使用API Key鉴权方式。使用API Key鉴权调用API流程,具体调用流程,请查看认证鉴权。
请求参数
GET /v2/models HTTP/1.1
Host: qianfan.baidubce.com
Authorization: Bearer <API Key>
示例代码
curl https://qianfan.baidubce.com/v2/models \
-H "Authorization: Bearer <API Key>" \
-H "Content-Type: application/json" \
import requests
import json
def main():
url = "https://qianfan.baidubce.com/v2/models"
payload = json.dumps({
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer bce-v3/ALTAK-*********/614fb**********'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
if __name__ == '__main__':
main()
返回响应
固定值为list
显示子属性
隐藏子属性
显示子属性
隐藏子属性
模型标识符,值为模型对应的model值
对象类型,固定值为model
拥有该模型的组织,例如 Baidu、Meta、DeepSeek 等
模型上线时间,Unix timestamp(秒)
模型类型,例如 chat、text2image、image2image、text2video、embeddings、rerank 等
多选一且必需"只能"符合其中一个
模型支持的最大上下文长度(token),含输入、输出及思维链
显示子属性
隐藏子属性
多选一且必需"只能"符合其中一个
可指定的模型最大思考+输出 token 数
显示子属性
隐藏子属性
多选一且必需"只能"符合其中一个
可指定的模型最大输出 token 数
显示子属性
隐藏子属性
多选一且必需"只能"符合其中一个
可指定的模型最大输入 token 数
显示子属性
隐藏子属性
模型输入输出模态信息
显示子属性
隐藏子属性
输入输出模态组合的简洁描述,例如 text+image->text、text->image、text->embedding 等
输入模态列表,例如["text"], ["image"], ["video"]等
显示子属性
隐藏子属性
输出模态列表,例如 ["text"]、["image"]、["embedding"]等
显示子属性
隐藏子属性
模型计费信息
显示子属性
隐藏子属性
多选一且必需"只能"符合其中一个
输入 tokens 单价,文本模型适用;固定价格为 string,分段计价为 array
显示子属性
隐藏子属性
固定价格,单位:元/千tokens
分段计价列表
显示子属性
隐藏子属性
显示子属性
隐藏子属性
多选一且必需"只能"符合其中一个
该分段的千tokens上限,null 表示无上限
显示子属性
隐藏子属性
该分段的单价,单位:元/千tokens
多选一且必需"只能"符合其中一个
输出 tokens 单价,格式同 prompt
显示子属性
隐藏子属性
固定价格,单位:元/千tokens
分段计价列表
显示子属性
隐藏子属性
显示子属性
隐藏子属性
多选一且必需"只能"符合其中一个
该分段的千tokens上限
显示子属性
隐藏子属性
该分段的单价,单位:元/千tokens
多选一且必需"只能"符合其中一个
输出图片单价,单位:元/张,仅图像生成/编辑模型适用
显示子属性
隐藏子属性
多选一且必需"只能"符合其中一个
输出视频单价,单位:元/秒,仅视频生成模型适用
显示子属性
隐藏子属性
多选一且必需"只能"符合其中一个
联网搜索增强单价,单位:元/次,仅支持 web_search 的模型适用
显示子属性
隐藏子属性
缓存命中价格,单位:元/千 tokens
模型展示名称
模型描述
模型状态:active 活跃、new 发布 14 天内、soon_offline 距下线 30 天内(即将下线)、offline 已下线
支持的能力标签(仅支持项出现):web_search 联网搜索、function_call 工具调用、structured_output 结构化输出、prompt_caching 前缀读写(缓存)、fim_completion FIM 补全
下线/预计下线时间,null 表示无下线计划
每分钟 token 限额(当前登录主账号维度),null 表示未配置
每分钟请求限额(当前登录主账号维度),null 表示未配置
支持的调用协议路径:/v2/chat/completions、/v2/responses、/anthropic/v1/messages
{
"object": "list",
"data": [
{
"id": "deepseek-v3.2",
"object": "model",
"owned_by": "DeepSeek",
"model_name": "DeepSeek-V3.2",
"model_description": "DeepSeek 通用对话模型",
"status": "active",
"features": ["function_call", "structured_output", "prompt_caching", "fim_completion"],
"created": 1717000000,
"shutdown_time": null,
"type": "chat",
"context_length": 131072,
"max_completions_tokens": 8192,
"max_tokens": 4096,
"prompt_tokens": 126976,
"tpm": 50000,
"rpm": 165,
"architecture": {
"modality": "text->text",
"input_modalities": ["text"],
"output_modalities": ["text"]
},
"pricing": {
"prompt": "0.002",
"completion": "0.008",
"cache": "0.0005"
},
"endpoints": ["/v2/chat/completions", "/v2/responses", "/anthropic/v1/messages"]
}
]
}
请求异常码
| 异常码 (code) | HTTP 状态码 | 说明 |
|---|---|---|
| InternalError | 500 | 本接口唯一对外异常码。/v2/models 无请求参数,出错均归为系统内部错误,涵盖:carrier-api→carrier 的 RAL 调用失败或 result 反序列化失败;carrier 侧查询预置模型/版本列表失败、批量询价失败、价格查询异常;调用 Compass Console 预置服务管理列表(tpm/rpm/下线时间)失败。对应 carrier 系统错误码 COMMON(11000),经 NewCarrierError 归一为 InternalError |
错误返回结构
与成功时的透传不同,出错时 handler 使用 BuildResponse 返回标准错误包装:带 requestId 外层、无 result 字段。/v2/models 无请求参数,出错均为系统内部错误,HTTP 状态码为 500。结构如下:
| 字段 | 类型 | 说明 |
|---|---|---|
| requestId | string | 请求追踪 ID |
| code | string | 错误码,如 InternalError;下游 carrier/compass 错误按映射透传对应错误码 |
| message | string | 错误描述信息 |
错误返回示例:
{
"requestId": "2744981776",
"code": "InternalError",
"message": "We encountered an internal error. Please try again."
}
评价此篇文章
