跳到主要内容

API 总览

187API 对外暴露三套协议,互不干扰。挑一套用即可。

协议与路径​

协议路径前缀主要端点鉴权头
OpenAI 兼容/v1/chat/completions、/completions、/embeddings、/responsesAuthorization: Bearer ***
Anthropic/v1/messagesx-api-key + anthropic-version
Gemini/v1beta/models/{model}:{action}x-goog-api-key 或 ?key=

同一把 key 三套都能用。

已实现的端点​

OpenAI 兼容​

方法路径说明
POST/v1/chat/completions对话补全(含流式)
POST/v1/completions文本补全(旧接口,仍可用)
POST/v1/embeddings向量化
POST/v1/responsesResponses API(另有 GET 走 WebSocket)
POST/v1/responses/compactResponses 压缩
POST/v1/moderations内容审核
POST/v1/rerank重排序
POST/v1/audio/speech语音合成
POST/v1/audio/transcriptions语音转文字
POST/v1/audio/translations语音翻译
POST/v1/images/edits图像编辑
POST/v1/alpha/search独立搜索(Codex 场景)
POST/v1/tools/search工具搜索(DeepSeek 协议)
POST/v1/tools/fetch工具抓取(DeepSeek 协议)
GET/v1/realtime实时 WebSocket
GET/v1/models模型列表
GET/v1/models/{model}单个模型信息

Anthropic​

方法路径说明
POST/v1/messages消息补全(含流式)

Gemini​

方法路径说明
POST/v1beta/models/{model}:generateContent生成
POST/v1beta/models/{model}:streamGenerateContent流式生成

未实现(会明确返回错误)​

以下端点不提供,请求会得到错误响应,而不是静默降级:

POST /v1/images/variations
GET /v1/files
POST /v1/files
GET /v1/files/{id}
GET /v1/files/{id}/content
DELETE /v1/files/{id}
POST /v1/fine-tunes
GET /v1/fine-tunes
GET /v1/fine-tunes/{id}
POST /v1/fine-tunes/{id}/cancel
GET /v1/fine-tunes/{id}/events
DELETE /v1/models/{model}
POST /v1beta/models/{model}:countTokens

:::warning 别在客户端静默吞掉这些错误 countTokens 请求会返回 404,不是"返回 0"。如果你的 SDK 依赖它做 上下文预算,需要自己实现本地估算。 :::

通用请求头​

头值说明
Content-Typeapplication/json必须
AuthorizationBearer <key>OpenAI 协议
x-api-key<key>Anthropic
anthropic-version2023-06-01Anthropic 必须
Accepttext/event-stream流式时可选

响应格式​

OpenAI 协议走标准 OpenAPI 结构;Anthropic 走 content 块数组;出错时统一是:

{
"error": {
"code": "...",
"message": "... (request id: xxx)",
"type": "new_api_error"
}
}

message 末尾的 request id 排障时请一并提供。