对话补全
curl --request POST \
--url https://api.hubto.ai/v1/chat/completions \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
]
}
'import requests
url = "https://api.hubto.ai/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}]
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', messages: [{}]})
};
fetch('https://api.hubto.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": "<string>",
"choices": [
{}
],
"usage": {}
}接口示例
对话补全
OpenAI 兼容聊天补全接口。
POST
/
v1
/
chat
/
completions
对话补全
curl --request POST \
--url https://api.hubto.ai/v1/chat/completions \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{}
]
}
'import requests
url = "https://api.hubto.ai/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}]
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', messages: [{}]})
};
fetch('https://api.hubto.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": "<string>",
"choices": [
{}
],
"usage": {}
}用途
用于发送多轮对话请求,生成文本回复。请求头
string
默认值:"Bearer YOUR_API_KEY"
必填
Bearer 鉴权请求头,格式为
Bearer YOUR_API_KEY。请求体
string
默认值:"glm-5.1"
必填
模型名称,例如
gpt-5.4。object[]
必填
对话消息数组,至少包含一条用户消息。
number
默认值:"0.7"
可选,控制生成随机性。
boolean
默认值:"false"
可选,是否启用流式返回。
integer
默认值:"512"
可选,限制本次生成的最大输出 token 数。
示例请求体
{
"model": "gpt-5.4",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下 HubTo。"
}
],
"temperature": 0.7
}
响应
string
请求 ID。
object[]
生成结果数组,内容通常位于
choices[0].message.content。object
Token 使用统计。