Empty or cut-off answers (finish_reason is length)
Causes and fixes when Echo Token Station's API returns HTTP 200 but the answer is empty or cut off. When finish_reason is length or stop_reason is max_tokens, the output has reached max_tokens. With models that reason, the reasoning also counts toward max_tokens.
The output reached max_tokens (the upper limit on output tokens) and the answer stopped partway. It is not an error and comes back with HTTP 200, so tell it apart by finish_reason (OpenAI format) or stop_reason (Anthropic format).
Example
This is the response when max_tokens: 5 was set for deepseek-v4.1-flash, a model that reasons (thinks before answering). All 5 tokens were used for reasoning, and the body of the answer is empty.
OpenAI format (/v1/chat/completions). content is empty, and reasoning_tokens in completion_tokens_details is 5:
{"choices":[{"finish_reason":"length","index":0,"message":{"content":"","reasoning_content":"We need answer in Japanese","role":"assistant"}}],"created":1795432196,"id":"279a8bbf-10e6-4280-a901-8c4590e33288","model":"deepseek-v4.1-flash","object":"chat.completion","usage":{"prompt_tokens":41,"completion_tokens":5,"total_tokens":46,"prompt_tokens_details":{"cached_tokens":0},"completion_tokens_details":{"reasoning_tokens":5}}}Anthropic format (/v1/messages). content holds only reasoning (thinking). We recorded only the beginning of the response (up to the middle of usage):
{"id":"69a3c691-38ce-4111-9286-08645fddc0dc","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"We need answer in Japanese"}],"stop_reason":"max_tokens","model":"deepseek-v4.1-flash","usage":{"input_tokens":41,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":5,"claude_cache_creation_5_m_tokens":0,"claude_cache_creation_1_h_tokens":0,"billing_usage":{"source":"oai_chat","semantic":"openai","openai_usage":{"prompt_tokens":41,"completion_tokens"Common causes
max_tokensis small: a long answer stops when it reaches the limit- With a model that reasons, the reasoning used up
max_tokens: reasoning also counts towardmax_tokens. In the example above, all 5 tokens went to reasoning and the body is empty - You call a Claude model in the OpenAI format (
/v1/chat/completions) withoutmax_tokens: in this case the answer stops at 8,192 tokens
How to fix
- Check whether the whole answer arrived. If
finish_reasonislengthorstop_reasonismax_tokens, it stopped at the limit. In the OpenAI format,finish_reasonisstopwhen the whole answer arrived - Increase
max_tokens. With models that reason, leave room for the reasoning too. The upper limit is the maximum output tokens on the model page
curl "https://token.echohub.io/v1/chat/completions" \
-H "Authorization: Bearer $ECHO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5-1",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "What is the capital of Japan?"}
]
}'- If you set
max_tokenstoo high, the estimated price can exceed your balance and you get 403 (403 insufficient_quota)
If a stream stops without finish_reason or stop_reason, it did not stop at the limit; it stopped because of an error from the upstream API or a cut connection ("When streaming stops partway" in Errors and fixes).
Related
- API reference: parameters such as
max_tokens, and what changes when the format is converted - Errors and fixes: how to tell when streaming stopped partway