Request payload size exceeds the limit

One of my agents got this error

InvalidArgument(‘Request payload size exceeds the limit: 20971520 bytes.’)
google.api_core.exceptions.InvalidArgument: 400 Request payload size exceeds the limit: 20971520 bytes.

But when i checked the file size it was only 32kb. Is this related to rate limits? Because the payload was nowhere near the limit.

whats the best way to monitor these api calls and get the data for each call?

this was my api config when i got the error

generation_config = {
“temperature”: 0.5,
“top_p”: 0.95,
“top_k”: 64,
“max_output_tokens”: 8192,
“response_mime_type”: “application/json”,
}
safety_settings = [
{
“category”: “HARM_CATEGORY_HARASSMENT”,
“threshold”: “BLOCK_NONE”,
},
{
“category”: “HARM_CATEGORY_HATE_SPEECH”,
“threshold”: “BLOCK_NONE”,
},
{
“category”: “HARM_CATEGORY_SEXUALLY_EXPLICIT”,
“threshold”: “BLOCK_NONE”,
},
{
“category”: “HARM_CATEGORY_DANGEROUS_CONTENT”,
“threshold”: “BLOCK_NONE”,
},
]

model = genai.GenerativeModel(
model_name="gemini-1.5-pro-latest",

This sounds like it is a limit on the network transmission size - not on anything related to Gemini itself.

What programming language and library are you using?
Can you show the code around where the error was generated and how you’re building the prompt?