> ## 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 是 PipeLLM 的 Auto Router：用一个兼容 endpoint 接入已批准的模型。

Relay 是 PipeLLM 的 Auto Router。保留现有的 OpenAI、Anthropic 或 Gemini SDK。Relay 负责鉴权、执行策略，并按协议、供应商健康状态和成本选择已批准的路由。

默认路径是 OpenAI 兼容：把 OpenAI SDK 的 Base URL 改成 `https://api.pipellm.ai/v1`，就可以发请求。

<CodeGroup>
  ```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": "你好"}]
    }'
  ```

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

  client = OpenAI(
      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);
  ```
</CodeGroup>

<Tip>
  在 [控制台](https://console.pipellm.ai) 创建 Relay API Key。模型 ID 会随目录更新，请用 [`GET /v1/models`](/zh/api-reference/list-models) 查看当前账号可用的模型。
</Tip>

## 接下来

<Columns cols={2}>
  <Card title="快速开始" icon="play" href="/zh/quickstart">
    获取 Key、安装 SDK，发出第一个请求。
  </Card>

  <Card title="路由与协议" icon="route" href="/zh/guides/routing-protocols">
    原生路由、converter 路由，以及 Relay 何时切换协议。
  </Card>

  <Card title="认证" icon="key" href="/zh/authentication">
    API Key、请求头和 Base URL。
  </Card>

  <Card title="模型" icon="layer-group" href="/zh/models">
    如何列出模型并选择 ID。
  </Card>
</Columns>


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