Skip to main content

Why Your Claude API Call Returned an Empty Response (Thinking Ate the Token Budget)

Claude API returned HTTP 200 but no text, stop_reason max_tokens? Thinking is on by default and counts against max_tokens. How to spot it, and the two-line fix.

Advertisement

My daily digest worked on short inputs. Once the prompt grew, every call came back with HTTP 200, a bill, and no text at all.

The short answer

On current Claude models, thinking is switched on by default and counts against max_tokens. If your limit was sized for the answer alone, the model can spend all of it thinking and stop before it writes anything. The response has stop_reason: "max_tokens" and only a thinking block, usually with empty text. Raise max_tokens well above the answer size, lower output_config.effort for simple tasks, and log stop_reason and usage every time a reply has no text.

4,000the max_tokens I had set
3,999of those tokens spent thinking
0characters of answer

Where this comes from

This was a WordPress plugin on my own site that calls the Claude Messages API over plain HTTP from PHP to compile a daily security digest. The model was Claude Sonnet 5. The same behaviour applies to the other current Claude models that think by default. Checked against Anthropic’s API documentation in October 2026.

The symptom

The plugin sends the day’s news items to Claude and asks for a condensed digest as JSON. It worked for weeks. Then I added an “update mode” that passes the existing digest back in so the model can merge new items into it. The prompt got longer, and from then on every call failed with:

cx-brief: model did not return JSON

The HTTP status was 200. The API had not errored. The calls were also slow: about 42 seconds each, against about 27 seconds for a normal successful call.

Advertisement

The false lead

I assumed the model was ignoring the format instruction, so I spent time tightening the prompt: “respond with JSON only”, an example object, stricter wording. None of it changed anything, because the model was not writing the wrong thing. It was not writing anything.

What the raw response showed

I added a filter on WordPress’s http_response hook to save the raw API body for this one request. The answer was right there:

{
  "stop_reason": "max_tokens",
  "content": [
    { "type": "thinking", "thinking": "", "signature": "..." }
  ],
  "usage": {
    "input_tokens": "...",
    "output_tokens": 4000,
    "output_tokens_details": { "thinking_tokens": 3999 }
  }
}

Three things in that response tell the whole story:

  • stop_reason is max_tokens, not end_turn. The model was cut off.
  • content holds one thinking block and no text block. My code only looked for text, found none, and reported “did not return JSON”.
  • Nearly all 4,000 output tokens went to thinking.

The thinking text is empty because current models don’t return their reasoning by default. You are billed for it, but the block comes back blank unless you ask for a summary.

Why it happened

On older Claude models, thinking was off unless you turned it on, and you gave it a separate budget. On current models that changed:

A
Thinking is on by default.

Sonnet 5 uses adaptive thinking unless told otherwise. It decides for itself how much to think.

B
Thinking comes out of max_tokens.

There is no separate pot. The limit covers thinking and answer together.

C
A longer prompt means more thinking.

Merging new items into an existing digest is a harder task than summarising a short list, so the model thought for longer and ran out before answering.

My max_tokens: 4000 had been sized for the digest. That was fine when the model thought briefly. It stopped being fine the day the task got harder.

The fix

Two changes to the request body:

{
  "model": "claude-sonnet-5",
  "max_tokens": 16000,
  "output_config": { "effort": "low" },
  "messages": [ ... ]
}

Raise max_tokens. Size it for thinking plus answer, not the answer alone. For a non-streaming request, around 16,000 is a sensible default. You only pay for the tokens actually generated, so a higher ceiling costs nothing when the model doesn’t need it.

Lower effort for simple tasks. output_config.effort controls how hard the model works, including how much it thinks. Condensing a list of news items does not need deep reasoning, so low is right here. Keep high or above for work where quality depends on careful reasoning.

After the change, the same update-mode call returned a complete digest in about 27 seconds.

Two things I tried along the way that don’t work on this model:

  • The old budget_tokens setting ("thinking": {"type": "enabled", "budget_tokens": N}) is rejected with a 400 on current models. Effort replaced it.
  • Prefilling the reply with { to force JSON is also rejected on current models. If you need guaranteed JSON, use structured outputs (output_config.format with a JSON schema) instead.

Make the next one visible

The real cost of this bug was the time spent on the wrong problem. Anywhere you call the API over raw HTTP, add this check before you parse:

$body = json_decode( wp_remote_retrieve_body( $response ), true );
$text = '';
foreach ( $body['content'] ?? [] as $block ) {
    if ( ( $block['type'] ?? '' ) === 'text' ) {
        $text .= $block['text'];
    }
}
if ( $text === '' ) {
    error_log( sprintf(
        'Claude returned no text: stop_reason=%s usage=%s',
        $body['stop_reason'] ?? 'none',
        wp_json_encode( $body['usage'] ?? [] )
    ) );
}

That one log line would have told me the cause on the first failure.

If your requests run long: stream

A larger max_tokens can mean longer requests. Over plain HTTP, a long non-streaming call can hit your client’s timeout before the response arrives. WordPress’s default wp_remote_post timeout is only 5 seconds, so set it explicitly (my plugin uses 120 seconds). If you push max_tokens much higher than 16,000, switch to streaming so the connection stays alive while the model works.

Checklist

  1. Empty reply with HTTP 200? Check stop_reason first. max_tokens means it was cut off.
  2. Look for a thinking block with no text block after it.
  3. Size max_tokens for thinking plus answer. Start around 16,000.
  4. Set output_config.effort to suit the task: low for condensing and formatting, high for hard reasoning.
  5. Don’t use budget_tokens or prefill on current models. Both return 400.
  6. Log stop_reason and usage whenever a reply has no text.
  7. Set an explicit HTTP timeout, and stream for very large outputs.

Takeaway

Nothing was broken. The model did exactly what current Claude models do: think first, then answer, out of one shared budget. A limit that was generous last year is now a limit on thinking and answer combined, and when the task gets harder the answer is the part that gets cut.

Your turn

Have you hit an empty reply from an LLM API?

Follow the conversation on XEach answer opens a post on X that you can edit before sending.

AI assisted with finding the cause and drafting this article. The plugin, the logs and the timings are from my own site.

Advertisement
Share this article
Written by Engineer running a 24/7 homelab since 2022. Every guide here is built and tested on my own hardware. No paid placements.

Keep reading