Chat 对话补全
POST /api/v1/chat/completions请求参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| model | string | 是 | - | 模型 ID |
| messages | array | 是 | - | 对话消息列表 |
| messages[].role | string | 是 | - | 消息角色:system / user / assistant |
| messages[].content | string | 是 | - | 消息内容 |
| stream | boolean | 否 | true | 是否流式返回 |
请求示例
bash
Javascript
Python
Java
Go
curl -X POST "https://ai.clouddun.com/api/v1/chat/completions" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "bytedance/doubao-seed-2-1-pro-260628",
"messages": [
{
"role": "user",
"content": "你可以做什么?"
}
]
}'响应参数
| 参数 | 类型 | 说明 |
|---|---|---|
| id | string | 本次请求的唯一标识 |
| object | string | 固定为 chat.completion |
| created | integer | 创建时间(Unix 时间戳) |
| model | string | 实际处理的模型 ID |
| choices | array | 候选回复列表 |
| choices[].message | object | 回复消息(role + content) |
| usage | object | token 用量统计 |
| usage.total_tokens | integer | 总 token 数 |