BerriAI/litellm · error · ValueError

Failed to delete file: {raw_response.text}

Error message

Failed to delete file: {raw_response.text}

What it means

Error "Failed to delete file: {raw_response.text}" thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/gemini/files/transformation.py:361

        Google AI Studio returns an empty JSON object {} on successful deletion.
        """
        try:
            # Google AI Studio returns {} on successful deletion
            if raw_response.status_code == 200:
                # Extract file ID from the request URL if possible
                file_id = "deleted"
                if hasattr(raw_response, "request") and raw_response.request:
                    url: Final = str(raw_response.request.url)
                    if "/files/" in url:
                        file_id = url.split("/files/")[-1].split("?")[0]
                        # Add the files/ prefix if not present
                        if not file_id.startswith("files/"):
                            file_id = f"files/{file_id}"

                return FileDeleted(id=file_id, deleted=True, object="file")
            else:
                raise ValueError(f"Failed to delete file: {raw_response.text}")
        except Exception as e:
            verbose_logger.exception("Error parsing file delete response: %s", e)
            raise ValueError(f"Error parsing file delete response: {e}")

    def transform_list_files_request(
        self,
        purpose: str | None,
        optional_params: dict,
        litellm_params: dict,
    ) -> tuple[str, dict]:
        raise NotImplementedError("GoogleAIStudioFilesHandler does not support file listing")

    def transform_list_files_response(
        self,
        raw_response: httpx.Response,
        logging_obj: LiteLLMLoggingObj,
        litellm_params: dict,
    ) -> list[OpenAIFileObject]:

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Inspect the Gemini API error text; check file name and API key.

When it happens

Trigger: Thrown at litellm/llms/gemini/files/transformation.py:361 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/7c9785e55610e192. Report an issue: GitHub.