{"record":{"id":"2775d0425214ec40","repo":"BerriAI/litellm","slug":"failed-to-initiate-upload-response-text","errorCode":null,"errorMessage":"Failed to initiate upload: {response.text}","messagePattern":"Failed to initiate upload: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/rag/ingestion/gemini_ingestion.py","lineNumber":277,"sourceCode":"            \"x-goog-api-key\": api_key,\n        }\n\n        verbose_logger.debug(\"Initiating resumable upload: %s\", url)\n\n        client: Final = get_async_httpx_client(\n            llm_provider=httpxSpecialProvider.RAG,\n            params={\"timeout\": 60.0},\n        )\n        response: Final = await client.post(\n            url,\n            json=request_body,\n            headers=headers,\n        )\n\n        if response.status_code not in [200, 201]:\n            error_msg: Final = f\"Failed to initiate upload: {response.text}\"\n            verbose_logger.error(error_msg)\n            raise Exception(error_msg)\n        verbose_logger.debug(\"Initiate resumable upload response: %s\", response.headers)\n        # Extract upload URL from response headers\n        upload_url: Final = response.headers.get(\"x-goog-upload-url\")\n        if not upload_url:\n            raise Exception(\"No upload URL returned in response headers\")\n\n        verbose_logger.debug(\"Got upload URL: %s\", upload_url)\n        return upload_url\n\n    async def _upload_file_content(\n        self,\n        upload_url: str,\n        file_content: bytes,\n    ) -> str:\n        \"\"\"\n        Upload file content to the resumable upload URL.\n\n        Returns:","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/rag/ingestion/gemini_ingestion.py#L259-L295","documentation":"The resumable-upload initiation POST to the Gemini Files API returned a non-200/201 status, so no upload session could start. The response body '{response.text}' carries the API's reason (auth, quota, bad metadata); the request is aborted before any bytes are uploaded.","triggerScenarios":"Thrown at litellm/rag/ingestion/gemini_ingestion.py:277 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the response text for the API error and verify the file metadata and API key."],"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-14T00:17:10.932Z"}