Google is making it easier to use the Gemini API in multi-agent workflows

A graphic for structured outputs in the Gemini API.
(Image credit: Google)

What you need to know

  • Google's latest Gemini API update adds enhanced support for structured outputs.
  • JSON Schema in the Gemini API allows developers, businesses, and schools to ensure data consistency between AI workflows.
  • The functionality is helpful for agentic workflows and LLM processing.

Disclaimer

Enjoy our content? Make sure to set Android Central as a preferred source in Google Search, and find out why you should so that you can stay up-to-date on the latest news, reviews, features, and more.

Google is updating the Gemini API to include better support for structured outputs, and the improvements will make it easier to use the API across multiple AI agents. The feature specifically adds support for JSON Schema, with allows the Gemini API to tap into data validation libraries like Pydantic and Zod. Previously, the Gemini API only support schemas based on the OpenAI 3.0 specification.

"Structured Outputs enable AI models to generate responses that guarantee adherence to a specific schema, which is important for tasks like data extraction and database population," Google explains in a blog post. "They are also important for agent communication: one agent’s output becomes another’s formatted input, enabling complex multi-agent systems to collaborate without translation layers."

JSON Schema support applies to all Gemini models that are still actively supported by Google, including all Gemini 2.5 models. One feature, implicit property ordering, also works with Google's OpenAI compatibility API. In the example code provided by Google below, you'll see the revised Gemini API in action, which keeps an identical order to the ordering of schema keys:

from google import genai
from pydantic import BaseModel, Field
from typing import Union, Literal

class SpamDetails(BaseModel):
    """Details for content classified as spam."""
    reason: str = Field(description="The reason why the content is considered spam.")
    spam_type: Literal["phishing", "scam", "unsolicited promotion", "other"] = Field(description="The type of spam.")

class NotSpamDetails(BaseModel):
    """Details for content classified as not spam."""
    summary: str = Field(description="A brief summary of the content.")
    is_safe: bool = Field(description="Whether the content is safe for all audiences.")

class ModerationResult(BaseModel):
    """The result of content moderation."""
    decision: Union[SpamDetails, NotSpamDetails]

client = genai.Client()

prompt = """
Please moderate the following content and provide a decision.
Content: 'Congratulations! You've won a free cruise to the Bahamas. Click here to claim your prize: www.definitely-not-a-scam.com'
"""

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents=prompt,
    config={
        "response_mime_type": "application/json",
        "response_json_schema": ModerationResult.model_json_schema(),
    },
)

recipe = ModerationResult.model_validate_json(response.text)
print(recipe)

Structured outputs, including JSON Schema, are available in the Gemini API starting today. Users can check out the official documentation in Google's Gemini API Docs to learn more.

Gemini API's schema support is built for agentic AI systems

Gemini Agent mode at Google I/O 2025

(Image credit: Android Central)

You might be wondering, how are structured outputs used in the real world? Google's answer to that question is simple: agentic AI. Google has been touting the future of agentic AI for a while now, starting with an appearance at Samsung's Galaxy Unpacked event in January 2025 and continuing at Google I/O in May 2025. There are consumer-facing projects that leverage agentic help, like Agent Mode, and more developer and enterprise tools — like the Gemini API.

In this case, businesses, schools, and developers can use the Gemini API to create multi-agent workflows for processing data. It ensures that schemas remain consistent across various AI agents and LLMs, which is critical for data processing an extraction. While you might not use structured outputs as the average Android user, you'll certainly encounter software applications that leverage the Gemini API's newest features.

TOPICS
Brady Snyder
Contributor

Brady is a tech journalist for Android Central, with a focus on news, phones, tablets, audio, wearables, and software. He has spent the last three years reporting and commenting on all things related to consumer technology for various publications. Brady graduated from St. John's University with a bachelor's degree in journalism. His work has been published in XDA, Android Police, Tech Advisor, iMore, Screen Rant, and Android Headlines. When he isn't experimenting with the latest tech, you can find Brady running or watching Big East basketball.

You must confirm your public display name before commenting

Please logout and then login again, you will then be prompted to enter your display name.