Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error:400 The request's total referenced files bytes are too large to be read when analyzing large image (>20MB) with File API #695

Open
ChenChengKuan opened this issue Mar 1, 2025 · 4 comments
Assignees
Labels
component:api Issues related to the API, not the SDK. type:bug Something isn't working

Comments

@ChenChengKuan
Copy link

ChenChengKuan commented Mar 1, 2025

Description of the bug:

Hello
I followed the official document of handling large image payload (>20MB) but still got the 400 invalid error with the code:

MODEL_NAME = gemini-2.0-flash-001
client = genai.Client(api_key="My api key)
my_file = client.files.upload(file='some_image.png')

client = genai.Client(api_key="My api key)
response = client.models.generate_content(
    model=MODEL_NAME, 
    contents=[
        'describe the image', 
        my_file
    ]
)

The error message:

ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': "The request's total referenced files bytes are too large to be read", 'status': 'INVALID_ARGUMENT'}}

The file size is around 36MB. What I notice is that it is totally fine with image size >=20MB but below 30MB. It seems to me that 30MB is the limit, which is different from what official doc says that per file size can be as large as 2GB

Things I have checked

  • client.file.list() only contain one file I upload which satisfies 20GB in total and 2GB / file
  • genai python sdk version =1.3.0

Could you help me to resolve this?

Actual vs expected behavior:

Should not get 400 error

Any other information you'd like to share?

I am in the paid API tier not free plan

@gmKeshari gmKeshari added type:bug Something isn't working status:triaged Issue/PR triaged to the corresponding sub-team component:api Issues related to the API, not the SDK. labels Mar 3, 2025
@gmKeshari
Copy link

Hi @ChenChengKuan,

I checked from my end with images >=30mb, it is giving the same error with 2.0-flash models. I think there is some limit/issue with 2.0-flash models.

I checked with 1.5 models and "gemini-2.0-pro-exp-02-05" it's working fine.

According to me, you can change the model as of now.

I will follow up on this (2.0-flash) model with the internal team.

Thanks.

@gmKeshari gmKeshari self-assigned this Mar 3, 2025
@gmKeshari gmKeshari added status:awaiting user response Awaiting a response from the author and removed status:triaged Issue/PR triaged to the corresponding sub-team labels Mar 3, 2025
@MarkDaoust
Copy link
Collaborator

MarkDaoust commented Mar 3, 2025

Thanks for the report, I think @junyanxu is looking into it.

Copy link

Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.

@github-actions github-actions bot added the status:stale Issue/PR will be closed automatically if there's no further activity label Mar 18, 2025
@MarkDaoust MarkDaoust removed status:awaiting user response Awaiting a response from the author status:stale Issue/PR will be closed automatically if there's no further activity labels Mar 18, 2025
@AbdielPerezB
Copy link

I have the same problem but with a 67 GB size PDF and the gemini-1.5-pro model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:api Issues related to the API, not the SDK. type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants