TechBriefAI

Google Enhances Gemini API with Expanded JSON Schema Support

Executive Summary:

Google has announced significant enhancements to the Structured Outputs feature within the Gemini API, adding full support for the JSON Schema standard across all actively supported models. This update enables guaranteed schema adherence in model responses, allowing for out-of-the-box compatibility with popular data validation libraries like Pydantic and Zod. A key improvement is the preservation of property ordering from the schema in the final output, increasing reliability for developers building complex data extraction pipelines and multi-agent systems.

Key Takeaways:

* Expanded JSON Schema Support: The API now supports the JSON Schema standard, building upon its existing OpenAPI 3.0-based schema support for structured outputs and function calling.

* Library Compatibility: This update allows for seamless, out-of-the-box integration with popular data validation libraries like Pydantic (Python) and Zod (JavaScript/TypeScript).

* New Keywords Supported: Support has been added for frequently requested JSON Schema keywords, including `anyOf` (unions), `$ref` (recursion), `minimum`/`maximum` (constraints), and `prefixItems`.

* Implicit Property Ordering: For Gemini 2.5 models and later, the API now preserves the order of keys from the input schema in its JSON output, ensuring more predictable and consistent results.

* Target Use Cases: The feature is crucial for data extraction, database population, and enabling communication in multi-agent systems by ensuring one agent's output is correctly formatted as another's input.

* Availability: These enhancements are available in the Gemini API today.

Strategic Importance:

This update makes the Gemini API more robust and developer-friendly for production-grade applications, directly addressing a critical need for reliable, structured data handling and reducing friction for developers using common toolchains.

Original article