Chat Completions
发送对话消息,读取回复与用量;可选能力按具体模型配置核对。
接口与认证
POST https://uouo.cloud/v1/chat/completions
使用 UOUO API Key 发送 Bearer 认证。先在 Models 确认该模型和档位支持 Chat Completions。
请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 所选配置的精确请求 ID。 |
| messages | array | 是 | 按顺序传入对话消息。 |
| stream | boolean | 否 | 请求 SSE 流式输出。 |
| max_completion_tokens | integer | 否 | 生成 Token 上限,按模型兼容性使用。 |
| max_tokens | integer | 否 | 部分兼容模型使用的输出上限字段。 |
| temperature / top_p | number | 否 | 采样参数;取值及支持情况因模型而异。 |
| tools / tool_choice | array / string or object | 否 | 工具定义与选择方式。 |
| response_format | object | 否 | 结构化输出约束,需要模型与档位支持。 |
最小请求
按 快速开始 设置环境变量,替换 YOUR_MODEL_ID。
curl https://uouo.cloud/v1/chat/completions \
-H "Authorization: Bearer $UOUO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_MODEL_ID","messages":[{"role":"user","content":"Hello"}]}'Windows 的 PowerShell / CMD 命令见 快速开始。
返回结构
| 字段 | 用途 |
|---|---|
| id | 响应标识,可在排查时保存。 |
| model | 返回的模型标识。 |
| choices | 候选回复数组。 |
| choices[0].message.content | 普通文本回复。 |
| choices[0].message.tool_calls | 模型请求的工具调用;需要应用执行后回传结果。 |
| usage | 可用的输入、输出与总 Token 统计。 |
下面仅展示普通文本回复结构:
{ "choices": [{ "message": { "role": "assistant", "content": "Hello!" } }] }流式输出
设置 stream: true 后,按 Chat Completions 的 SSE 格式读取 choices[].delta,并处理正常结束与连接中断。参阅 流式输出。
常见错误
401 检查凭据;403 核对权限;404 区分路径和模型;429 查看速率、额度或容量错误;5xx 保留请求标识并检查 服务状态。详见 错误与排查。