跳到正文
Skillpedia
智能体22k · #10262

gemini-interactions-api

它能做什么

这个技能指导开发者使用 Google 有状态的 Gemini Interactions API,由平台替他们保存对话。它适用于构建多步骤对话和后台研究的团队。

适用场景

  • ✓当你想运行一段由平台保存历史记录的多轮对话的时候。
  • ✓当你需要后台研究任务,或来自 Gemini 的流式回复的时候。
  • ✓当你想通过 Interactions API 获得结构化输出或函数调用的时候。

技能链接

https://github.com/google/skills/blob/main/skills/cloud/gemini-interactions-api/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/google/skills/blob/main/skills/cloud/gemini-interactions-api/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请在 Google Cloud 上构建一个能记住前面消息、并能在后台运行研究任务的 Gemini 聊天。”

每周 5 个新技能,1 分钟读完。

工作原理

它说明如何通过 Google Gen AI SDK 进行认证、连接并使用 Interactions API。它推荐最新的 Gemini 模型,并提醒不要使用不受支持的旧软件包。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Gemini Interactions API Skill

This skill provides instructions for authenticating, connecting to, and utilizing the stateful, server-managed Gemini Interactions API on Gemini Enterprise Agent Platform.

The Interactions API is the modern, recommended way to execute Generative AI agent conversations, background research tasks, multi-turn chats, and structured, multi-step workflows.

[!IMPORTANT] CRITICAL: Unified SDK, Latest Models & Model/Agent Targeting * Unified SDK: Use the Google Gen AI SDK (google-genai >= 2.3.0 for Python, @google/genai >= 2.3.0 for JS/TS). SDK versions >= 2.0.0 are the minimum floor at which the steps schema activates, but >= 2.3.0 is the supported/recommended floor. Legacy SDKs like google-cloud-aiplatform, @google-cloud/vertexai, google-generativeai, and @google/generative-ai are strictly unsupported for Interactions. * Mandatory Instruction: When explaining client initialization or writing import code, you must explicitly state/warn the user that legacy packages like google-cloud-aiplatform or google-generativeai are strictly unsupported for interactions. * Latest Models Only: Use gemini-3.8-flash (fast, balanced, multimodal — the recommended default), gemini-3.1-pro-preview (complex reasoning, coding, research), or gemini-3.5-flash-lite (cost-efficient, high-frequency lightweight tasks). Refer to the latest model versions to check for new updates. Legacy models (gemini-3-flash-preview, gemini-2.5-*, gemini-2.0-*, gemini-1.5-*) are deprecated and do not support interactions. * Mandatory Instruction: In any interaction response, you must warn the user that legacy models like gemini-2.5-*, gemini-2.0-*, or gemini-1.5-* are deprecated and unsupported for the Interactions API. If a user asks for a deprecated model, use gemini-3.8-flash instead and note the substitution. * Model & Agent Targeting: Target foundation models directly using model="gemini-3.8-flash", or target autonomous managed/custom agents (antigravity-preview-05-2026, deep-research-preview-04-2026, or custom agents provisioned via client.agents.create()) using agent="<AGENT_ID>". Managed agents (antigravity-preview-05-2026 and custom agents) require environment="remote" to provision a sandbox. * Turn-Scoped Parameters: Parameters like tools, system_instruction, and generation_config are turn-scoped. They MUST be passed with each interaction request.

Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read Usage Attribution. For commands executed directly in the terminal (never in generated scripts, Terraform, or user code), prefix gcloud with CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gemini-interactions-api)" and append agent-skills/1.0 (skill:gemini-interactions-api) to User-Agent headers.

1. Authentication

Before running any code, ensure you are authenticated with Application Default Credentials (ADC) and have the necessary API enabled.

  1. Login:

    gcloud auth application-default login
    
  2. Enable API (if not already enabled):

    gcloud services enable aiplatform.googleapis.com
    

2. Client Initialization

You can initialize the client using environment variables (recommended) or by passing explicit configuration parameters.

Option A: Environment Variables (Recommended)

Configure environment variables to let the SDK automatically resolve settings:

export GOOGLE_GENAI_USE_ENTERPRISE=true
export GOOGLE_CLOUD_PROJECT="your-project-id"
export GOOGLE_CLOUD_LOCATION="global"

Python

from google import genai

# The SDK automatically picks up the environment variables
client = genai.Client()

TypeScript/JavaScript

import { GoogleGenAI } from "@google/genai";

// The SDK automatically picks up the environment variables
const ai = new GoogleGenAI();

Option B: Explicit Inline Parameters

Alternatively, pass configuration values directly inside your code:

Python

from google import genai
import google.auth

_, project_id = google.auth.default()
client = genai.Client(enterprise=True, project=project_id, location="global")

Typ

常见问题

需要哪个 SDK 版本?

Python 的 google-genai 需 2.3.0 或更高版本,JavaScript 的 @google/genai 需 2.3.0 或更高版本。

它支持旧的 Vertex 软件包吗?

不支持。像 google-cloud-aiplatform 这样的软件包不支持 Interactions。

它处理流式传输吗?

处理。它涵盖流式响应。

详情

作者的原始描述

Guides the usage of Gemini Interactions API on Gemini Enterprise Agent Platform. Use when the user wants to use the stateful, server-managed Interactions API for multi-turn conversations, background execution, streaming, structured output, and function calling on the Agent Platform.

repo: google/skills

热度

GitHub 星标
22k
排名
#10262
许可证
Apache-2.0
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能