{"record":{"id":"69cca969a5db8c00","repo":"BerriAI/litellm","slug":"model-unable-to-complete-request-raw-response","errorCode":null,"errorMessage":"{model} unable to complete request: {raw_response.incomplete_details.reason}","messagePattern":"(.+?) unable to complete request: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/transformation.py","lineNumber":768,"sourceCode":"        if len(output_items) == 0:\n            recovered_output_items: Final = self._recover_output_items_from_logging(logging_obj)\n            if recovered_output_items:\n                output_items = cast(Any, recovered_output_items)\n                raw_response.output = cast(Any, recovered_output_items)\n                verbose_logger.warning(\n                    \"Recovered empty Responses API output from raw SSE for model=%s\",\n                    model,\n                )\n\n        # Convert response output to choices using the static helper\n        choices: Final = self._convert_response_output_to_choices(\n            output_items=output_items,\n            handle_raw_dict_callback=self._handle_raw_dict_response_item,\n        )\n\n        if len(choices) == 0:\n            if raw_response.incomplete_details is not None and raw_response.incomplete_details.reason is not None:\n                raise ValueError(f\"{model} unable to complete request: {raw_response.incomplete_details.reason}\")\n            else:\n                raise ValueError(f\"Unknown items in responses API response: {output_items}\")\n\n        setattr(model_response, \"choices\", choices)\n\n        model_response.model = model\n\n        setattr(\n            model_response,\n            \"usage\",\n            ResponseAPILoggingUtils._transform_response_api_usage_to_chat_usage(raw_response.usage),\n        )\n\n        # Preserve hidden params from the ResponsesAPIResponse, especially the headers\n        # which contain important provider information like x-request-id\n        raw_response_hidden_params: Final = getattr(raw_response, \"_hidden_params\", {})\n        if raw_response_hidden_params:\n            if not hasattr(model_response, \"_hidden_params\") or model_response._hidden_params is None:","sourceCodeStart":750,"sourceCodeEnd":786,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/completion_extras/litellm_responses_transformation/transformation.py#L750-L786","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nresp = litellm.completion(model=\"openai/o3-mini\", messages=msgs, max_tokens=1000)\n# ValueError: openai/o3-mini unable to complete request: max_output_tokens\n\n// after\nresp = litellm.completion(model=\"openai/o3-mini\", messages=msgs,\n                          max_completion_tokens=8000, reasoning_effort=\"low\")","handlingStrategy":"retry","validationCode":"REASONING_MODEL_PREFIXES = (\"o1\", \"o3\", \"o4\", \"gpt-5\")\n\ndef token_budget_is_safe(model: str, max_tokens) -> bool:\n    if not any(model.startswith(p) for p in REASONING_MODEL_PREFIXES):\n        return True\n    return max_tokens is None or max_tokens >= 4000","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model=m, messages=msgs, max_completion_tokens=budget)\nexcept ValueError as e:\n    if \"unable to complete request: max_output_tokens\" in str(e) and budget:\n        return litellm.completion(model=m, messages=msgs,\n                                  max_completion_tokens=budget * 4)  # retry with larger budget\n    raise","preventionTips":["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"],"tags":["token-limit","reasoning-model","responses-api","configuration"],"backgroundTag":"response-incomplete-token-limit","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}