Chat Completions
POST
/v1/chat/completions核心接口,兼容 OpenAI Chat Completions API。支持多轮对话、流式输出、Function Calling。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 必填 | 模型名称,如 gpt-4o、glm-4.7-flash |
| messages | array | 必填 | 消息列表,每项含 role 和 content |
| stream | boolean | 可选 | 是否流式输出,默认 false |
| temperature | number | 可选 | 采样温度 0-2,越高越随机,默认 1 |
| max_tokens | integer | 可选 | 最大生成 token 数 |
| top_p | number | 可选 | 核采样概率,默认 1 |
| stop | array | 可选 | 停止生成的字符串列表 |
messages 字段说明
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| role | string | 必填 | system / user / assistant |
| content | string | 必填 | 消息内容 |
| name | string | 可选 | 发送者名称 |
| tool_calls | array | 可选 | 工具调用(assistant 角色) |