> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# 角色扮演长回复超时、断联或写到一半被截断怎么办？

> 区分 Cloudflare 100 秒超时、Failed to fetch / No response from bot 断流与 max_tokens 上限截断，用 BeatAPI 直连/亚洲域名、流式输出与合理回复长度逐项解决。

角色扮演回复写到一半停住，原因分两类：**网络超时断联**（模型未写完，连接先断开）和 **输出上限截断**（模型写到 `max_tokens` 上限后正常停止）。先确认属于哪一类，再改对应配置。

## 一、解决网络超时、`Failed to fetch` 与 `No response from bot`

客户端等待一分钟以上后出现超时、`502`/`504`、`Failed to fetch (unk)`、`PROXY ERROR: No response from bot` 或空白气泡，属于连接在回复完成前中断：

* **文本对话避开 `api.beatapi.io`**：`https://api.beatapi.io` 经过 Cloudflare，非流式请求等待超过 100 秒会被断开。改用 `https://direct.beatapi.io/v1`，密钥、模型与价格不变，且不受 100 秒限制。
* **亚洲网络优先使用 `api-asia.beatapi.io`**：从中国大陆、日韩或东南亚的移动或宽带网络访问 `direct.beatapi.io` 仍掉线时，改用 `https://api-asia.beatapi.io/v1`。`api-asia.beatapi.io` 同样不受 100 秒限制。
* **开启流式输出（Streaming）**：流式模式下模型生成首批 token 即通过 SSE 持续下发，既能维持长回复连接，也支持剧情跑偏时随时中止。

## 二、解决 `max_tokens` 输出截断

没有网络报错、文字停在半句话处，且客户端日志显示 `finish_reason: "length"`（Claude 显示 `stop_reason: "max_tokens"`）时，说明输出撞到了最大回复长度上限：

* **日常对话将 `max_tokens` 设为 `2000`–`4096`**。
* **推理模型将 `max_tokens` 设为 `4096`–`8192`**：带思考过程的模型会把思考 token 计入 `max_tokens`。例如 `hy4-flash-free` 一句短回复也会消耗约 230 个思考 token，至少需要设为 `2000` 以上。
* **小余额账户不要把 `max_tokens` 设为 `32000` 以上**：过大的上限会让 BeatAPI 余额预检返回 `402 insufficient_credits`，见[max_tokens 过大触发 402](/zh/faq/roleplay-max-tokens-402)。

## 相关文档

* [长文本请求超时排查](/zh/faq/model-text-timeout)
* [推理模型思维链截断与复读](/zh/faq/roleplay-thinking-tags-cutoff)
* [返回 AI 模型常见问题](/zh/faq/models)