> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apiyi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Why does a reasoning model return empty content?

> Getting empty_response, or HTTP 200 with empty text? Usually max_tokens is consumed by thinking. Three checks and three fixes.

## Short answer

This is not an API failure — it is the **thinking budget eating the output budget**.

Reasoning models such as `gpt-6.1-sol` first generate a reasoning trace, then write the answer. Both parts **share** the `max_tokens` allowance. When the budget runs out during thinking, the answer is cut off before it starts, so you receive an empty result.

Raise `max_tokens` (size it to the task, not to the visible answer), or lower the reasoning effort, and the problem disappears.

## What you will see

There are two common forms.

**One is an explicit error**, with HTTP status 429 or 500 (the `message` field may be localized, so a Chinese message is expected on some responses):

```json theme={null}
{
  "error": {
    "message": "上游返回了空响应。",
    "type": "shell_api_error",
    "code": "empty_response"
  }
}
```

**The other is HTTP 200 with empty content**:

```json theme={null}
{
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "" },
      "finish_reason": "length"
    }
  ],
  "usage": {
    "prompt_tokens": 1500,
    "completion_tokens": 300,
    "completion_tokens_details": { "reasoning_tokens": 300, "text_tokens": 0 }
  }
}
```

Look at the usage block: `completion_tokens` is 300, `reasoning_tokens` is 300, `text_tokens` is 0 — **the model generated 300 tokens, spent all of them thinking, and never wrote a single word of output.**

**A third form appears on `/v1/responses`: `status: "incomplete"` with an empty `output_text`**:

```json theme={null}
{
  "id": "resp_abc123",
  "status": "incomplete",
  "incomplete_details": { "reason": "max_output_tokens" },
  "output": [{ "type": "reasoning", "summary": [] }],
  "usage": {
    "input_tokens": 480,
    "output_tokens": 65000,
    "output_tokens_details": { "reasoning_tokens": 65000 }
  }
}
```

On olympiad proofs or hard algorithmic tasks, `gpt-5.5` at `high` / `xhigh` effort can spend **35,000–65,000+ tokens** on internal deliberation alone. Even `max_output_tokens=65000` can be completely exhausted before the visible answer begins — and if your streaming loop only listens for `response.output_text.delta` and `response.completed` while ignoring `response.incomplete`, the terminal prints nothing at all after waiting 10–20 minutes.

> [!NOTE]
>
> The call log shows the request as successful and billed, which is not a contradiction: the model did produce content (the reasoning trace), just no visible text.

## Why this happens

A reasoning model's output has two stages:

| Stage | Content | Returned to you |
| - | - | - |
| Thinking | reasoning tokens, internal deliberation | Some models expose it as `reasoning_content`; usually invisible |
| Answer | text tokens, the visible output | Yes |

`max_tokens` (or `max_completion_tokens`, `max_output_tokens`) limits **both stages combined**, not the length of the visible answer.

So if `max_tokens` is set to something small like 200–500 while the task needs substantial reasoning, the budget is exhausted during thinking. `finish_reason` becomes `length` and the content is empty.

## Three checks

**1. Step 1: read finish\_reason**

If it is `length`, the output was truncated — the model did not refuse to answer. If it is `stop` but the content is still empty, continue to steps 2 and 3.

**2. Step 2: read reasoning\_tokens in usage**

Find `usage.completion_tokens_details.reasoning_tokens` (Claude native responses put it in `usage.output_tokens_details.thinking_tokens`) and compare it with `completion_tokens`. If the two are close or equal, most of the budget went into thinking.

**3. Step 3: read max\_tokens in your request**

If you explicitly set `max_tokens` to a small value (300, for example), that is almost certainly the cause. If you did not set it, check whether your SDK or framework filled in a small default.

This script prints all three signals at once:

```python theme={null}
import json
from openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.apiyi.com/v1")

resp = client.chat.completions.create(
    model="gpt-6.1-sol",
    messages=[{"role": "user", "content": "your question"}],
    max_tokens=2000,
)

choice = resp.choices[0]
usage = resp.usage
print("finish_reason:", choice.finish_reason)
print("content:", repr(choice.message.content)[:100])
print("completion_tokens:", usage.completion_tokens)
print("reasoning_tokens:", getattr(usage.completion_tokens_details, "reasoning_tokens", None))
```

## How to fix it

