Skip to content
IFAI

AI models

Google fixes messy JSON in the Gemini API

Published Reach 51

Google just upgraded Structured Outputs in the Gemini API, adding full JSON Schema support that works out-of-the-box with Pydantic and Zod. The update brings support for unions, recursive schemas, and strictly preserves key ordering across Gemini 2.5 models. For developers building multi-agent systems, it means finally putting an end to broken JSON responses in production.

Google fixes messy JSON in the Gemini API
Image: blog.google

If you've ever built real software on top of LLMs, you know the specific pain of broken JSON. You write an airtight prompt, and the model still misses a closing bracket, hallucinates a key, or throws in chatty pleasantries that immediately crash your downstream parser.

Google is tackling that headache head-on. The company just rolled out a major upgrade to Structured Outputs in the Gemini API, bringing expanded JSON Schema support and strict property ordering.

Pydantic and Zod work out of the box

The biggest quality-of-life improvement for developers is native ecosystem support. The Gemini API now plays nicely with popular validation libraries like Pydantic in Python and Zod in JavaScript and TypeScript, without requiring messy translation layers.

Google also checked off a laundry list of heavily requested JSON Schema keywords. The update adds support for anyOf for conditional unions, $ref for recursive schemas, minimum and maximum numeric bounds, prefixItems for tuple-style arrays, additionalProperties, and explicit null types.

Ordered keys and 6x fewer calls

Another critical fix tackles key ordering. For all Gemini 2.5 models and beyond—as well as Google's OpenAI compatibility endpoint—the API now guarantees that output fields appear in the exact order specified in your schema.

That deterministic ordering is huge for streaming workflows, letting systems parse and act on early keys before the full object finishes generating.

In production, the impact is already showing. Early partners report that combining guaranteed schemas with predictable output eliminated broken JSON responses entirely and cut API retry calls by up to 6x.

Why it matters

We think this update highlights a broader shift in the AI race: raw intelligence matters less right now than raw reliability.

If you are building autonomous agents, one agent's structured output is the next agent's input. A single malformed bracket breaks the entire chain. By guaranteeing schema compliance down to recursive refs and strict key orders, Google turns Gemini into a much safer engine for production backends and multi-agent pipelines.

Meeting developers where they already live—specifically supporting Pydantic and Zod out of the box while keeping OpenAI compatibility intact—is a sharp move. It removes the friction of switching providers. If you have been wrestling with brittle JSON parsing or expensive validation retry loops, updating your Gemini integration is an easy win worth testing immediately.

Sources (1)

  1. [1]
    blog.google(opens in a new tab)Originalblog.google

Similar events

Past happenings like this one, for context.

Best of AI, daily