5 Undocumented Rules for Gemini Structured Output, Measured in Production
We run a document extraction pipeline on Gemini with a native responseSchema attached, not a "please reply with JSON" instruction in the prompt text. Over two months, three separate production problems traced back to behaviours of that schema that are not in Google's documentation. These are the rules we ship with now, and the measurement behind each one. The domain is anonymized (no client, no…
Rule 1: Order the required properties of a schema as they appear in the required array, followed by optional properties in any order. The declaration order inside properties does not affect the order of required properties. This rule governs the correctness of the output, not just cosmetics. The order is empirical and not documented by Google. Measure the effect of the order on a specific model (gemini-3-flash-preview) and adjust as needed.
Rule 2: Before shipping a schema, count the total number of enum values across the entire schema. There is an undocumented ceiling on the total enum-value count. If the count exceeds this limit, Gemini will reject the schema. In production, the ceiling was found to be lower than expected.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.