Error:
google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {‘error’: {‘code’: 400, ‘message’: ‘Request contains an invalid argument.’, ‘status’: ‘INVALID_ARGUMENT’}}
at google/genai/errors.py:210 (raise_error_async)
at google/genai/errors.py:188 (raise_for_async_response)
at google/genai/_api_client.py:1312 (_async_request_once)
at tenacity/asyncio/init.py:116 (call)
at concurrent/futures/_base.py:401 (get_result)
at concurrent/futures/_base.py:449 (result)
at tenacity/init.py:184 (reraise)
at tenacity/init.py:413 (exc_check)
at tenacity/_utils.py:111 (inner)
at tenacity/asyncio/init.py:157 (iter)
at tenacity/asyncio/init.py:112 (call)
at google/genai/_api_client.py:1367 (_async_request)
at google/genai/_api_client.py:1434 (async_request)
at google/genai/models.py:5839 (_generate_content)
at google/genai/models.py:7033 (generate_content)
at app/services/gemini_service.py:264 (_call_gemini_api_with_config)
at app/utils/retry_utils.py:84 (retry_with_backoff)
at app/utils/retry_utils.py:89 (retry_with_backoff)
at app/utils/retry_utils.py:112 (wrapper)
at app/services/gemini_service.py:277 (_call_gemini_api_with_rotation)
at app/services/gemini_service.py:104 (generate_images_async)
at app/services/gemini_service.py:163 (generate_images_async) # re-raise
at app/tracing/wrappers.py:53 (async_wrapper)
at app/worker.py:257 (_process_task_internal)
at app/worker.py:195 (process_task_async)
at app/worker.py:349 (run_job)
This was intermittent and failed for a while with the same inputs, then started working again without any changes on our side.
One thing I realized is that we’re sending MPO images but setting the MIME type to image/jpeg. That said, we’ve successfully generated thousands of images with Gemini using MPO inputs labeled as JPEG, so this hasn’t been an issue before.
I’m wondering if there’s anything we can do on our end to make this more reliable or avoid this kind of intermittent INVALID_ARGUMENT error going forward.