Files API throwing error when trying to list files

Hi, I am trying to list the files for my Gemini client using the code below:

client = genai.Client(api_key=API_KEYS.get(api_type))
print(client.files.list())

but the print(client.files.list()) throws the below error. I need to list the files to use the API, as I have reached my quota limit for file storage (20GB) and need to delete some files. I have been doing it for a couple of days, and it was working fine, but then it went awry last night.

File "/root/home/molmo-R1/molmo_r1/context_vlm.py", line 35, in __init__
    print(self.client.files.list())
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.conda/envs/prog-r1/lib/python3.11/site-packages/google/genai/files.py", line 714, in list
    self._list(config=config),
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.conda/envs/prog-r1/lib/python3.11/site-packages/google/genai/files.py", line 385, in _list
    response_dict = self._api_client.request(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.conda/envs/prog-r1/lib/python3.11/site-packages/google/genai/_api_client.py", line 755, in request
    response = self._request(http_request, stream=False)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.conda/envs/prog-r1/lib/python3.11/site-packages/google/genai/_api_client.py", line 684, in _request
    errors.APIError.raise_for_response(response)
  File "/root/.conda/envs/prog-r1/lib/python3.11/site-packages/google/genai/errors.py", line 103, in raise_for_response
    raise ServerError(status_code, response_json, response)
google.genai.errors.ServerError: 500 INTERNAL. {'error': {'code': 500, 'message': 'Failed to convert server response to JSON', 'status': 'INTERNAL'}}

Hey @Jitesh_Jain , Welcome to the forum.

500 Internal Error is a temporary issue, an unexpected error occurred on Google’s side. I checked from my end, and its working now.

Let me know if you are still facing the issue.

Hi @GUNAND_MAYANGLAMBAM, thank you, it’s working now!

Hi, it is all day I am having this error :frowning:

The error showed up again this afternoon

@GUNAND_MAYANGLAMBAM, could you please look into this? It happens every one or two hours

1 Like