Files
nexus/wiki/concepts/ChatCompletions.md
2026-05-03 05:42:12 +08:00

36 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "ChatCompletions"
type: concept
tags:
- "openai"
- "api"
- "chat"
sources: []
last_updated: 2026-04-20
---
## Overview
Chat Completions 是 OpenAI 标准的聊天补全 API 格式,通过 `POST /v1/chat/completions` 端点调用。Hermes Agent 的 API Server 默认使用此模式,无需额外配置。
## Key Characteristics
- **请求格式**`{"model": "...", "messages": [...]}`
- **响应格式**:返回 `choices[].message` 完整回复
- **历史管理**:每次请求携带完整对话历史
- **工具调用**:支持 `tools` / `tool_calls` 参数
- **流式输出**:支持 `stream: true`,实时推送 token
## vs Responses API
| 特性 | Chat Completions | Responses API |
|---|---|---|
| 状态管理 | 客户端携带历史 | 服务端 `previous_response_id` |
| 事件流 | 逐 token 块 | 结构化事件text_delta, function_call |
| 稳定性 | 稳定(默认) | 实验性 |
| 适用场景 | 通用对话 | 需要服务端状态追踪的场景 |
## See Also
- [[APIServer]]
- [[ResponsesAPI]]