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

# 快速开始

> 获取 Relay Key，把 OpenAI SDK 指到 Auto Router，发出第一个请求。

最快的用法是把 OpenAI SDK 指到 Relay 的 `https://api.pipellm.ai/v1`。如果你已经在用 Anthropic 或 Gemini 客户端，后面再看其他协议即可。

<Steps>
  <Step title="创建 API Key">
    1. 登录 [console.pipellm.ai](https://console.pipellm.ai)
    2. 充值余额
    3. 创建 API Key

    在终端里导出：

    ```bash theme={"dark"}
    export PIPELLM_API_KEY="..."
    ```
  </Step>

  <Step title="安装 OpenAI SDK">
    <CodeGroup>
      ```bash Python theme={"dark"}
      pip install openai
      ```

      ```bash Node.js theme={"dark"}
      npm install openai
      ```
    </CodeGroup>
  </Step>

  <Step title="发送对话请求">
    把 `gpt-5` 换成 [`GET /v1/models`](/zh/api-reference/list-models) 里当前可用的模型 ID。

    <CodeGroup>
      ```python Python theme={"dark"}
      import os
      from openai import OpenAI

      client = OpenAI(
          api_key=os.environ["PIPELLM_API_KEY"],
          base_url="https://api.pipellm.ai/v1",
      )

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

      ```typescript TypeScript theme={"dark"}
      import OpenAI from "openai";

      const client = new OpenAI({
        apiKey: process.env.PIPELLM_API_KEY,
        baseURL: "https://api.pipellm.ai/v1",
      });

      const response = await client.chat.completions.create({
        model: "gpt-5",
        messages: [{ role: "user", content: "你好" }],
      });
      console.log(response.choices[0].message.content);
      ```

      ```bash cURL theme={"dark"}
      curl https://api.pipellm.ai/v1/chat/completions \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer $PIPELLM_API_KEY" \
        -d '{
          "model": "gpt-5",
          "messages": [{"role": "user", "content": "你好"}]
        }'
      ```
    </CodeGroup>
  </Step>
</Steps>

## 接下来

<Columns cols={2}>
  <Card title="流式输出" href="/zh/guides/streaming">
    边生成边接收 token。
  </Card>

  <Card title="图像" href="/zh/guides/images">
    生成和编辑图像。
  </Card>

  <Card title="视频" href="/zh/guides/video">
    创建异步视频任务并轮询直到完成。
  </Card>

  <Card title="API 参考" href="/zh/api-reference/introduction">
    端点路径、参数和响应结构。
  </Card>
</Columns>

## 其他协议

如果应用已经使用 Anthropic 或 Gemini SDK，保留原 SDK，只改 Base URL。需要 converter 路由时，见 [路由与协议](/zh/guides/routing-protocols)。

<AccordionGroup>
  <Accordion title="Anthropic SDK">
    ```python theme={"dark"}
    import anthropic

    client = anthropic.Anthropic(
        api_key="...",
        base_url="https://api.pipellm.ai",
    )

    message = client.messages.create(
        model="claude-sonnet-4-6",
        max_tokens=1024,
        messages=[{"role": "user", "content": "你好"}],
    )
    ```
  </Accordion>

  <Accordion title="Gemini SDK">
    ```python theme={"dark"}
    from google import genai

    client = genai.Client(
        api_key="...",
        http_options={"base_url": "https://api.pipellm.ai"},
    )

    response = client.models.generate_content(
        model="gemini-3-flash-preview",
        contents="你好",
    )
    ```
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.