对话与响应
创建对话补全
根据对话消息生成模型响应。兼容模型支持流式输出与工具调用。
POST
/v1/chat/completions请求参数
| 参数 | 类型 / 位置 | 说明 |
|---|---|---|
model必填 | stringbody | 模型页面中的准确模型 ID。 |
messages必填 | arraybody | 按时间顺序排列的对话消息。 |
max_completion_tokens可选 | integerbody | 允许生成的最大 Token 数。 |
reasoning_effort可选 | stringbody | 支持推理的模型所使用的推理强度。 noneminimallowmediumhighxhighmax |
temperature可选 | numberbody | 采样温度,具体支持情况取决于模型。 |
stream可选 | booleanbody | 设为 true 时通过 Server-Sent Events 返回结果。 |
tools可选 | arraybody | 提供给模型调用的工具或函数。 |
请求示例
cURL
curl --request POST \
--url 'https://api.juhenextvip.com/v1/chat/completions' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.6-luna",
"messages": [
{
"role": "developer",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'响应示例
JSON
{
"id": "chatcmpl_...",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 9,
"total_tokens": 33
}
}调用注意事项
- 流式调用时将 stream 设为 true,并持续读取事件直至 [DONE]。