google.genai.errors.ServerError: 500 INTERNAL

Hi team,

Today I got 500 internal error when running this code to get uploaded files info via File API.

I used to do the same thing and everything works properly.

from google import genai

client = genai.Client()

print('My files:')
for f in client.files.list():
    print(' ', f.name)

Error:

google.genai.errors.ServerError: 500 INTERNAL. {'error': {'code': 500, 'message': 'Failed to convert server response to JSON', 'status': 'INTERNAL'}}

Hi @user4123 , Thanks for reaching out to us.

Could you clarify the specific model you are using? Also, have you uploaded too many large files?

Hi,

Thanks for reaching out.

The two most frequently used models are gemini-2.5-pro and gemini-3-pro-preview. I primarily use them for video analysis, uploading hundreds of large videos through the File API and Batch API.

Sorry, I forgot to quote, please read my last reply.

Additionally, if I set ‘page_size‘: 1, the terminal can print the first 20 files, but suddenly throw the same 500 error.

@user4123, What is the average file size and format of these videos? The error you are seeing might be due to storage quota issue. Since you are able to print first 20 files, it’s possible a specific file at that position has corrupted metadata or a filename leading to Failed to convert server response to JSON error.

The average file size is about 150mb, and most videos are MP4, MPG, MKV

@user4123, Could you verify your total storage usage in the Google AI Studio or Cloud Console? Even if the average file size is about 150MB, uploading hundreds of videos will likely exceed the 20GB File API limit. Files are stored for 48 hours, so are you manually deleting the files after the analysis is complete, or are you waiting for the auto-deletion after 48 hours ?

The total usage of 20GB was 30%, staying within the limit. I manually deleted the files after analysis using the file API.

@user4123, At this moment, we are not able to reproduce this issue on our end with some test cases. Could you please provide a minimal reproducible code so we can test in on our end.

I got the same error today see: Files API throwing error when trying to list files - #13 by Evan_Lesmez