BerriAI/litellm · error · ValueError
unable to complete request
Error message
{model} unable to complete request: {raw_response.incomplete_details.reason} What it means
The Responses API output produced zero convertible choices and the response carries incomplete_details.reason — the model stopped before emitting any message content. The dominant cause is max_output_tokens being exhausted by invisible reasoning before any output text was generated, so the response contains only reasoning items and incomplete_details.reason='max_output_tokens'. The reason string from the provider is included in the message.
Solutions
- Raise or remove the max_tokens/max_completion_tokens cap so reasoning plus output fit (e.g. 4k+ for reasoning models)
- Lower reasoning_effort (e.g. to 'low') to shrink the reasoning budget instead of capping total tokens
- Check the reason string: 'max_output_tokens' means raise the cap; 'content_filter' means adjust the prompt/content
- For smoke tests, use a non-reasoning model or a much larger budget
Example fix
// before
resp = litellm.completion(model="openai/o3-mini", messages=msgs, max_tokens=1000)
# ValueError: openai/o3-mini unable to complete request: max_output_tokens
// after
resp = litellm.completion(model="openai/o3-mini", messages=msgs,
max_completion_tokens=8000, reasoning_effort="low") Defensive patterns
Strategy: retry
Validate before calling
REASONING_MODEL_PREFIXES = ("o1", "o3", "o4", "gpt-5")
def token_budget_is_safe(model: str, max_tokens) -> bool:
if not any(model.startswith(p) for p in REASONING_MODEL_PREFIXES):
return True
return max_tokens is None or max_tokens >= 4000 Try / catch
try:
resp = litellm.completion(model=m, messages=msgs, max_completion_tokens=budget)
except ValueError as e:
if "unable to complete request: max_output_tokens" in str(e) and budget:
return litellm.completion(model=m, messages=msgs,
max_completion_tokens=budget * 4) # retry with larger budget
raise Prevention
- Do not port small GPT-4-era max_tokens caps onto reasoning models
- Budget = reasoning + output; prefer omitting the cap or using large values (4k+)
- Pair tight budgets with reasoning_effort='low'
- Read incomplete_details.reason from the message to pick the right corrective action
When it happens
Trigger: Reasoning models (o3/o4-mini/gpt-5 class) called with a small max_tokens or max_completion_tokens cap; high reasoning_effort combined with a tight token budget; tool-heavy prompts where planning consumes the entire budget; any responses-bridged call where the provider reports incomplete_details.
Common situations: Porting existing max_tokens=512-style budgets from GPT-4 code to reasoning models; cost-limiting proxies that inject low token caps; CI smoke tests with tiny limits that now fail on reasoning models; streaming and non-streaming alike.
Related errors
- api_base not set for Hosted VLLM responses API. Set via…
- 503
- AI21Exception
- AlephAlphaException
- All values in argilla_transformation_object must be a key…
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/69cca969a5db8c00.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/completion_extras/litellm_responses_transformation/transformation.py:768
if len(output_items) == 0:
recovered_output_items: Final = self._recover_output_items_from_logging(logging_obj)
if recovered_output_items:
output_items = cast(Any, recovered_output_items)
raw_response.output = cast(Any, recovered_output_items)
verbose_logger.warning(
"Recovered empty Responses API output from raw SSE for model=%s",
model,
)
# Convert response output to choices using the static helper
choices: Final = self._convert_response_output_to_choices(
output_items=output_items,
handle_raw_dict_callback=self._handle_raw_dict_response_item,
)
if len(choices) == 0:
if raw_response.incomplete_details is not None and raw_response.incomplete_details.reason is not None:
raise ValueError(f"{model} unable to complete request: {raw_response.incomplete_details.reason}")
else:
raise ValueError(f"Unknown items in responses API response: {output_items}")
setattr(model_response, "choices", choices)
model_response.model = model
setattr(
model_response,
"usage",
ResponseAPILoggingUtils._transform_response_api_usage_to_chat_usage(raw_response.usage),
)
# Preserve hidden params from the ResponsesAPIResponse, especially the headers
# which contain important provider information like x-request-id
raw_response_hidden_params: Final = getattr(raw_response, "_hidden_params", {})
if raw_response_hidden_params:
if not hasattr(model_response, "_hidden_params") or model_response._hidden_params is None:View on GitHub (pinned to 77b7c6c40c)