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

# 创建 Chat Completion

> 根据输入的对话消息生成模型回复。

**流式输出**：设置 `stream: true` 后，接口以 SSE（Server-Sent Events）逐块返回结果，每个数据块是一行 `data:`。除第一个数据块（只包含 `role`）和带 `finish_reason` 的数据块外，每个数据块都带有 `usage` 字段。流的最后一行是 `data: [DONE]`，表示输出结束；在它之前的最后一个数据块 `choices` 为空数组，`usage` 是整个请求的总用量。

**采样参数**：各参数的可用范围取决于具体模型。下方 schema 标注的是 OpenAI 协议允许的范围，不代表每个模型都支持。

**重试**：遇到 429 或 5xx 错误时，请使用指数退避（加随机抖动）重试。等待时间优先采用响应头给出的值：先看 `retry-after-ms`，再看 `retry-after`。400、401、402、404 错误不要重试，响应头 `x-should-retry` 为 `false` 时也不要重试。这类错误需要先修改请求或处理账户问题，直接重试只会得到相同的结果。

**429 错误**：表示你的某一项每分钟配额已用完。三项配额的含义以及相关响应头的读法，请参阅[速率限制](/zh/rate-limits)。




## API Specification

The full API specification for this endpoint is available in the [documentation index](https://docs.lithosai.com/llms.txt).


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