BerriAI/litellm · error · NotImplementedError
GoogleAIStudioFilesHandler does not support file listing
Error message
GoogleAIStudioFilesHandler does not support file listing
What it means
GoogleAIStudioFilesHandler.transform_list_files_request deliberately raises NotImplementedError: the Gemini files handler implements upload/retrieve/delete but not listing, even though Google's Files API exposes GET /v1beta/files. Any list-files call routed to the gemini provider (e.g. litellm.files_list / litellm.list_files with custom_llm_provider='gemini') fails here before any HTTP request is made.
Solutions
- Call the Gemini Files API directly for listing: httpx.get(f'{base}/v1beta/files', headers={'x-goog-api-key': KEY}) and page through nextPageToken
- Or use the google-genai SDK: client.files.list()
- Track file ids in your own database at create time instead of relying on server-side listing
- Upstream: open a GitHub issue/PR on BerriAI/litellm to implement transform_list_files_request for the Gemini handler
Example fix
# before
files = litellm.files_list(custom_llm_provider='gemini', api_key=KEY)
# NotImplementedError: GoogleAIStudioFilesHandler does not support file listing
# after - list directly against the Gemini Files API
import httpx
resp = httpx.get(
'https://generativelanguage.googleapis.com/v1beta/files',
headers={'x-goog-api-key': KEY},
)
resp.raise_for_status()
files = resp.json().get('files', []) Defensive patterns
Strategy: validation
Validate before calling
GEMINI_FILES_UNSUPPORTED = {'list', 'content'}
def files_op_allowed(op: str, provider: str) -> bool:
return not (provider == 'gemini' and op in GEMINI_FILES_UNSUPPORTED)
assert files_op_allowed('list', 'gemini') is False Try / catch
try:
files = litellm.files_list(custom_llm_provider='gemini', api_key=KEY)
except NotImplementedError:
files = httpx.get(
'https://generativelanguage.googleapis.com/v1beta/files',
headers={'x-goog-api-key': KEY},
).json().get('files', []) Prevention
- Maintain a per-provider capability map for file operations and branch before calling litellm
- Persist file ids at upload time so listing is never required
- Know the gemini handler's supported set: create, retrieve, delete only
When it happens
Trigger: litellm.files_list(custom_llm_provider='gemini', api_key=KEY); any code that iterates uploaded files through LiteLLM's OpenAI-style files interface against the Gemini provider.
Common situations: Porting OpenAI file-management code (client.files.list()) to Gemini through LiteLLM; housekeeping scripts that list files before deleting; assuming provider parity because upload/get/delete work.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- GoogleAIStudioFilesHandler does not support file content…
- Error parsing file delete response
- Error parsing file retrieve response
- Error parsing file upload response
- Failed to delete file
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/de6a814c2bbbd14b.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/gemini/files/transformation.py:372
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]:
raise NotImplementedError("GoogleAIStudioFilesHandler does not support file listing")
def transform_file_content_request(
self,
file_content_request,
optional_params: dict,
litellm_params: dict,
) -> tuple[str, dict]:
raise NotImplementedError("GoogleAIStudioFilesHandler does not support file content retrieval")
def transform_file_content_response(View on GitHub (pinned to 77b7c6c40c)