> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openp.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# API 概览

> OpenPAI 三套协议端点的入口

OpenPAI 同时暴露三套协议端点,你可以按现有代码或上游模型自由选择。

## 端点速查

| 协议              | Base URL                                     | 鉴权头                                       | 适合                                    |
| --------------- | -------------------------------------------- | ----------------------------------------- | ------------------------------------- |
| OpenAI 兼容       | `https://openp.ai/v1`                        | `Authorization: Bearer sk-...`            | 已有 OpenAI SDK 代码 / 大部分模型              |
| Claude Messages | `https://openp.ai/v1/messages`               | `x-api-key: sk-...` + `anthropic-version` | Claude thinking / cache\_control 高级特性 |
| Gemini 原生       | `https://openp.ai/v1beta/models/{model}:...` | `x-goog-api-key: sk-...`                  | Gemini 多模态、function\_declarations     |

> 同一把 `sk-` 密钥可同时使用三套端点,共享账户额度。

## 接口分类

<CardGroup cols={2}>
  <Card title="OpenAI 兼容" icon="o" href="/api-reference/openai/chat-completions">
    `/v1/chat/completions`、`/v1/embeddings`、`/v1/images/*`、`/v1/audio/*`、`/v1/responses`、`/v1/realtime`
  </Card>

  <Card title="Claude Messages" icon="a" href="/api-reference/anthropic/messages">
    `/v1/messages`、`/v1/messages/count_tokens`
  </Card>

  <Card title="Gemini 原生" icon="g" href="/api-reference/gemini/generate-content">
    `:generateContent`、`:streamGenerateContent`、`:embedContent`
  </Card>

  <Card title="Rerank" icon="arrow-up-9-1" href="/api-reference/rerank/create-rerank">
    `/v1/rerank` —— Cohere / Jina 兼容
  </Card>

  <Card title="Midjourney" icon="paintbrush" href="/api-reference/midjourney/imagine">
    `/mj/submit/*`、`/mj/task/{id}/fetch`
  </Card>

  <Card title="Suno" icon="music" href="/api-reference/suno/generate">
    `/suno/submit/music`、`/suno/fetch/{id}`
  </Card>
</CardGroup>

## 通用约定

* **协议**:HTTPS,推荐 HTTP/2(`curl --http2`)。
* **编码**:`Content-Type: application/json; charset=utf-8`。
* **超时**:服务端默认 600 秒。流式响应可保持长连接,空闲心跳每 15 秒。
* **请求体大小**:默认上限 32 MB(压缩后)。
* **响应头**:
  * `X-OpenPAI-Request-Id`:本次请求 ID,工单沟通时附上可加速排查。
  * `X-OpenPAI-Group`:本次走的用户分组。
  * `X-OpenPAI-Quota-Consumed`:本次扣费金额。
  * `X-OpenPAI-Remaining-Quota`:扣费后账户剩余额度。

## 下一步

<CardGroup cols={2}>
  <Card title="鉴权" icon="key" href="/api-reference/authentication">
    三套协议的鉴权头格式与示例。
  </Card>

  <Card title="错误码" icon="circle-exclamation" href="/api-reference/errors">
    HTTP 状态、错误结构与排查建议。
  </Card>

  <Card title="限流" icon="gauge-high" href="/api-reference/rate-limits">
    RPM / TPM 限制与 429 处理。
  </Card>
</CardGroup>
