gemini-interactions-api
Skill1 starsChanged 3 months agoApache-2.0View on GitHub
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.
- Reads credentials
- Sends data out
7 other projects use a version of this, 3 of them edited.
Adopted by
Most recently taken up by
- oivanfelipe/claude-skillsword for word, first seen Nov 8, 2026
- Ayuilos/Miffanedited, first seen Nov 2, 2026
- google/skillsedited, first seen Sep 29, 2026
- roshankodi/agent-skillstheir own version, first seen Sep 22, 2026
- dmarafetti/ai-writer-extensionedited, first seen Jul 20, 2026
- danielvogler/ai-skills-librarytheir own version, first seen Jun 3, 2026
Other versions7 projects use a version of this.
Word for word · 1
- oivanfelipe/claude-skills★ 0100% same
Edited · 3
- google/skills★ 24k63% same
- Ayuilos/Miffan★ 30810% same
- dmarafetti/ai-writer-extension★ 010% same
Wrote their own version · 3
- JetBrains/skills★ 386same name
- roshankodi/agent-skills★ 2same name
- danielvogler/ai-skills-library★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository126 other files it gives its agents.
- data-manager-api-audience-ingestionSkill
- data-manager-api-event-ingestionSkill
- data-manager-api-setupSkill
- google-ads-api-account-diagnosticsSkill
- google-ads-api-mcp-setupSkill
- google-ads-api-quickstartSkill
- google-mobile-ads-android-migrate-to-next-genSkill
- google-mobile-ads-bannerSkill
- google-mobile-ads-get-startedSkill
- google-mobile-ads-interstitialSkill
- google-mobile-ads-rewardedSkill
- ima-dai-sdkSkill
- ima-sdk-client-sideSkill
- google-analytics-admin-api-basicsSkill
- google-analytics-data-api-basicsSkill
- agent-platform-alert-configurationSkill
- agent-platform-deploySkill
- agent-platform-endpoint-managementSkill
- agent-platform-eval-flywheelSkill
- agent-platform-inferenceSkill
- agent-platform-migrate-from-ai-studioSkill
- agent-platform-model-registrySkill
- agent-platform-prompt-managementSkill
- agent-platform-rag-engine-managementSkill
- agent-platform-skill-registrySkill
- agent-platform-troubleshootingSkill
- agent-platform-tuning-managementSkill
- agent-platform-tuningSkill
- alloydb-basicsSkill
- application-design-center-design-deploySkill
- bigquery-ai-mlSkill
- bigquery-basicsSkill
- bigquery-bigframesSkill
- bigtable-basicsSkill
- cloud-build-basicsSkill
- cloud-databases-onboardingSkill
- cloud-logging-configuration-basicsSkill
- cloud-logging-cross-project-configurationSkill
- cloud-logging-query-generationSkill
- cloud-monitoring-chart-generationSkill
- cloud-monitoring-list-time-series-requestSkill
- cloud-monitoring-metric-selectionSkill
- cloud-monitoring-promql-querySkill
- cloud-run-basicsSkill
- cloud-sql-basicsSkill
- datalineage-bigquery-asset-impact-analysisSkill
- datalineage-summarySkill
- detection-engineering-coverage-evaluationSkill
- developer-device-platform-basicsSkill
- firebase-basicsSkill
- gcloudSkill
- gemini-agents-apiSkill
- gemini-apiSkill
- gemini-live-apiSkill
- developing-genkit-dartSkill
- developing-genkit-goSkill
- developing-genkit-jsSkill
- developing-genkit-pythonSkill
- gke-ai-troubleshooting-handle-disruption-gpu-tpuSkill
- gke-ai-troubleshooting-jobset-interruptionSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 52
Before running any code, ensure you are authenticated with Application Default Credentials (ADC) and have the necessary API enabled.
- Very specific: line 418
LOCATION: Use global (or custom region if required).
- Very specific: line 569
Prefer this over hand-walking steps[-1].content[0].text, which breaks when the last step is a tool call or a thought.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 & GEAP Targeting * Unified SDK: Use the Google Gen AI SDK (
google-genai >= 2.3.0for Python,@google/genai >= 2.3.0for JS/TS). SDK versions>= 2.0.0are the minimum floor at which the steps schema activates, but>= 2.3.0is the supported/recommended floor. Legacy SDKs likegoogle-cloud-aiplatform,@google-cloud/vertexai, andgoogle-generativeaiare strictly unsupported for Interactions. * Mandatory Instruction: When explaining client initialization or writing import code, you must explicitly state/warn the user that legacy packages likegoogle-cloud-aiplatformorgoogle-generativeaiare strictly unsupported for interactions. * Latest Models Only: Usegemini-3.5-flash(fast, balanced, multimodal — the recommended default),gemini-3.1-pro-preview(complex reasoning, coding, research), orgemini-3.1-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 likegemini-2.5-*,gemini-2.0-*, orgemini-1.5-*are deprecated and unsupported for the Interactions API. * GEAP requires a provisioned agent (no direct base-model calls yet): On Gemini Enterprise Agent Platform (GEAP), direct/base-model calls (model="...") via the Interactions API are not supported yet. You must target a provisioned agent or endpoint with theagent="<AGENT_ID>"parameter instead ofmodel="...". The code examples in this skill useagent=...for this reason. (This is the primary difference from the ai.google.dev documentation for Interactions, which usesmodel=...— whilemodel=...is valid for other Gemini API contexts, it is not supported on the Agent Platform.) Provision an agent per the Agent Platform docs and pass its ID asagent. * Turn-Scoped Parameters: Parameters liketools,system_instruction, andgeneration_configare turn-scoped. They MUST be passed with each interaction request.
1. Authentication
Before running any code, ensure you are authenticated with Application Default Credentials (ADC) and have the necessary API enabled.
Login:
gcloud auth application-default loginEnable 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")TypeScript/JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({
enterprise: {
project: "your-project-id",
location: "global"
}
});3. Core Interactions API Usage
Quick Start (Single-Turn)
Submit a single prompt and read the final text response. Under the modern schema, output content is retrieved from the steps list.
Python
interaction = client.interactions.create(
agent="your-agent-id", # GEAP: target a provisioned agent, not a base model
input="Explain serverless computing in one sentence."
)
# Use the output_text convenience accessor (combined text from the trailing model_output steps)
print(interaction.output_text)TypeScript/JavaScript
const interaction = await ai.interactions.create({
agent: "your-agent-id", // GEAP: target a provisioned agent, not a base model
input: "Explain serverless computing in one sentence."
});
console.log(interaction.output_text);Stateful Conversation (Multi-Turn)
Interactions are stateful by default. Store the conversation state in the cloud and reference it in the subsequent turn using previous_interaction_id.
Python
# Turn 1: Introduce ourselves
# Interactions are stored by default (store=True); pass store=False to disable
# server-side retention (which also disables previous_interaction_id and background).
turn1 = client.interactions.create(
agent="your-agent-id",
input="Hi! My name is John. I am working on AI agents.",
store=True
)
print(f"Turn 1: {turn1.output_text}")
# Turn 2: Refer back to the stored turn state
turn2 = client.interactions.create(
agent="your-agent-id",
input="What is my name?",
previous_interaction_id=turn1.id
)
print(f"Turn 2: {turn2.output_text}")TypeScript/JavaScript
// Turn 1 (interactions are stored by default; pass store: false to disable)
const turn1 = await ai.interactions.create({
agent: "your-agent-id",
input: "Hi! My name is John. I am working on AI agents.",
store: true
});
// Turn 2
const turn2 = await ai.interactions.create({
agent: "your-agent-id",
input: "What is my name?",
previousInteractionId: turn1.id
});
console.log(turn2.output_text);Real-Time Streaming
Stream responses in real-time. Passing stream=True returns an iterable chunk generator.
Python
# The stream yields typed events, not full interaction snapshots. The sequence is:
# interaction.created -> (step.start -> step.delta(s) -> step.stop)+ -> interaction.completed
for event in client.interactions.create(
agent="your-agent-id",
input="Write a short poem about debugging.",
stream=True
):
if event.event_type == "step.delta":
if event.delta.type == "text":
print(event.delta.text, end="", flush=True)
elif event.event_type == "interaction.completed":
print()TypeScript/JavaScript
// The stream yields typed events, not full interaction snapshots. The sequence is:
// interaction.created -> (step.start -> step.delta(s) -> step.stop)+ -> interaction.completed
const responseStream = await ai.interactions.create({
agent: "your-agent-id",
input: "Write a short poem about debugging.",
stream: true
});
for await (const event of responseStream) {
if (event.event_type === "step.delta") {
if (event.delta.type === "text") {
process.stdout.write(event.delta.text);
}
} else if (event.event_type === "interaction.completed") {
console.log();
}
}Structured Output (Pydantic / Polymorphic response_format)
Retrieve structured, type-safe JSON matching a schema. Under the modern Interactions API, a polymorphic response_format argument directly takes the target schema structure.
Python
from pydantic import BaseModel, Field
class Book(BaseModel):
title: str = Field(description="The title of the book")
author: str = Field(description="The book's author")
year_published: int
interaction = client.interactions.create(
agent="your-agent-id",
input="Recommend one famous sci-fi book.",
response_format=Book
)
# The text will be a valid JSON matching the Book schema
print(interaction.output_text)TypeScript/JavaScript
import { Type } from "@google/genai";
const BookSchema = {
type: Type.OBJECT,
properties: {
title: { type: Type.STRING, description: "The title of the book" },
author: { type: Type.STRING, description: "The book's author" },
yearPublished: { type: Type.INTEGER }
},
required: ["title", "author", "yearPublished"]
};
const interaction = await ai.interactions.create({
agent: "your-agent-id",
input: "Recommend one famous sci-fi book.",
responseFormat: BookSchema
});
console.log(interaction.output_text);Function Calling (Agent Tool Use)
Define local tools (functions) and submit execution results to the stateful interaction history.
Python
import json
def get_stock_price(ticker: str) -> float:
"""Gets the stock price for a given ticker symbol."""
if ticker.upper() == "GOOG":
return 175.50
return 100.0
# Turn 1: Pass tools to the model
interaction = client.interactions.create(
agent="your-agent-id",
input="What is the stock price of GOOG?",
tools=[get_stock_price]
)
# In the flat steps schema, a tool request is a top-level step of type
# "function_call" with flat `name` and `arguments` fields (no nested tool_calls).
for step in interaction.steps:
if step.type == "function_call" and step.name == "get_stock_price":
ticker_arg = step.arguments.get("ticker")
price = get_stock_price(ticker_arg)
# Turn 2: Submit the result back as a function_result step. Reference the
# originating call via call_id=step.id, and pass tools again (turn-scoped).
final_turn = client.interactions.create(
agent="your-agent-id",
input=[
{
"type": "function_result",
"name": step.name,
"call_id": step.id,
"result": [{"type": "text", "text": json.dumps(price)}],
}
],
tools=[get_stock_price],
previous_interaction_id=interaction.id
)
print(final_turn.output_text)TypeScript/JavaScript
import { Type } from "@google/genai";
// Define local tool
function getStockPrice({ ticker }: { ticker: string }): number {
if (ticker.toUpperCase() === "GOOG") {
return 175.50;
}
return 100.00;
}
// Turn 1: Pass tools to the model
const toolDeclaration = {
functionDeclarations: [{
name: "getStockPrice",
description: "Gets the stock price for a given ticker symbol.",
parameters: {
type: Type.OBJECT,
properties: {
ticker: { type: Type.STRING, description: "The stock ticker symbol" }
},
required: ["ticker"]
}
}]
};
const interaction = await ai.interactions.create({
agent: "your-agent-id",
input: "What is the stock price of GOOG?",
tools: [toolDeclaration]
});
// In the flat steps schema, a tool request is a top-level step of type
// "function_call" with flat `name` and `arguments` fields (no nested toolCalls).
const fcStep = interaction.steps.find(s => s.type === "function_call");
if (fcStep && fcStep.name === "getStockPrice") {
const tickerArg = fcStep.arguments.ticker as string;
const price = getStockPrice({ ticker: tickerArg });
// Turn 2: Submit the result back as a function_result step. Reference the
// originating call via call_id=fcStep.id, and pass tools again (turn-scoped).
const finalTurn = await ai.interactions.create({
agent: "your-agent-id",
input: [{
type: "function_result",
name: fcStep.name,
call_id: fcStep.id,
result: [{ type: "text", text: JSON.stringify(price) }]
}],
tools: [toolDeclaration],
previousInteractionId: interaction.id
});
console.log(finalTurn.output_text);
}4. Accessing the Interactions API via REST
For shell-based scripts, debugging, or non-Python/JS environments, you can communicate with the stateful Interactions API directly using raw HTTP/REST requests via curl.
1. REST Endpoint
The REST API endpoint for interactions is:
POST https://aiplatform.googleapis.com/v1beta1/projects/{PROJECT_ID}/locations/{LOCATION}/interactions- LOCATION: Use
global(or custom region if required). - PROJECT_ID: Your Google Cloud Project ID.
2. Set up Variables & Authentication Header
Set your target agent ID (e.g., model or custom agent path) and access token generated from Application Default Credentials:
AGENT_ID="your-agent-id"
ACCESS_TOKEN=$(gcloud auth print-access-token)3. Single-Turn Interaction Payload
Send a request to start an interaction using the agent variable:
curl -X POST "https://aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/global/interactions" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"agent": "'"${AGENT_ID}"'",
"input": [{
"type": "user_input",
"content": [{
"type": "text",
"text": "Explain serverless computing in one sentence."
}]
}]
}'Response Example
A synchronous POST request returns a JSON object containing the conversation step details and unique identifiers:
{
"id": "your-interaction-id",
"status": "completed",
"steps": [
{
"type": "model_output",
"content": [
{
"type": "text",
"text": "Serverless computing is a cloud execution model where the cloud provider dynamically manages the allocation and provisioning of servers, charging customers based on actual usage rather than pre-purchased capacity."
}
]
}
],
"usage": {
"total_tokens": 24751,
"total_input_tokens": 23894,
"total_output_tokens": 857
},
"created": "2026-05-08T10:44:43Z",
"updated": "2026-05-08T10:44:43Z",
"environment_id": "your-environment-id",
"object": "interaction"
}4. Multi-Turn Stateful Interaction Payload
To continue an existing conversation statefully, specify the previous_interaction_id in the JSON payload:
curl -X POST "https://aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/global/interactions" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"agent": "'"${AGENT_ID}"'",
"store": true,
"previous_interaction_id": "YOUR_PREVIOUS_INTERACTION_ID",
"input": [{
"type": "user_input",
"content": [{
"type": "text",
"text": "Can you elaborate on that?"
}]
}]
}'5. Streaming Output Payload
To stream updates in real time (Server-Sent Events format), pass "stream": true in the payload:
curl -X POST "https://aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/global/interactions" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"agent": "'"${AGENT_ID}"'",
"stream": true,
"input": [{
"type": "user_input",
"content": [{
"type": "text",
"text": "Write a long story about space travel."
}]
}]
}'The endpoint will return a chunked stream where each event begins with data: containing JSON updates with the event_type and step contents.
How
curlhandles streaming: By default, when"stream": trueis passed, the server responds withTransfer-Encoding: chunkedandContent-Type: text/event-stream(Server-Sent Events).curlwill automatically keep the connection open and print the incoming data chunks tostdoutin real time as they are pushed by the server. The user does not need to poll or pull further; the complete sequence of events streams continuously until completion.
5. Data Model & Step Types Reference
An Interaction response contains steps, an array of typed step objects
representing a structured timeline of the interaction turn. Read the current
step type rather than assuming the last step is text — the trailing step may
be a function_call or a thought.
Step Types
User steps:
user_input: User input (text, audio, multimodal). Contains acontentarray. (This is why REST input payloads use"type": "user_input", not"role": "user".)
Model/server steps:
model_output: Final model generation. Contains acontentarray withtext,image,audio, etc. (REST responses use"type": "model_output", not"role": "model".)thought: Model reasoning / chain of thought. Has asignaturefield and optionalsummary.function_call: Tool call request, with flatid,name, andargumentsfields (there is no nestedtool_callslist).function_result: Tool result you send back, withcall_id,name, andresultfields.google_search_call/google_search_result,code_execution_call/code_execution_result,url_context_call/url_context_result,mcp_server_tool_call/mcp_server_tool_result,file_search_call/file_search_result: built-in and remote tool steps.
Content types (inside the content array on model_output and user_input steps)
text: Text content (textfield).image/audio/document/video: Content withdata,mime_type, oruri.
Convenience accessor
output_text: The combined text from the trailingmodel_outputsteps. Prefer this over hand-walkingsteps[-1].content[0].text, which breaks when the last step is a tool call or a thought.
Streaming Event Types
| Event | Description |
interaction.created | Interaction created; includes metadata. |
step.start | A new step begins. Contains the step type and |
| : : initial metadata. : | |
step.delta | Incremental data for the current step. Contains a |
: : typed delta object (e.g. delta.type == "text" : | |
: : with delta.text). : | |
step.stop | The step is complete. Contains index. |
interaction.completed | Interaction finished. Contains final usage. |
Storage & retention
Interactions are stored by default (store=True), which enables stateful
features like previous_interaction_id and background execution. Passing
store=False disables server-side retention and therefore also disables
previous_interaction_id and background — in that mode you must pass the full
conversation history in input on each turn.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

