> ## 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.

# 对话补全

> 通过 PipeLLM 发送 Chat Completions 请求。

默认对话路径是 OpenAI Chat Completions：

```
POST https://api.pipellm.ai/v1/chat/completions
```

<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": "system", "content": "你是一个助手。"},
          {"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: "system", content: "你是一个助手。" },
      { 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": "system", "content": "你是一个助手。"},
        {"role": "user", "content": "用一句话解释速率限制。"}
      ]
    }'
  ```
</CodeGroup>

`model` 从 [`GET /v1/models`](/zh/api-reference/list-models) 选取。原生 `/v1/chat/completions` 只会路由到 OpenAI 兼容平台。要保留这个请求格式去调用 Claude 或 Gemini，使用 [OpenAI converter](/zh/converter/openai-format)。

## 相关文档

<Columns cols={2}>
  <Card title="流式输出" href="/zh/guides/streaming">
    设置 `stream: true`，读取 SSE 分片。
  </Card>

  <Card title="Chat Completions API" href="/zh/api-reference/openai/chat-completions">
    参数、Function Calling 和响应字段。
  </Card>

  <Card title="Responses API" href="/zh/api-reference/openai/responses">
    PipeLLM 上的 OpenAI Responses。
  </Card>

  <Card title="路由" href="/zh/guides/routing-protocols">
    原生路由和 converter 路由。
  </Card>
</Columns>


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