调用大模型服务
POST/v1/ai/:model/:path
当调用大模型时需要传递额外路径时,可追加 path
参数,如 v1/chat/completions
。具体路径定义参考各大模型文档。
当前,腾讯混元(hunyuan
)的 path
参数可以为空,调用的接口需通过请求头X-Tc-Action
来传递。例如:X-Tc-Action: ChatCompletions
,各接口 action 参考 https://cloud.tencent.com/document/api/1729/101848 。
Request
Path Parameters
model ModelEnumrequired
Possible values: [hunyuan
]
调用的模型代码,下面中的一个
hunyuan
: 腾讯混元
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...