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

# 创建对话

> POST /v1/chat/completions 的基础请求与响应。

## 请求地址

`POST https://token.poryf.com/v1/chat/completions`

请求头按 [接入配置](/connection) 设置。

## 常用字段

| 字段                   | 类型      | 说明                                    |
| -------------------- | ------- | ------------------------------------- |
| `model`              | string  | 必填，精确模型 ID                            |
| `messages`           | array   | 必填，对话消息列表                             |
| `messages[].role`    | string  | 基础对话使用 `user`、`assistant`；其他角色支持取决于模型 |
| `messages[].content` | string  | 本示例使用纯文本内容                            |
| `stream`             | boolean | 可选，设为 `true` 请求流式输出                   |

```json theme={null}
{
  "model": "YOUR_MODEL_ID",
  "messages": [{ "role": "user", "content": "你好" }],
  "stream": false
}
```

## 读取响应

* `choices[0].message.content`：模型回答。
* `choices[0].finish_reason`：本次生成结束的原因。
* `usage`：上游返回的用量信息（若提供）；实际扣费查看控制台使用日志。

## 连续对话

在后续请求的 `messages` 中附上需要保留的历史消息。接口不会因为复用同一密钥而自动记住上一次对话。历史消息会占用上下文，并可能增加输入用量。

<Note>温度、输出长度、推理强度、工具调用等高级参数的支持和限制因模型而异。先用最小请求跑通，再按对应模型能力逐项添加。</Note>

完整可执行示例见 [快速开始](/quickstart) 和 [SDK](/sdk)。
