Skip to main content

Short answer

When deepseek-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.
Server-side analysis of a set of requests that reached 60 seconds produced the following results: The data shows that the requests were slow neither because the JSON was long nor because generation suddenly slowed during the incident windows. Hidden reasoning consumed most of the generation time.
In the Responses API, 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

1

Step 1: compare total output and reasoning tokens

Inspect the final response:
In this example, reasoning accounts for about 92% of output, while the visible answer is relatively small. If your distribution looks similar, reduce reasoning before compressing the input abstracts further.
2

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.
3

Step 3: compare the client timeout with server-side completion

For a non-streaming request, the complete response normally arrives only after generation finishes. A client disconnect at 60 seconds does not necessarily stop the server at the same time. The server may continue to completion and record usage, so an immediate retry can duplicate generation and charges.

1. Lower reasoning effort first

For batch classification, extraction, and fixed-field screening, test low first, then evaluate whether none preserves sufficient quality:
Use the same samples to compare accuracy, JSON validity, reasoning tokens, and total latency across 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.
If you keep medium reasoning with non-streaming responses, use an overall timeout of at least 180 seconds. In the measurements above, even 120 seconds did not cover the maximum 122-second server duration, while 90 seconds left still less headroom.

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.
Do not sharply reduce max_output_tokens merely to prevent timeouts. The request may finish sooner because it ran out of budget, not because it succeeded, and the final JSON may be incomplete.

Common questions

The model may already have generated a large number of reasoning tokens before producing the JSON. Total latency depends on reasoning plus visible output, not visible output alone.
Not significantly. Streaming improves visibility and timeout control by delivering events incrementally. Setting stream = true does not automatically reduce the number of tokens the model generates.
No. Tasks requiring complex judgment may still benefit from reasoning. Evaluate quality on your own samples: start with low, and use none only after confirming that it does not reduce screening quality.
A client disconnect does not necessarily cancel server-side generation at the same moment. The model may continue through reasoning and visible output, so the log records the tokens actually generated. Blind retries after long timeouts can duplicate that usage.

DeepSeek V4 Flash Responses API

Responses parameters, streaming, and caching

Why does a reasoning model return empty content?

Diagnosing output budgets exhausted by reasoning tokens

How can I avoid API timeouts?

Timeout settings for clients, proxies, and different workload types

Long-form output best practices

Streaming, event idle timeouts, and retry strategies for long-running tasks