Skip to content
Ruvicode logo
Ruvicode
USD
GuideOctober 21, 2026·6 min read

Reasoning Model Returns Empty Content? Check finish_reason

A reasoning model can spend its whole max_tokens budget thinking and return null content. How to spot it, why it still costs tokens, and what to change.

This one has come up with our users before. "The API returns 200, but the answer is empty." The key works, the model exists, the request shows up in usage, and content is null.

Usually nothing is broken. The model ran out of room before it reached the answer.

What a real request looks like

On 21 October 2026 we sent the same small question to DeepSeek V4 Flash three times and changed only max_tokens. The question: is 391 a prime number?

{
  "model": "deepseek-v4-flash",
  "max_tokens": 20,
  "messages": [
    {
      "role": "user",
      "content": "Is 391 a prime number? Answer yes or no and one short reason."
    }
  ]
}

With a budget of 20 tokens, this came back (trimmed to the fields that matter):

{
  "choices": [
    {
      "finish_reason": "length",
      "message": {
        "role": "assistant",
        "content": null,
        "reasoning_content": "..."
      }
    }
  ],
  "usage": {
    "prompt_tokens": 37,
    "completion_tokens": 20,
    "completion_tokens_details": { "reasoning_tokens": 20 }
  }
}

All 20 output tokens went to reasoning. The model was still working through divisors when it hit the cap, so it never wrote a single token of the actual answer. finish_reason: "length" is how the API tells you the output was cut off.

Here are the three runs side by side:

max_tokensfinish_reasoncompletion tokensof which reasoninganswer returned
20length2020no
300stop128116yes
2000stop113101yes

The bigger budgets did not make the model think longer. Both finished in a little over 100 tokens and gave the right answer (391 is 17 times 23). The extra room only let it finish.

Why it happens

Reasoning models write working notes before they answer. Those notes are output tokens, and they draw from the same max_tokens budget as the answer. A cap that is generous for a regular chat model, where a one-line reply might take 30 tokens, can be used up before a reasoning model is done with its first pass at the problem.

You also pay for those tokens. Reasoning tokens bill as output tokens, so the empty reply above was not free. It cost very little because the request was tiny, but on a long agent turn with a big context the same mistake buys you nothing at full price.

Catch it in code

Check finish_reason, not only content. With the OpenAI Python SDK:

from openai import OpenAI
 
client = OpenAI(base_url="https://api.ruvicode.com/v1", api_key="rvcd_...")
 
resp = client.chat.completions.create(
    model="deepseek-v4-flash",
    max_tokens=2000,
    messages=[{"role": "user", "content": "Is 391 a prime number?"}],
)
 
choice = resp.choices[0]
if choice.finish_reason == "length" and not choice.message.content:
    # The budget ran out during reasoning. Retry with more room
    # instead of showing the user an empty answer.
    ...

length together with empty content almost always means this exact problem. stop with empty content is something else, and we would like to hear about it through the contact page.

Streaming makes it look like a hang

With stream: true the reasoning arrives in delta.reasoning_content, and the answer arrives later in delta.content. Plenty of chat UIs and agent tools render only delta.content. So the user stares at a spinner, the stream closes, and nothing was ever printed.

This is part of our streamed run of the same 20 token request, trimmed:

data: {"choices":[{"delta":{"reasoning_content":" sqrt"},"finish_reason":null,"index":0}]}
data: {"choices":[{"delta":{"reasoning_content":" ~"},"finish_reason":null,"index":0}]}
data: {"choices":[{"delta":{"reasoning_content":"19"},"finish_reason":null,"index":0}]}
...
data: {"choices":[{"delta":{"role":"assistant"},"finish_reason":"length","index":0}]}
data: [DONE]

Every chunk before the last one carried reasoning, and not one carried content. If you write your own client, read both fields and decide whether to show the reasoning, hide it, or put up a "thinking" state while it streams:

stream = client.chat.completions.create(
    model="deepseek-v4-flash",
    max_tokens=2000,
    stream=True,
    messages=[{"role": "user", "content": "Is 391 a prime number?"}],
)
 
for chunk in stream:
    if not chunk.choices:
        continue  # the final usage chunk has no choices
    delta = chunk.choices[0].delta
    thinking = getattr(delta, "reasoning_content", None)
    if thinking:
        pass  # show a thinking indicator, or log it
    if delta.content:
        print(delta.content, end="", flush=True)

The streaming docs cover the rest of the event format.

What to change

Give the model room. For reasoning models, start with a budget in the thousands, not the tens. If you want short answers, say so in the prompt ("answer in one sentence") and let the model decide how much it needs to think.

Lower the reasoning effort where it is supported. We pass reasoning_effort (low, medium, high) through to the model unchanged, as listed in the chat completions reference. Whether a model honors it, and how much it saves, varies by model, so measure it on your own prompts before you rely on it.

Use a non-reasoning model for small jobs. Classification, extraction, and short rewrites rarely need a model that thinks first. The models catalog marks which models reason, and a plain model will answer those tasks in fewer output tokens.

Do not treat max_tokens as a spending cap. It is a request to the model, and in the same round of tests two other models wrote several hundred tokens with max_tokens set to 20. Billing always follows the tokens actually produced. If you need a hard ceiling, set a daily or monthly spend limit on the API key in the dashboard. Once the key reaches its limit, new requests are refused before they reach the model.

Router tools that flag reasoning models as broken

Some router and proxy tools test each model by sending a one word prompt with a very small max_tokens, often under 10. A reasoning model spends that whole budget thinking, returns empty content, and the tool shows a red mark next to it. The model is fine. The test is too small for it. Raise the test budget, or check the response for finish_reason: "length" before you count the model as down.

The short version

When an answer comes back empty, look at finish_reason first. length means the model needed more room, usually because it was reasoning. Raise max_tokens, lower the effort, or pick a model that does not reason for that task, and keep real spending limits on the key instead of on the token cap.

Ready to start building?

Get your API key in under 2 minutes.

Get Started →
R

Ruvicode Team

The people who build and run Ruvicode