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

45 lines
969 B
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: "HTTP-ChatCompletions"
type: concept
tags: []
---
## Definition
HTTP-ChatCompletions 是通过 HTTP 协议调用 AI 模型 Chat Completions 接口的模式,是 [[OpenAI-Compatible-API]] 的底层传输机制。
## Architecture
```
Client (n8n HTTP Request)
POST /v1/chat/completions
Content-Type: application/json
Authorization: Bearer <token>
{
"model": "openclaw:main",
"messages": [...]
}
AI Gateway (OpenClaw Gateway)
Agent Response
```
## Key Fields
- `model`:指定要调用的 Agent ID
- `messages`:对话历史,格式为 `[{role, content}]`
- `Authorization`Bearer Token 认证
## 与 WebSocket 的区别
- HTTP同步请求-响应,适合 n8n 等工作流工具
- WebSocket长连接双向通信适合实时对话界面
## Related
- [[OpenAI-Compatible-API]] 依赖此机制
- [[OpenClaw]] Gateway 提供此端点
- [[n8n]] 通过 HTTP Request 节点调用