{"record":{"id":"b8a5b93ece6ea68e","repo":"BerriAI/litellm","slug":"invalid-completion-response-no-choices-found","errorCode":null,"errorMessage":"Invalid completion response: no choices found","messagePattern":"Invalid completion response: no choices found","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/google_genai/adapters/transformation.py","lineNumber":493,"sourceCode":"\n    def translate_completion_to_generate_content(\n        self,\n        response: ModelResponse,\n    ) -> dict[str, object]:\n        \"\"\"\n        Transform litellm completion response to Google GenAI generate_content format\n\n        Args:\n            response: ModelResponse from litellm.completion\n\n        Returns:\n            Dict in Google GenAI generate_content response format\n        \"\"\"\n\n        # Extract the main response content\n        choice: Final = response.choices[0] if response.choices else None\n        if not choice:\n            raise ValueError(\"Invalid completion response: no choices found\")\n\n        # Handle different choice types (Choices vs StreamingChoices)\n        if isinstance(choice, Choices):\n            if not choice.message:\n                raise ValueError(\"Invalid completion response: no message found in choice\")\n            parts = self._transform_openai_message_to_google_genai_parts(choice.message)\n        else:\n            # Fallback for generic choice objects\n            message_content = getattr(choice, \"message\", {}).get(\"content\", \"\") or getattr(choice, \"delta\", {}).get(\n                \"content\", \"\"\n            )\n            parts = [{\"text\": message_content}] if message_content else []\n\n        # Create Google GenAI format response\n        generate_content_response: Final[dict[str, object]] = {\n            \"candidates\": [\n                {\n                    \"content\": {\"parts\": parts, \"role\": \"model\"},","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/google_genai/adapters/transformation.py#L475-L511","documentation":"Transform guard in translate_completion_to_generate_content: the ModelResponse from litellm.completion has an empty choices list, so there is no content to translate into Google GenAI generate_content format.","triggerScenarios":"Thrown at litellm/google_genai/adapters/transformation.py:493 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The completion response contained no choices; retry the request or check the provider response for errors.","Verify the request parameters are valid for the target model."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}