调用大模型服务
POST/v1/ai/:model/:path
当调用大模型时需要传递额外路径时,可追加 path
参数,如 v1/chat/completions
。具体路径定义参考各大模型文档。
流式输出 (server-sent events)
当启用流式输出时,应显式在请求头 Accept
中指定 text/event-stream
,否则请求将在 60 秒后超时。
Request
Path Parameters
model anyrequired
调用的模型代码,下列平台提供的模型组中的任意一个:
hunyuan-exp
: 混元体验版
deepseek
: 体验版
或填写在控制台上配置的其他自定义模型分组。
path stringrequired
对应大模型的调用路径,如 v1/chat/completions
- application/json
Body
required
请求参数参考各个大模型文档进行传递。
object
Responses
- 200
- 400
- 404
- default
调用大模型成功时返回(不一定返回正确结果)
Response Headers
X-Request-Id string
请求ID
- application/json
- text/event-stream
- Schema
- Example (from schema)
Schema
property name* any
{
"created": 1723618716,
"id": "xxx",
"model": "hunyuan",
"version": "202403121316",
"choices": [
{
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "我是一个由腾讯开发的人工智能助手,有什么我可以帮你的吗?"
}
}
],
"search_info": {
"mindmap": {}
},
"processes": {},
"usage": {
"prompt_tokens": 11,
"completion_tokens": 14,
"total_tokens": 25
}
}
- Schema
Schema
string
请求失败
Response Headers
X-Request-Id string
请求ID
- application/json
- Schema
- Example (from schema)
- AIModelConfigMissing
- AIModelParamInvalid
- AIModelRequestFailed
Schema
code string
错误码
message string
错误信息
requestId string
请求 ID
{
"code": "string",
"message": "string",
"requestId": "string"
}
缺少调用模型的必要配置,如 token, clientID 等(400)
{
"code": "AI_MODEL_CONFIG_MISSING",
"message": "xxx",
"requestId": "xxx"
}
调用模型的参数异常(400)
{
"code": "AI_MODEL_PARAM_INVALID",
"message": "xxx",
"requestId": "xxx"
}
请求模型失败(400)
{
"code": "AI_MODEL_REQUEST_FAILED",
"message": "xxx",
"requestId": "xxx"
}
请求失败
Response Headers
X-Request-Id string
请求ID
- application/json
- Schema
- Example (from schema)
- FeatureNotConfigured
- AIModelNotFound
Schema
code string
错误码
message string
错误信息
requestId string
请求 ID
{
"code": "string",
"message": "string",
"requestId": "string"
}
未启用大模型(404)
{
"code": "ENV_FEATURE_NOT_CONFIGURED",
"message": "xxx",
"requestId": "xxx"
}
未找到指定模型(404)
{
"code": "AI_MODEL_NOT_FOUND",
"message": "xxx",
"requestId": "xxx"
}
Response Headers
X-Request-Id string
请求ID
- application/json
- Schema
- Example (from schema)
- InvalidHost
Schema
code string
错误码
message string
错误信息
requestId string
请求 ID
{
"code": "string",
"message": "string",
"requestId": "string"
}
请求地址异常
{
"code": "INVALID_HOST",
"message": "xxx",
"requestId": "xxx"
}
Loading...