Hi! I'm trying to use Gemini 1.5 with image batches and running into some issues. According to the docs, Gemini 1.5 supports up to 3,600 images, but I'm getting 500 errors when trying to process more than ~15 images at once. For my current request, I'm trying to send 128 images. even 20 images pretty consistently fails.
When i print my completion, we see:
ChatCompletion(id=None, choices=None, created=None, model=None, object=None, service_tier=None, system_fingerprint=None, usage=None, error={'message': 'Internal Server Error', 'code': 500}, user_id='user_id')
Here's a minimal reproducible example:
import json
from openai import OpenAI
# Read messages containing multiple images
with open('debug_messages.txt', 'r') as f:
messages = json.loads(f.read())
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key="api_key",
)
completion = client.chat.completions.create(
model="google/gemini-flash-1.5",
messages=messages
)
print(completion.choices[0].message.content)
This works fine with 15 or fewer images but fails with 500 errors when trying to process more. The messages follow the format outlined in the docs:
{
"role": "user",
"content": [
{"type": "text", "text": "Some text"},
{"type": "image_url", "image_url": {"url": "https://example.com/image1.jpg"}},
{"type": "image_url", "image_url": {"url": "https://example.com/image2.jpg"}},
# ... more images
]
}
Is this a known limitation? Any suggestions for handling larger batches of images? For now I've worked around it by processing in chunks of 15 images, but wanted to check if there's a better approach.