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

# 快速入门

> 完成注册、创建 API 令牌、验证模型列表，并发送第一次 API 请求。

## 开始前

你需要一个 AIOHub 账号和可用余额。首次接入建议先用 OpenAI Chat Completions 完成验证，再按客户端切换到 OpenAI Responses、Claude Messages 或 Gemini API 格式。

## 四步发出第一次请求

<Steps>
  <Step title="注册并进入控制台">
    访问 [AIOHub 控制台](https://api.aiohub.org/console) 注册账号。登录后在 [钱包管理](https://api.aiohub.org/console/topup) 确认账户已有可用额度；需要充值时参考 [充值说明](/cn/account/recharge)。
  </Step>

  <Step title="创建 API 令牌">
    打开 [API 令牌管理](https://api.aiohub.org/console/token)，创建一个 `sk-` 开头的 API 令牌。为每个工具创建独立 API 令牌，便于按客户端查看用量日志并设置额度限制。

    <Warning>API 令牌是敏感调用凭证。不要发送给他人，也不要提交到 Git 仓库。</Warning>
  </Step>

  <Step title="确认可用模型">
    先请求模型列表，确认 API 令牌、余额和分组配置可用。

    ```bash theme={"system"}
    curl https://api.aiohub.org/v1/models \
      -H "Authorization: Bearer sk-你的API令牌"
    ```

    成功响应会返回当前 API 令牌的分组可访问的模型列表。
  </Step>

  <Step title="发送对话请求">
    使用 OpenAI Chat Completions 发送第一条对话请求。

    <CodeGroup>
      ```bash cURL theme={"system"}
      curl https://api.aiohub.org/v1/chat/completions \
        -H "Authorization: Bearer sk-你的API令牌" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "gpt-4o",
          "messages": [{"role": "user", "content": "Hello!"}]
        }'
      ```

      ```python Python theme={"system"}
      from openai import OpenAI

      client = OpenAI(
          base_url="https://api.aiohub.org/v1",
          api_key="sk-你的API令牌"
      )

      response = client.chat.completions.create(
          model="gpt-4o",
          messages=[{"role": "user", "content": "Hello!"}]
      )
      print(response.choices[0].message.content)
      ```

      ```javascript Node.js theme={"system"}
      import OpenAI from "openai";

      const client = new OpenAI({
        baseURL: "https://api.aiohub.org/v1",
        apiKey: "sk-你的API令牌",
      });

      const response = await client.chat.completions.create({
        model: "gpt-4o",
        messages: [{ role: "user", content: "Hello!" }],
      });
      console.log(response.choices[0].message.content);
      ```
    </CodeGroup>
  </Step>
</Steps>

## 选择 API 格式

| 场景                          | Base URL                        | 请求路径                                          |
| --------------------------- | ------------------------------- | --------------------------------------------- |
| OpenAI SDK / 通用工具           | `https://api.aiohub.org/v1`     | `POST /chat/completions`                      |
| Codex CLI                   | `https://api.aiohub.org/v1`     | `POST /responses`                             |
| Anthropic SDK / Claude Code | `https://api.aiohub.org`        | `POST /v1/messages`                           |
| Gemini CLI                  | `https://api.aiohub.org`        | `POST /v1beta/models/{model}:generateContent` |
| Gemini REST / Google SDK    | `https://api.aiohub.org/v1beta` | `POST /models/{model}:generateContent`        |

<Tip>不确定客户端需要哪个格式时，先查看对应的客户端指南；只写 API 代码时优先使用 OpenAI Chat Completions。</Tip>

## 下一步

<Columns cols={2}>
  <Card title="选择客户端" icon="plug" href="/cn/clients">
    将 AIOHub 接入 Claude Code、Codex CLI、Gemini CLI 或聊天客户端。
  </Card>

  <Card title="了解分组" icon="layers-3" href="/cn/account/groups">
    确认你的 API 令牌所属分组能访问目标模型。
  </Card>

  <Card title="查看 API 文档" icon="book-open" href="/cn/api/overview">
    查看鉴权方式、端点列表和 API Playground。
  </Card>

  <Card title="排查错误" icon="wrench" href="/cn/support/troubleshooting">
    处理鉴权失败、余额不足、网络连接和模型不可用。
  </Card>
</Columns>
