@_philschmid:现在可以在 Gemini Enterprise Agent Platform(前身为 Vertex AI)上使用 Interactions API 与 Gemini 模型集成,沿用相同的 `google-genai` SDK。
摘要
Phil Schmid 报道 Gemini Enterprise Agent Platform(前身为 Vertex AI)现已支持 Interactions API 与 Gemini 模型集成,并继续沿用 `google-genai` SDK;该 API 提供统一的有状态接口,支持服务端会话状态、可观察的执行步骤与后台长任务执行。
查看缓存全文
缓存时间: 2026/09/30 18:11
现在你可以在 Gemini Enterprise Agent Platform(原 Vertex AI)上使用 Interactions API,并配合 Gemini 模型。仍然使用同一个 google-genai SDK。https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/interactions…
Interactions API 概览
Source: https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/interactions?hl=pt-br
Interactions API 提供了一个统一的、有状态的接口,用于基于 Gemini Enterprise Agent Platform 上托管的 Gemini 模型和智能体来构建生成式 AI 应用和智能体工作流。虽然它与现有 generateContent API 在功能上有重叠,但 generateContent 仍被完全支持。
为什么要使用 Interactions API?
Interactions API 在构建生成式 AI 应用和智能体工作流方面具备以下重要优势:
- 模型与智能体共用同一 API:通过统一的端点和模式,可直接调用 Gemini 标准模型以及专用智能体(例如 Gemini Deep Research Agent 和自定义托管智能体)。
- 开箱即用的新功能:包括可选的服务端会话状态(通过
previous_interaction_id)、可观测的执行步骤(便于调试和 UI 渲染),以及通过background=true支持长时间任务的后台执行。 - 新功能的首发平台:从现在起,所有新模型、多模态功能、工具和智能体能力都将首先支持 Interactions API。
Interactions API 的工作原理
Interactions API 的核心是 Interaction 资源(https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/models/interactions-api?hl=pt-br#Resource:Interaction)。一个 Interaction 代表对话或任务中的一个完整回合,并作为会话记录,包含按时间顺序排列的执行 steps 序列:
user_input:为该回合提供的输入消息、多模态文件或工具调用结果。通过interactions.get获取的已存储交互包含完整的user_input步骤以保留上下文,而interactions.create的响应仅返回该回合期间产生的步骤。thought:模型或智能体在规划回答过程中生成的中间推理摘要。- 工具调用与结果步骤:客户端或服务端的工具调用及其输出(例如
function_call和function_result)。 model_output:模型或智能体生成的最终文本、结构化 JSON 或多模态内容。
当你调用 interactions.create(https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/models/interactions-api?hl=pt-br#CreateInteraction)时,Agent Platform 会处理你的输入,执行所有配置的服务端工具或智能体循环,并返回相应的 Interaction 资源。如需 Python、TypeScript/JavaScript 和 REST 的代码示例,请参阅 Interactions API 开发者指南(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/interactions/developer-guide?hl=pt-br)。
支持的模型
以下 Gemini 模型支持 Interactions API:
点击展开支持的模型
- Gemini Omni Flash(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/omni-flash-preview?hl=pt-br)预览版
- Gemini 3.8 Flash(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-8-flash?hl=pt-br)
- Gemini 3.7 Flash(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-7-flash?hl=pt-br)
- Gemini 3.6 Flash(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-6-flash?hl=pt-br)
- Gemini 3.5 Flash-Lite(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-5-flash-lite?hl=pt-br)
- Gemini 3.1 Pro(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-1-pro?hl=pt-br)预览版
- Gemini 3.1 Flash-Lite(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-1-flash-lite?hl=pt-br)
除上述模型外,Interactions API 还支持以下音频生成和多模态专用模型:
gemini-omni-flash-preview:高性能多模态模型,支持对话式视频的生成、编辑和电影级控制。lyria-3-clip-preview和lyria-3-pro-preview:生成式音乐模型,可制作高保真音频片段和完整乐曲(仅支持通过store=false进行无状态交互)。
支持的智能体
你可以通过指定 agent 参数(而非 model)来调用以下智能体:
antigravity-preview-05-2026:面向多步骤推理、编程、文件操作和工具使用的通用自主智能体。deep-research-preview-04-2026:Gemini Deep Research Agent(https://docs.cloud.google.com/gemini-enterprise-agent-platform/agents/use-deep-research?hl=pt-br),面向 Web 上自主、多阶段的研究与综合。- 部署在 Agent Platform 上的自定义托管智能体(https://docs.cloud.google.com/gemini-enterprise-agent-platform/build/managed-agents/interact-with-agents?hl=pt-br)。
功能与规格
以下章节介绍 Interactions API 的主要功能、技术规格和运维注意事项。
状态管理
默认情况下,Interactions API 会存储请求,以便你可以使用 previous_interaction_id 享受服务端状态管理功能。如需启用无状态行为,请设置 store=false。
支持的工具与 Grounding
Interactions API 上的 Gemini 3 模型支持以下内置工具、Grounding 提供方和搜索功能:
- Google Search Grounding(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/grounding/grounding-with-google-search?hl=pt-br)和企业级 Web Grounding(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/grounding/web-grounding-enterprise?hl=pt-br):使用来自 Google Search 或企业级 Web Grounding 的实时 Web 信息为模型回答提供依据。
- Agent Search 与 Gemini Enterprise Agent Platform 上的 RAG 引擎:使用 Agent Search 和 RAG 引擎,基于私有企业数据仓库和文档为模型回答提供依据。
- xAI Search:将模型接入实时社交搜索和知识 Grounding。
- Parallel Search:基于 Parallel Web Systems 搜索 API 提供的实时 Web 公开数据为模型回答提供依据。
- 代码执行(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/tools/code-execution?hl=pt-br):允许模型在安全的沙盒环境中生成并执行 Python 代码。
- 函数调用(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/tools/function-calling?hl=pt-br):通过返回结构化的函数参数,让模型连接外部工具、API 和数据库。
Interactions API 支持企业级 Web Grounding 和 Google Search Grounding。这些功能的使用同样受特定服务条款(https://cloud.google.com/terms/service-terms?hl=pt-br)约束。
计费
Interactions API 按 token 消耗量计费。
被中断或未完成请求的计费方式如下:
- 手动取消:如果交互在完成前被取消(例如发送取消请求),你将为取消时已消耗的 token 付费。
- 请求失败:如果交互请求因系统内部错误或后端故障而失败,则不会产生费用。
安全与合规
在预览版期间,Interactions API 在安全性、合规性和数据驻留方面有以下注意事项:
- 安全与合规认证:Interactions API 预览版不支持 FedRAMP,也不支持客户管理加密密钥(CMEK),且不符合美国国防部(DoD)影响等级 5(IL5)要求或国际武器贸易条例(ITAR)。
- VPC Service Controls:Interactions API 预览版支持 VPC Service Controls(VPC-SC)以保护 API 边界。
- 数据驻留:Interactions API 预览版不支持数据驻留功能,也不对会话存储作出任何承诺。
- 端点:Interactions API 预览版仅支持全球端点(
locations/global)。
支持的 SDK
你可以使用 Google 统一生成式 AI SDK 或直接通过 REST 调用来访问 Interactions API:
- Python:
google-genai版本2.3.0或更高 - TypeScript / JavaScript:
@google/genai版本2.3.0或更高 - Go:
google.golang.org/genai - Java:
com.google.genai:google-genai
旧版 SDK(google-cloud-aiplatform、@google-cloud/vertexai 和 google-generativeai)不支持 Interactions API。
下一步
- 安装 Google 生成式 AI SDK,并在 Interactions API 开发者指南(https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/capabilities/interactions/developer-guide?hl=pt-br)中发出你的第一个请求。
- 在 Interactions API 快速入门 notebook(https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/getting-started/intro_interactions_api.ipynb)中进行测试。
- 在 Interactions API 参考文档(https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/models/interactions-api?hl=pt-br)中查看方法和资源 schema。
- 了解如何与托管智能体交互(https://docs.cloud.google.com/gemini-enterprise-agent-platform/build/managed-agents/interact-with-agents?hl=pt-br)以及如何使用 Gemini Deep Research Agent(https://docs.cloud.google.com/gemini-enterprise-agent-platform/agents/use-deep-research?hl=pt-br)。
相似文章
@googledevs:Interactions API 现已正式发布(GA),成为构建……的主要接口
Google 针对 Gemini 模型和智能体的 Interactions API 现已正式发布,推出了托管智能体、用于长时间运行任务的背景执行,以及即将支持的 Gemini Omni。
@_philschmid: Gemini Interactions API 更新 随着我们超越简单提示,严格的“user”和“model”角色显得局限。因此……
Google 正在更新 Gemini Interactions API,用灵活的基于步骤的系统(outputs + roles → steps)取代严格的 user/model 角色,引入类似 user_input、thought、function_call、tool_call 和 model_output 的代理步骤。该更新还合并了 response_format 控制,并要求升级 SDK(Python/JS ≥2.0.0)或添加新的 API 标头以选择加入。
@_philschmid: 我很兴奋地介绍 Gemini API 中的托管代理。一次 API 调用即可获得一个完整的代理,具备代码执行、网页浏览…
Phil Schmid 宣布 Gemini API 中的托管代理,支持一次性调用获取包含代码执行、网页浏览和文件管理功能的代理,运行在隔离沙箱中,由 Gemini 3.5 Flash 驱动。
@_philschmid: https://x.com/_philschmid/status/2122358498461691913
Google 推出了 Gemini 4 Carbon 和 Gemini 4 Hydrogen 推理/编程模型,同时还推出了全新的 Gemini Decisions API、Gemini Managed Agents 中的自托管智能体沙箱,以及更多机器人和基因组学模型。
Gemini API 展示代理型 Gemini 模型
Google 的 Gemini API 现已开放代理型模型,使开发者能够构建具备更强推理和行动能力的自主 AI 智能体。