Short answer
Whendeepseek-v4.1-flash uses reasoning.effort = "medium" for batch summarization or structured screening through /v1/responses, hidden reasoning tokens can far exceed the final JSON output. A non-streaming call returns only after both reasoning and visible output finish, so even a short JSON response can hit a 60-second client timeout.
Check usage.output_tokens_details.reasoning_tokens first. If reasoning accounts for most output tokens, try low, or none when quality permits, and combine that with streaming and a sufficient overall timeout. Do not rely solely on shortening the JSON or retrying immediately.
An anonymized production example
A batch literature-screening workload submitted about 20 abstracts per request and asked for a JSON array containing one decision per paper. Its request shape was:- Model:
deepseek-v4.1-flash; - Endpoint:
POST /v1/responses; - Parameter:
reasoning.effort = "medium"; - Non-streaming response with a 60-second overall client timeout.
output_tokens includes both reasoning tokens and final output. Do not estimate latency or cost from visible text alone. OpenAI uses the same accounting in its general guidance for reasoning models on Responses: developers.openai.com/api/docs/guides/reasoning.Confirm the issue in three steps
Step 1: compare total output and reasoning tokens
Step 2: check whether the output cap truncated the response
max_output_tokens also includes reasoning tokens. If the response has status = "incomplete" and incomplete_details.reason = "max_output_tokens", the budget may have been exhausted during reasoning, leaving partial or even empty visible output.Step 3: compare the client timeout with server-side completion
Recommended fixes
1. Lower reasoning effort first
For batch classification, extraction, and fixed-field screening, testlow first, then evaluate whether none preserves sufficient quality:
medium, low, and none. max_output_tokens = 8000 is only an example; adjust it for your actual output requirements and reasoning headroom rather than treating it as a universal value.
2. Use streaming while retaining an overall timeout
Streaming does not make the model generate faster, but it distinguishes ongoing generation from a genuinely stalled connection:- Start with a 120–180 second overall timeout;
- A 20–30 second SSE idle timeout is a reasonable starting point;
- Measure idleness across all SSE events, including reasoning events, not just visible text events;
- Still validate the final response status and parse the complete JSON.
3. Reduce batch size, but do not rely on splitting alone
Start by reducing each batch from 20 papers to 10 and retesting with 2–4 concurrent requests to limit the impact of a failed request. Splitting, however, does not guarantee a proportional reduction in reasoning tokens. Use it together with lower reasoning effort rather than as a substitute.4. Constrain retries
Use bounded exponential backoff for 429s, 5xx responses, and clear connection-establishment failures. Do not immediately retry every client timeout after a long wait; first determine whether the server is still generating, otherwise the same batch may run twice.Common questions
Why does a request take over a minute when the final JSON is short?
Why does a request take over a minute when the final JSON is short?
Does streaming reduce total generation time?
Does streaming reduce total generation time?
stream = true does not automatically reduce the number of tokens the model generates.Should every batch summarization workload disable reasoning?
Should every batch summarization workload disable reasoning?
low, and use none only after confirming that it does not reduce screening quality.Why does the log still contain output usage after a client timeout?
Why does the log still contain output usage after a client timeout?