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

31 lines
1023 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: "OpenAI-Compatible-API"
type: concept
tags: []
---
## Definition
OpenAI 兼容 API 是一种标准化的 AI 模型调用接口规范,遵循 OpenAI Chat Completions API 的请求/响应格式,使第三方 AI 系统能够被标准 AI 工具(如 n8n、LangChain无缝调用。
## Key Properties
- **请求格式**:遵循 OpenAI `chat/completions` 规范
- **模型指定**:通过 `model` 字段指定具体的 Agent`openclaw:main`
- **认证方式**Bearer Token`Authorization: Bearer <token>`
- **端点**:通常是 `/v1/chat/completions`
## Example
OpenClaw Gateway 提供的 OpenAI 兼容端点:
- **URL**`http://<host>:18789/v1/chat/completions`
- **Body**
```json
{
"model": "openclaw:main",
"messages": [{"role": "user", "content": "..."}]
}
```
## Related
- [[OpenClaw]] 通过 `gateway.http.endpoints.chatCompletions.enabled: true` 提供此接口
- [[HTTP-ChatCompletions]] 是其底层协议
- [[n8n]] 通过 HTTP Request 节点调用此接口