Google AI News 前天 02:01
Gemini API更新:增强结构化输出与JSON Schema支持
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了Gemini API结构化输出功能升级,包括扩展JSON Schema支持和改进属性排序,以提升AI模型响应的一致性和系统协作能力。

Today, we're announcing enhancements to Structured Outputs in the Gemini API, with expanded support for JSON Schema and better adherence to property ordering in the output.

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. 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.

Expanded JSON Schema support

We’ve now added support for JSON Schema to all actively supported Gemini models. This enables libraries like Pydantic (Python) or Zod (JavaScript/TypeScript) to work out-of-the-box with the Gemini API. It builds upon the current support for the Gemini API’s Schema object that is based on OpenAPI 3.0 for Structured Outputs and Function Calling.

This update also adds support for frequently requested JSON Schema keywords, including:

  • anyOf for conditional structures (Unions)
  • $ref for recursive schemas
  • minimum and maximum for numeric constraints
  • additionalProperties and type: 'null'
  • prefixItems for tuple-like arrays

Implicit property ordering

One of the important updates we have made is that the API now preserves the same order as the ordering of keys in the schema. This is supported for all Gemini 2.5 models and beyond and also applies to our OpenAI compatibility API. You can see this in action in this content moderation example using Pydantic:

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Gemini API 结构化输出 JSON Schema AI模型 系统协作
相关文章