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

# API 概览

> AIOAGI 提供 OpenAI 兼容 API，可通过统一端点访问多模型能力。

AIOAGI API 使用 Bearer Token 认证，并兼容 OpenAI SDK 的常见调用方式。多数场景只需要替换 `base_url`、`api_key` 和 `model`。

## 基础地址

<Table>
  <thead>
    <tr>
      <th>地址</th>
      <th>说明</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>[https://api.aiearth.dev/v1](https://api.aiearth.dev/v1)</code></td>
      <td>通用 OpenAI 兼容 API。</td>
    </tr>

    <tr>
      <td><code>[https://api.aiearth.vip/v1](https://api.aiearth.vip/v1)</code></td>
      <td>CDN 加速 API。</td>
    </tr>

    <tr>
      <td><code>[https://api-s1.aiearth.dev/v1](https://api-s1.aiearth.dev/v1)</code></td>
      <td>余额查询、实时语音等指定能力。</td>
    </tr>
  </tbody>
</Table>

## 认证

所有接口都需要在请求头中携带 API Key。

```http theme={null}
Authorization: Bearer sk-your-api-key
Content-Type: application/json
```

<Warning>
  API Key 只应保存在服务端。不要在前端页面、移动端包体或公开仓库中暴露密钥。
</Warning>

## 接口能力

<CardGroup cols={2}>
  <Card title="模型列表" icon="list">
    获取当前 Key 可访问的模型。
  </Card>

  <Card title="聊天补全" icon="messages">
    调用文本、多轮对话和推理模型。
  </Card>

  <Card title="图像生成" icon="image">
    调用图像生成和图像编辑接口。
  </Card>

  <Card title="文本向量" icon="chart-scatter">
    为 RAG、语义搜索和聚类生成向量。
  </Card>

  <Card title="语音合成" icon="waveform-lines">
    将文本转换为语音音频。
  </Card>
</CardGroup>

## 响应与错误

成功响应遵循 OpenAI 兼容结构。错误响应通常包含 `error.message`、`error.type` 和 `error.code`。

<AccordionGroup>
  <Accordion title="401 Unauthorized" icon="key">
    API Key 缺失、格式错误、已删除或没有当前接口权限。
  </Accordion>

  <Accordion title="400 Bad Request" icon="triangle-exclamation">
    请求体格式错误、模型名称不存在、参数超出范围或输入内容超限。
  </Accordion>

  <Accordion title="429 Rate Limit" icon="gauge-high">
    并发、频率或额度达到限制。请降低请求速率，或联系服务支持调整资源。
  </Accordion>
</AccordionGroup>
