Error: Input token count exceeds maximum allowed in Google GenAI API
I'm using the gemini-2.5-pro-preview-03-25 and I get the following error when trying to analyse a large Python repo:
google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'The input token count (1252454) exceeds the maximum number of tokens allowed (1048576).', 'status': 'INVALID_ARGUMENT'}}
It seems like the tool is attempting to send too large payload - in this case, over 1.2 million tokens, which exceeds the model's maximum of 1,048,576 tokens.
I'm aware that this is a limitation of the LLM itself, not the tool, but since Gemini is one of the models with the largest context window, I think maybe it's worth exploring some techniques to avoid LLM limitations, for example implementing automatic chunking of source files or text blocks before sending to the model.
Source: The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge