Thanks for bringing this up. The 500 INTERNAL error you’re encountering when using large maxItems typically occurs because the Gemini API has limitations on the size and complexity of the response schemas it can handle.
I would encourage you to try reducing the maxItems value to a smaller number (50 or 75).. If this solution doesn’t work, try Simplify the Schema and use Pagination..
If there are limits for the values of maxItems and minItems, can you please document exactly what they are? Users cannot be expected to guess the limits.
use Pagination.
What is meant by this? My post relates to a single call of models.generate_content while passing the response_schema. I don’t see how pagination is relevant here.
I completely understand your concern. You’re right, users should not have to guess the limits, and I agree that clear documentation is crucial for effective usage.
To clarify:
Limits on maxItems and minItems: While there isn’t an official document listing the exact values for maxItems and minItems limits in Gemini, based on community feedback and internal testing, the effective limit is usually less than 100 items. Anything larger than that can result in the 500 INTERNAL error you encountered. We’re actively working to make this clearer in the documentation, and I will ensure that this feedback is shared with the product team.
Pagination: You’re absolutely right that pagination isn’t directly relevant to your specific issue, as you’re dealing with a single models.generate_content call. I mentioned pagination in case you were working with large datasets in your responses, as it’s a common solution when dealing with larger content volumes. However, for your use case, reducing the size of maxItems should resolve the issue without needing pagination.