> [card] Raise max\_tokens
>
> The direct fix. Start at 2,000 for ordinary chat and 16,000+ for heavy reasoning; for `gpt-5.5` high-effort math/algorithm proofs set `max_output_tokens` to 100,000–128,000; on Claude 5.x start at 64,000 (128,000 cap).

> [card] Lower reasoning effort
>
> OpenAI uses `reasoning_effort` (or `reasoning.effort` on Responses — prefer `high` before jumping to `xhigh`); Claude uses `output_config.effort` (top level, not inside `thinking`); Gemini uses `thinkingConfig`.

> [card] Switch to streaming
>
> Set `stream` to `true`. On OpenAI `/v1/responses`, also pass `reasoning={"effort": "high", "summary": "auto"}` and handle `response.incomplete` so you see live reasoning progress and explicit truncation alerts.

### Parameter reference by model family

| Model family | Output budget parameter | Reasoning effort parameter |
| - | - | - |
| OpenAI reasoning models (o series, GPT-5/6 series) | `max_completion_tokens` (Chat), `max_output_tokens` (Responses) | `reasoning_effort` |
| Claude 5.x / 4.7–4.8 | `max_tokens` | `output_config.effort`; `thinking.budget_tokens` was removed and returns 400 |
| Claude 4.5–4.6 | `max_tokens` | `thinking.budget_tokens` (legacy extended thinking) |
| Gemini thinking mode | `maxOutputTokens` | `thinkingConfig.thinkingBudget` |

### If you are on Claude

Claude uses different field names and parameters:

* The cutoff flag is `stop_reason` with value `max_tokens`, not `finish_reason`.
* Thinking tokens are in `usage.output_tokens_details.thinking_tokens`, not `reasoning_tokens`.
* The effort parameter is `output_config.effort`, not `reasoning_effort`.

Claude 5-generation models (Opus 5.5 / Sonnet 5.5 / Haiku 5.5 / Fable 5.1 / Fable 5 / Opus 5 / Sonnet 5) **think by default**. Opus 5.5, Fable 5.1 and Fable 5 cannot disable thinking; Sonnet 5.5 uses `thinking: {"type": "between_tools"}`; Haiku 5.5 and Opus 5 accept `disabled` when effort is `high` or lower.

For coding and long-form work on Claude 5.x, start `max_tokens` at 64,000; the model cap is 128,000. 30,000 is easily consumed by thinking. See [Claude Effort and Thinking Guide](https://docs.apiyi.com/en/api-capabilities/claude-effort-thinking.md).

> [!WARNING]
>
> Some reasoning models reject `max_tokens` and require `max_completion_tokens`. A wrong parameter name may raise an error, or may be silently ignored so the model falls back to a default that does not match your intent.

## FAQ

> [accordion] Why does the log show success while I received an error?
>
> The log records that the upstream finished generating and settled billing. It does not check whether the visible text is empty. Generation succeeding and the answer being non-empty are two different things.

> [accordion] Will simply retrying help?
>
> Usually not. With the same prompt and the same `max_tokens`, the model will most likely spend the budget on thinking again. Changing the parameters is far more effective than retrying.

> [accordion] Am I billed for an empty response?
>
> Yes. Reasoning tokens are real consumption and are billed as output tokens. Check [call logs](https://docs.apiyi.com/en/faq/log-billing-explained.md) for the exact amount.

> [accordion] Does every model behave this way?
>
> No. Only reasoning models with a thinking stage have this problem. Ordinary non-reasoning models such as `gpt-4o` or `deepseek-chat` spend the whole `max_tokens` on visible output.

> [accordion] Does a large max\_tokens cost more?
>
> No. `max_tokens` is a ceiling, not actual consumption. The model stops when it finishes, and you pay for the tokens actually generated.

## Related

> [card] [What is max\_tokens?](https://docs.apiyi.com/en/faq/max-tokens.md)
>
> Parameter meaning, naming history, and per-model defaults

> [card] [Streaming vs non-streaming](https://docs.apiyi.com/en/faq/streaming-vs-non-streaming.md)
>
> Prefer streaming for long responses and reasoning models

> [card] [How to troubleshoot model errors](https://docs.apiyi.com/en/faq/model-error-troubleshooting.md)
>
> General triage for 400, 401, 429, and 503

> [card] [How to read billing in logs](https://docs.apiyi.com/en/faq/log-billing-explained.md)
>
> Confirm whether a request was billed, and how much


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.