탐색으로 건너뛰기

Why do long roleplay replies time out or cut off mid-sentence?

Markdown으로 보기

A roleplay reply that stops mid-sentence comes from one of two causes: a network timeout (the connection closed before the model finished) or an output token cap (the model reached max_tokens and stopped). Identifying which cause occurred points directly to the right setting.

1. Fix network timeouts, Failed to fetch, and No response from bot

When a client displays a timeout, 502/504, A network error occurred / Failed to fetch (unk), PROXY ERROR: No response from bot, or an empty bubble after waiting over a minute, the connection dropped before completion.

  • Use https://direct.beatapi.io/v1 for text chat: https://api.beatapi.io runs behind Cloudflare and inherits Cloudflare’s 100-second wait limit on non-streaming responses. https://direct.beatapi.io/v1 uses the same key, models, and prices without the 100-second ceiling.
  • Use https://api-asia.beatapi.io/v1 in East and Southeast Asia: If direct.beatapi.io drops packets on mobile or residential networks in Asia, switch to https://api-asia.beatapi.io/v1, which also bypasses the 100-second limit.
  • Enable streaming (stream: true): Streaming sends tokens over server-sent events as soon as generation starts, keeping the HTTP connection active during long story turns.

2. Fix max_tokens truncation

When the reply ends cleanly mid-sentence with no network error and the raw response reports finish_reason: "length" (or stop_reason: "max_tokens" on Claude), the model hit your configured output cap.

  • Set max_tokens to 2000–4096 for standard roleplay dialogue.
  • Set max_tokens to 4096–8192 for reasoning models: Reasoning tokens count toward max_tokens. Even hy4-flash-free spends roughly 230 reasoning tokens on a one-sentence reply, so reasoning models need max_tokens of at least 2000.
  • Keep max_tokens below 32000 on small balances: Oversized caps can trigger 402 insufficient_credits during BeatAPI’s balance pre-check; see 402 error from oversized max_tokens.