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

1023 B
Raw Blame History

title, type, tags
title type tags
OpenAI-Compatible-API concept

Definition

OpenAI 兼容 API 是一种标准化的 AI 模型调用接口规范,遵循 OpenAI Chat Completions API 的请求/响应格式,使第三方 AI 系统能够被标准 AI 工具(如 n8n、LangChain无缝调用。

Key Properties

  • 请求格式:遵循 OpenAI chat/completions 规范
  • 模型指定:通过 model 字段指定具体的 Agentopenclaw:main
  • 认证方式Bearer TokenAuthorization: Bearer <token>
  • 端点:通常是 /v1/chat/completions

Example

OpenClaw Gateway 提供的 OpenAI 兼容端点:

  • URLhttp://<host>:18789/v1/chat/completions
  • Body
    {
      "model": "openclaw:main",
      "messages": [{"role": "user", "content": "..."}]
    }
    
  • OpenClaw 通过 gateway.http.endpoints.chatCompletions.enabled: true 提供此接口
  • HTTP-ChatCompletions 是其底层协议
  • n8n 通过 HTTP Request 节点调用此接口