31 lines
1023 B
Markdown
31 lines
1023 B
Markdown
---
|
||
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 节点调用此接口
|