Google declares help for JSON Schema and implicit property ordering in Gemini API.
Right now, we’re saying enhancements to Structured Outputs in the Gemini API, with expanded help for JSON Schema and higher adherence to property ordering within the output.
Structured Outputs allow AI fashions to generate responses that assure adherence to a selected schema, which is vital for duties like information extraction and database inhabitants. They’re additionally vital for agent communication: one agent’s output turns into one other’s formatted enter, enabling advanced multi-agent programs to collaborate with out translation layers.
Expanded JSON Schema help
We’ve now added support for JSON Schema to all actively supported Gemini fashions. This allows libraries like Pydantic (Python) or Zod (JavaScript/TypeScript) to work out-of-the-box with the Gemini API. It builds upon the present help for the Gemini API’s Schema object that’s primarily based on OpenAPI 3.0 for Structured Outputs and Operate Calling.
This replace additionally provides help for continuously requested JSON Schema key phrases, together with:
- anyOf for conditional buildings (Unions)
- $ref for recursive schemas
- minimal and most for numeric constraints
- additionalProperties and sort: ‘null’
- prefixItems for tuple-like arrays
Implicit property ordering
One of many vital updates we now have made is that the API now preserves the identical order because the ordering of keys within the schema. That is supported for all Gemini 2.5 fashions and past and likewise applies to our OpenAI compatibility API. You may see this in motion on this content material moderation instance utilizing Pydantic: