BerriAI/litellm · error · Exception
Failed to initiate upload: {response.text}
Error message
Failed to initiate upload: {response.text} What it means
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.
Source
Thrown at litellm/rag/ingestion/gemini_ingestion.py:277
"x-goog-api-key": api_key,
}
verbose_logger.debug("Initiating resumable upload: %s", url)
client: Final = get_async_httpx_client(
llm_provider=httpxSpecialProvider.RAG,
params={"timeout": 60.0},
)
response: Final = await client.post(
url,
json=request_body,
headers=headers,
)
if response.status_code not in [200, 201]:
error_msg: Final = f"Failed to initiate upload: {response.text}"
verbose_logger.error(error_msg)
raise Exception(error_msg)
verbose_logger.debug("Initiate resumable upload response: %s", response.headers)
# Extract upload URL from response headers
upload_url: Final = response.headers.get("x-goog-upload-url")
if not upload_url:
raise Exception("No upload URL returned in response headers")
verbose_logger.debug("Got upload URL: %s", upload_url)
return upload_url
async def _upload_file_content(
self,
upload_url: str,
file_content: bytes,
) -> str:
"""
Upload file content to the resumable upload URL.
Returns:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Check the response text for the API error and verify the file metadata and API key.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/rag/ingestion/gemini_ingestion.py:277 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/2775d0425214ec40.
Report an issue: GitHub.