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

969 B
Raw Blame History

title, type, tags
title type tags
HTTP-ChatCompletions concept

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}]
  • AuthorizationBearer Token 认证

与 WebSocket 的区别

  • HTTP同步请求-响应,适合 n8n 等工作流工具
  • WebSocket长连接双向通信适合实时对话界面