[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D6VSDFVD49XYYDW4X5DV2N":3,"skill-same:01M7D6VSDFVD49XYYDW4X5DV2N":73},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":28,"commitSha":29,"skillDirectory":5,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M7D6VSDFVD49XYYDW4X5DV2N","gemini-interactions-api",null,"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.","tangyixiao\u002Ftangyixiao-skills","tangyixiao","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F115929632?v=4","01M7D582YK6A4M63CAK4CSY4EW","Tang Yixiao","01M7D582Z64DMRSYR872SR34SA",2,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fgemini-interactions-api\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fgemini-interactions-api\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: gemini-interactions-api\nmetadata:\n  version: 2.0.2\n  category: AiAndMachineLearning\ndescription: Guides the usage of Gemini Interactions API on Gemini Enterprise Agent\n  Platform. Use when the user wants to use the stateful, server-managed Interactions\n  API for multi-turn conversations, background execution, streaming, structured output,\n  and function calling on the Agent Platform.\n---\n\n# Gemini Interactions API Skill\n\nThis skill provides instructions for authenticating, connecting to, and utilizing the stateful, server-managed **Gemini Interactions API** on Gemini Enterprise Agent Platform.\n\n\nThe Interactions API is the modern, recommended way to execute Generative AI agent conversations, background research tasks, multi-turn chats, and structured, multi-step workflows.\n\n> [!IMPORTANT] **CRITICAL: Unified SDK, Latest Models & Model\u002FAgent Targeting** *\n> **Unified SDK**: Use the Google Gen AI SDK (**`google-genai >= 2.3.0`** for\n> Python, **`@google\u002Fgenai >= 2.3.0`** for JS\u002FTS). SDK versions `>= 2.0.0` are\n> the minimum floor at which the steps schema activates, but `>= 2.3.0` is the\n> supported\u002Frecommended floor. Legacy SDKs like `google-cloud-aiplatform`,\n> `@google-cloud\u002Fvertexai`, `google-generativeai`, and `@google\u002Fgenerative-ai`\n> are strictly unsupported for Interactions. * *Mandatory Instruction*: When\n> explaining client initialization or writing import code, you **must**\n> explicitly state\u002Fwarn the user that legacy packages like\n> `google-cloud-aiplatform` or `google-generativeai` are strictly unsupported\n> for interactions. * **Latest Models Only**: Use `gemini-3.8-flash` (fast,\n> balanced, multimodal — the recommended default), `gemini-3.1-pro-preview`\n> (complex reasoning, coding, research), or `gemini-3.5-flash-lite`\n> (cost-efficient, high-frequency lightweight tasks). Refer to the\n> [latest model versions](https:\u002F\u002Fdocs.cloud.google.com\u002Fgemini-enterprise-agent-platform\u002Fmodels\u002Fmigrate)\n> to check for new updates. Legacy models (`gemini-3-flash-preview`,\n> `gemini-2.5-*`, `gemini-2.0-*`, `gemini-1.5-*`) are deprecated and do not\n> support interactions. * *Mandatory Instruction*: In any interaction response,\n> you **must** warn the user that legacy models like `gemini-2.5-*`,\n> `gemini-2.0-*`, or `gemini-1.5-*` are deprecated and unsupported for the\n> Interactions API. If a user asks for a deprecated model, use\n> `gemini-3.8-flash` instead and note the substitution. * **Model & Agent\n> Targeting**: Target foundation models directly using\n> `model=\"gemini-3.8-flash\"`, or target autonomous managed\u002Fcustom agents\n> (`antigravity-preview-09-2026`, `deep-research-preview-04-2026`, or custom\n> agents provisioned via `client.agents.create()`) using `agent=\"\u003CAGENT_ID>\"`.\n> Managed agents (`antigravity-preview-09-2026` and custom agents) require\n> `environment=\"remote\"` to provision a sandbox. * **Turn-Scoped Parameters**:\n> Parameters like `tools`, `system_instruction`, and `generation_config` are\n> turn-scoped. They **MUST** be passed with each interaction request.\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read [Usage Attribution](references\u002Fattribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with\n`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\u002F1.0 (skill:gemini-interactions-api)\"`\nand append\n`agent-skills\u002F1.0 (skill:gemini-interactions-api)`\nto `User-Agent` headers.\n\n## 1. Authentication\n\nBefore running any code, ensure you are authenticated with Application Default Credentials (ADC) and have the necessary API enabled.\n\n1.  **Login**:\n    \n    ```bash\n    gcloud auth application-default login\n    ```\n2.  **Enable API** (if not already enabled):\n    \n    ```bash\n    gcloud services enable aiplatform.googleapis.com\n    ```\n\n---\n\n## 2. Client Initialization\n\nYou can initialize the client using environment variables (recommended) or by passing explicit configuration parameters.\n\n### Option A: Environment Variables (Recommended)\n\nConfigure environment variables to let the SDK automatically resolve settings:\n\n```bash\nexport GOOGLE_GENAI_USE_ENTERPRISE=true\nexport GOOGLE_CLOUD_PROJECT=\"your-project-id\"\nexport GOOGLE_CLOUD_LOCATION=\"global\"\n```\n\n#### Python\n\n```python\nfrom google import genai\n\n# The SDK automatically picks up the environment variables\nclient = genai.Client()\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nimport { GoogleGenAI } from \"@google\u002Fgenai\";\n\n\u002F\u002F The SDK automatically picks up the environment variables\nconst ai = new GoogleGenAI();\n```\n\n### Option B: Explicit Inline Parameters\n\nAlternatively, pass configuration values directly inside your code:\n\n#### Python\n\n```python\nfrom google import genai\nimport google.auth\n\n_, project_id = google.auth.default()\nclient = genai.Client(enterprise=True, project=project_id, location=\"global\")\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nimport { GoogleGenAI } from \"@google\u002Fgenai\";\n\nconst ai = new GoogleGenAI({\n    enterprise: true,\n    project: \"your-project-id\",\n    location: \"global\"\n});\n```\n\n### Option C: Express Mode (API Key)\n\nRecommended for lightweight scripts or environments using an API key:\n\n#### Python\n\n```python\nfrom google import genai\n\nclient = genai.Client(enterprise=True, api_key=\"YOUR_API_KEY\")\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nimport { GoogleGenAI } from \"@google\u002Fgenai\";\n\nconst ai = new GoogleGenAI({\n    enterprise: true,\n    apiKey: \"YOUR_API_KEY\"\n});\n```\n\n---\n\n## 3. Core Interactions API Usage\n\n### Quick Start (Single-Turn)\n\nSubmit a single prompt and read the final text response. Under the modern schema, output content is retrieved from the `steps` list.\n\n#### Python\n\n```python\ninteraction = client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"Explain serverless computing in one sentence.\"\n)\n# Use the output_text convenience accessor (combined text from the trailing model_output steps)\nprint(interaction.output_text)\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nconst interaction = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"Explain serverless computing in one sentence.\"\n});\nconsole.log(interaction.output_text);\n```\n\n---\n\n### Stateful Conversation (Multi-Turn)\n\nInteractions are stateful by default. Store the conversation state in the cloud and reference it in the subsequent turn using `previous_interaction_id`.\n\n#### Python\n\n```python\n# Turn 1: Introduce ourselves\n# Interactions are stored by default (store=True, retained for 7 days); pass store=False to disable\n# server-side retention (which also disables previous_interaction_id and background).\nturn1 = client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"Hi! My name is John. I am working on AI agents.\",\n    store=True\n)\nprint(f\"Turn 1: {turn1.output_text}\")\n\n# Turn 2: Refer back to the stored turn state\nturn2 = client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"What is my name?\",\n    previous_interaction_id=turn1.id\n)\nprint(f\"Turn 2: {turn2.output_text}\")\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\n\u002F\u002F Turn 1 (interactions are stored by default; pass store: false to disable)\nconst turn1 = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"Hi! My name is John. I am working on AI agents.\",\n    store: true\n});\n\n\u002F\u002F Turn 2\nconst turn2 = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"What is my name?\",\n    previous_interaction_id: turn1.id\n});\nconsole.log(turn2.output_text);\n```\n\n---\n\n### Real-Time Streaming\n\nStream responses in real-time. Passing `stream=True` returns an iterable chunk generator.\n\n#### Python\n\n```python\n# The stream yields typed events, not full interaction snapshots. The sequence is:\n# interaction.created -> (step.start -> step.delta(s) -> step.stop)+ -> interaction.completed\nfor event in client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"Write a short poem about debugging.\",\n    stream=True\n):\n    if event.event_type == \"step.delta\":\n        if event.delta.type == \"text\":\n            print(event.delta.text, end=\"\", flush=True)\n    elif event.event_type == \"interaction.completed\":\n        print()\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\n\u002F\u002F The stream yields typed events, not full interaction snapshots. The sequence is:\n\u002F\u002F interaction.created -> (step.start -> step.delta(s) -> step.stop)+ -> interaction.completed\nconst responseStream = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"Write a short poem about debugging.\",\n    stream: true\n});\n\nfor await (const event of responseStream) {\n    if (event.event_type === \"step.delta\") {\n        if (event.delta.type === \"text\") {\n            process.stdout.write(event.delta.text);\n        }\n    } else if (event.event_type === \"interaction.completed\") {\n        console.log();\n    }\n}\n```\n\n---\n\n### Structured Output (Pydantic \u002F Polymorphic `response_format`)\n\nRetrieve structured, type-safe JSON matching a schema. Under the modern Interactions API, a polymorphic `response_format` argument directly takes the target schema structure.\n\n#### Python\n\n```python\nfrom pydantic import BaseModel, Field\n\nclass Book(BaseModel):\n    title: str = Field(description=\"The title of the book\")\n    author: str = Field(description=\"The book's author\")\n    year_published: int\n\ninteraction = client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"Recommend one famous sci-fi book.\",\n    response_format=Book\n)\n\n# The text will be a valid JSON matching the Book schema\nprint(interaction.output_text)\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nimport { Type } from \"@google\u002Fgenai\";\n\nconst BookSchema = {\n    type: Type.OBJECT,\n    properties: {\n        title: { type: Type.STRING, description: \"The title of the book\" },\n        author: { type: Type.STRING, description: \"The book's author\" },\n        yearPublished: { type: Type.INTEGER }\n    },\n    required: [\"title\", \"author\", \"yearPublished\"]\n};\n\nconst interaction = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"Recommend one famous sci-fi book.\",\n    response_format: BookSchema\n});\n\nconsole.log(interaction.output_text);\n```\n\n---\n\n### Function Calling (Agent Tool Use)\n\nDefine local tools (functions) and submit execution results to the stateful interaction history.\n\n#### Python\n\n```python\nimport json\n\ndef get_stock_price(ticker: str) -> float:\n    \"\"\"Gets the stock price for a given ticker symbol.\"\"\"\n    if ticker.upper() == \"GOOG\":\n        return 175.50\n    return 100.0\n\n# Turn 1: Pass tools to the model\ninteraction = client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"What is the stock price of GOOG?\",\n    tools=[get_stock_price]\n)\n\n# In the flat steps schema, a tool request is a top-level step of type\n# \"function_call\" with flat `name` and `arguments` fields (no nested tool_calls).\nfor step in interaction.steps:\n    if step.type == \"function_call\" and step.name == \"get_stock_price\":\n        ticker_arg = step.arguments.get(\"ticker\")\n        price = get_stock_price(ticker_arg)\n\n        # Turn 2: Submit the result back as a function_result step. Reference the\n        # originating call via call_id=step.id, and pass tools again (turn-scoped).\n        final_turn = client.interactions.create(\n            model=\"gemini-3.8-flash\",\n            input=[\n                {\n                    \"type\": \"function_result\",\n                    \"name\": step.name,\n                    \"call_id\": step.id,\n                    \"result\": [{\"type\": \"text\", \"text\": json.dumps(price)}],\n                }\n            ],\n            tools=[get_stock_price],\n            previous_interaction_id=interaction.id\n        )\n        print(final_turn.output_text)\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\n\u002F\u002F Define local tool and flat function tool declaration\nfunction getStockPrice({ ticker }: { ticker: string }): number {\n    if (ticker.toUpperCase() === \"GOOG\") {\n        return 175.50;\n    }\n    return 100.00;\n}\n\nconst stockTool = {\n    type: \"function\",\n    name: \"getStockPrice\",\n    description: \"Gets the stock price for a given ticker symbol.\",\n    parameters: {\n        type: \"object\",\n        properties: {\n            ticker: { type: \"string\", description: \"The stock ticker symbol\" }\n        },\n        required: [\"ticker\"]\n    }\n};\n\n\u002F\u002F Turn 1: Pass tools to the model\nconst interaction = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"What is the stock price of GOOG?\",\n    tools: [stockTool]\n});\n\n\u002F\u002F In the flat steps schema, a tool request is a top-level step of type\n\u002F\u002F \"function_call\" with flat `name` and `arguments` fields (no nested toolCalls).\nconst fcStep = interaction.steps.find(s => s.type === \"function_call\");\nif (fcStep && fcStep.name === \"getStockPrice\") {\n    const tickerArg = fcStep.arguments.ticker as string;\n    const price = getStockPrice({ ticker: tickerArg });\n\n    \u002F\u002F Turn 2: Submit the result back as a function_result step. Reference the\n    \u002F\u002F originating call via call_id=fcStep.id, and pass tools again (turn-scoped).\n    const finalTurn = await ai.interactions.create({\n        model: \"gemini-3.8-flash\",\n        input: [{\n            type: \"function_result\",\n            name: fcStep.name,\n            call_id: fcStep.id,\n            result: [{ type: \"text\", text: JSON.stringify(price) }]\n        }],\n        tools: [stockTool],\n        previous_interaction_id: interaction.id\n    });\n    console.log(finalTurn.output_text);\n}\n```\n\n---\n\n### Agents & Long-Running Tasks\n\nBeyond foundation models, the Interactions API provides access to specialized, autonomous agents via the `agent` parameter:\n\n*   **`antigravity-preview-09-2026`**: Antigravity Agent — general-purpose\n    managed agent with code execution, file management, and web browsing in a\n    secure sandboxed Linux environment (pass `environment=\"remote\"` to\n    provision a sandbox).\n*   **`deep-research-preview-04-2026`**: Deep Research Agent — executes multi-step web research tasks, synthesizing information from multiple sources into comprehensive reports.\n*   **Custom agents**: Configured and managed via `client.agents.create()`, `list()`, `get()`, and `delete()` (pass `environment=\"remote\"` when invoking).\n\nAgents typically run asynchronously in the background using `background=True`. Poll the interaction status to retrieve the completed result:\n\n#### Python\n\n```python\nimport time\n\ninteraction = client.interactions.create(\n    input=\"Analyze competitive positioning for solar energy providers.\",\n    agent=\"deep-research-preview-04-2026\",\n    background=True\n)\nprint(f\"Research started: {interaction.id}\")\n\nwhile True:\n    interaction = client.interactions.get(interaction.id)\n    if interaction.status == \"completed\":\n        print(interaction.output_text)\n        break\n    elif interaction.status in (\"failed\", \"cancelled\"):\n        print(f\"Research ended with status: {interaction.status}\")\n        break\n    time.sleep(10)\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nconst initialInteraction = await ai.interactions.create({\n    agent: \"deep-research-preview-04-2026\",\n    input: \"Analyze competitive positioning for solar energy providers.\",\n    background: true\n});\n\nwhile (true) {\n    const interaction = await ai.interactions.get(initialInteraction.id);\n    if (interaction.status === \"completed\") {\n        console.log(interaction.output_text);\n        break;\n    } else if ([\"failed\", \"cancelled\"].includes(interaction.status)) {\n        console.log(`Research ended with status: ${interaction.status}`);\n        break;\n    }\n    await new Promise(resolve => setTimeout(resolve, 10000));\n}\n```\n\n---\n\n## 4. Accessing the Interactions API via REST\n\nFor shell-based scripts, debugging, or non-Python\u002FJS environments, communicate with the stateful Interactions API over HTTP\u002FREST (`curl`) at `POST https:\u002F\u002Faiplatform.googleapis.com\u002Fv1beta1\u002Fprojects\u002F{PROJECT_ID}\u002Flocations\u002F{LOCATION}\u002Finteractions` (or `POST https:\u002F\u002Faiplatform.googleapis.com\u002Fv1beta1\u002Flocations\u002Fglobal\u002Finteractions` with `x-goog-api-key` for Express Mode). Pass `\"model\"` or `\"agent\"`, `\"input\"` steps with `\"type\": \"user_input\"`, and optional `\"previous_interaction_id\"`, `\"background\": true`, or `\"stream\": true` (which streams Server-Sent Events via `Content-Type: text\u002Fevent-stream` and `Transfer-Encoding: chunked` that `curl` prints continuously in real time).\n\nFor complete `curl` examples (single-turn, multi-turn stateful, SSE streaming, and background managed agents) and response schemas, read [references\u002Frest_api.md](references\u002Frest_api.md).\n\n---\n\n## 5. Data Model & Step Types Reference\n\nAn `Interaction` response contains a flat `steps` timeline (`user_input`, `model_output`, `thought`, `function_call`, `function_result`, and built-in tool steps) along with convenience accessors (`output_text`, `output_image`, `output_audio`) and SSE streaming events (`interaction.created`, `step.start`, `step.delta`, `step.stop`, `interaction.completed`).\n\nFor the complete step types, content types, streaming event table, and 7-day retention rules, read [references\u002Fdata_model.md](references\u002Fdata_model.md).\n\n","# Gemini Interactions API Skill\n\nThis skill provides instructions for authenticating, connecting to, and utilizing the stateful, server-managed **Gemini Interactions API** on Gemini Enterprise Agent Platform.\n\n\nThe Interactions API is the modern, recommended way to execute Generative AI agent conversations, background research tasks, multi-turn chats, and structured, multi-step workflows.\n\n> [!IMPORTANT] **CRITICAL: Unified SDK, Latest Models & Model\u002FAgent Targeting** *\n> **Unified SDK**: Use the Google Gen AI SDK (**`google-genai >= 2.3.0`** for\n> Python, **`@google\u002Fgenai >= 2.3.0`** for JS\u002FTS). SDK versions `>= 2.0.0` are\n> the minimum floor at which the steps schema activates, but `>= 2.3.0` is the\n> supported\u002Frecommended floor. Legacy SDKs like `google-cloud-aiplatform`,\n> `@google-cloud\u002Fvertexai`, `google-generativeai`, and `@google\u002Fgenerative-ai`\n> are strictly unsupported for Interactions. * *Mandatory Instruction*: When\n> explaining client initialization or writing import code, you **must**\n> explicitly state\u002Fwarn the user that legacy packages like\n> `google-cloud-aiplatform` or `google-generativeai` are strictly unsupported\n> for interactions. * **Latest Models Only**: Use `gemini-3.8-flash` (fast,\n> balanced, multimodal — the recommended default), `gemini-3.1-pro-preview`\n> (complex reasoning, coding, research), or `gemini-3.5-flash-lite`\n> (cost-efficient, high-frequency lightweight tasks). Refer to the\n> [latest model versions](https:\u002F\u002Fdocs.cloud.google.com\u002Fgemini-enterprise-agent-platform\u002Fmodels\u002Fmigrate)\n> to check for new updates. Legacy models (`gemini-3-flash-preview`,\n> `gemini-2.5-*`, `gemini-2.0-*`, `gemini-1.5-*`) are deprecated and do not\n> support interactions. * *Mandatory Instruction*: In any interaction response,\n> you **must** warn the user that legacy models like `gemini-2.5-*`,\n> `gemini-2.0-*`, or `gemini-1.5-*` are deprecated and unsupported for the\n> Interactions API. If a user asks for a deprecated model, use\n> `gemini-3.8-flash` instead and note the substitution. * **Model & Agent\n> Targeting**: Target foundation models directly using\n> `model=\"gemini-3.8-flash\"`, or target autonomous managed\u002Fcustom agents\n> (`antigravity-preview-09-2026`, `deep-research-preview-04-2026`, or custom\n> agents provisioned via `client.agents.create()`) using `agent=\"\u003CAGENT_ID>\"`.\n> Managed agents (`antigravity-preview-09-2026` and custom agents) require\n> `environment=\"remote\"` to provision a sandbox. * **Turn-Scoped Parameters**:\n> Parameters like `tools`, `system_instruction`, and `generation_config` are\n> turn-scoped. They **MUST** be passed with each interaction request.\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read [Usage Attribution](references\u002Fattribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with\n`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\u002F1.0 (skill:gemini-interactions-api)\"`\nand append\n`agent-skills\u002F1.0 (skill:gemini-interactions-api)`\nto `User-Agent` headers.\n\n## 1. Authentication\n\nBefore running any code, ensure you are authenticated with Application Default Credentials (ADC) and have the necessary API enabled.\n\n1.  **Login**:\n    \n    ```bash\n    gcloud auth application-default login\n    ```\n2.  **Enable API** (if not already enabled):\n    \n    ```bash\n    gcloud services enable aiplatform.googleapis.com\n    ```\n\n---\n\n## 2. Client Initialization\n\nYou can initialize the client using environment variables (recommended) or by passing explicit configuration parameters.\n\n### Option A: Environment Variables (Recommended)\n\nConfigure environment variables to let the SDK automatically resolve settings:\n\n```bash\nexport GOOGLE_GENAI_USE_ENTERPRISE=true\nexport GOOGLE_CLOUD_PROJECT=\"your-project-id\"\nexport GOOGLE_CLOUD_LOCATION=\"global\"\n```\n\n#### Python\n\n```python\nfrom google import genai\n\n# The SDK automatically picks up the environment variables\nclient = genai.Client()\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nimport { GoogleGenAI } from \"@google\u002Fgenai\";\n\n\u002F\u002F The SDK automatically picks up the environment variables\nconst ai = new GoogleGenAI();\n```\n\n### Option B: Explicit Inline Parameters\n\nAlternatively, pass configuration values directly inside your code:\n\n#### Python\n\n```python\nfrom google import genai\nimport google.auth\n\n_, project_id = google.auth.default()\nclient = genai.Client(enterprise=True, project=project_id, location=\"global\")\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nimport { GoogleGenAI } from \"@google\u002Fgenai\";\n\nconst ai = new GoogleGenAI({\n    enterprise: true,\n    project: \"your-project-id\",\n    location: \"global\"\n});\n```\n\n### Option C: Express Mode (API Key)\n\nRecommended for lightweight scripts or environments using an API key:\n\n#### Python\n\n```python\nfrom google import genai\n\nclient = genai.Client(enterprise=True, api_key=\"YOUR_API_KEY\")\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nimport { GoogleGenAI } from \"@google\u002Fgenai\";\n\nconst ai = new GoogleGenAI({\n    enterprise: true,\n    apiKey: \"YOUR_API_KEY\"\n});\n```\n\n---\n\n## 3. Core Interactions API Usage\n\n### Quick Start (Single-Turn)\n\nSubmit a single prompt and read the final text response. Under the modern schema, output content is retrieved from the `steps` list.\n\n#### Python\n\n```python\ninteraction = client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"Explain serverless computing in one sentence.\"\n)\n# Use the output_text convenience accessor (combined text from the trailing model_output steps)\nprint(interaction.output_text)\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nconst interaction = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"Explain serverless computing in one sentence.\"\n});\nconsole.log(interaction.output_text);\n```\n\n---\n\n### Stateful Conversation (Multi-Turn)\n\nInteractions are stateful by default. Store the conversation state in the cloud and reference it in the subsequent turn using `previous_interaction_id`.\n\n#### Python\n\n```python\n# Turn 1: Introduce ourselves\n# Interactions are stored by default (store=True, retained for 7 days); pass store=False to disable\n# server-side retention (which also disables previous_interaction_id and background).\nturn1 = client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"Hi! My name is John. I am working on AI agents.\",\n    store=True\n)\nprint(f\"Turn 1: {turn1.output_text}\")\n\n# Turn 2: Refer back to the stored turn state\nturn2 = client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"What is my name?\",\n    previous_interaction_id=turn1.id\n)\nprint(f\"Turn 2: {turn2.output_text}\")\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\n\u002F\u002F Turn 1 (interactions are stored by default; pass store: false to disable)\nconst turn1 = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"Hi! My name is John. I am working on AI agents.\",\n    store: true\n});\n\n\u002F\u002F Turn 2\nconst turn2 = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"What is my name?\",\n    previous_interaction_id: turn1.id\n});\nconsole.log(turn2.output_text);\n```\n\n---\n\n### Real-Time Streaming\n\nStream responses in real-time. Passing `stream=True` returns an iterable chunk generator.\n\n#### Python\n\n```python\n# The stream yields typed events, not full interaction snapshots. The sequence is:\n# interaction.created -> (step.start -> step.delta(s) -> step.stop)+ -> interaction.completed\nfor event in client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"Write a short poem about debugging.\",\n    stream=True\n):\n    if event.event_type == \"step.delta\":\n        if event.delta.type == \"text\":\n            print(event.delta.text, end=\"\", flush=True)\n    elif event.event_type == \"interaction.completed\":\n        print()\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\n\u002F\u002F The stream yields typed events, not full interaction snapshots. The sequence is:\n\u002F\u002F interaction.created -> (step.start -> step.delta(s) -> step.stop)+ -> interaction.completed\nconst responseStream = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"Write a short poem about debugging.\",\n    stream: true\n});\n\nfor await (const event of responseStream) {\n    if (event.event_type === \"step.delta\") {\n        if (event.delta.type === \"text\") {\n            process.stdout.write(event.delta.text);\n        }\n    } else if (event.event_type === \"interaction.completed\") {\n        console.log();\n    }\n}\n```\n\n---\n\n### Structured Output (Pydantic \u002F Polymorphic `response_format`)\n\nRetrieve structured, type-safe JSON matching a schema. Under the modern Interactions API, a polymorphic `response_format` argument directly takes the target schema structure.\n\n#### Python\n\n```python\nfrom pydantic import BaseModel, Field\n\nclass Book(BaseModel):\n    title: str = Field(description=\"The title of the book\")\n    author: str = Field(description=\"The book's author\")\n    year_published: int\n\ninteraction = client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"Recommend one famous sci-fi book.\",\n    response_format=Book\n)\n\n# The text will be a valid JSON matching the Book schema\nprint(interaction.output_text)\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nimport { Type } from \"@google\u002Fgenai\";\n\nconst BookSchema = {\n    type: Type.OBJECT,\n    properties: {\n        title: { type: Type.STRING, description: \"The title of the book\" },\n        author: { type: Type.STRING, description: \"The book's author\" },\n        yearPublished: { type: Type.INTEGER }\n    },\n    required: [\"title\", \"author\", \"yearPublished\"]\n};\n\nconst interaction = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"Recommend one famous sci-fi book.\",\n    response_format: BookSchema\n});\n\nconsole.log(interaction.output_text);\n```\n\n---\n\n### Function Calling (Agent Tool Use)\n\nDefine local tools (functions) and submit execution results to the stateful interaction history.\n\n#### Python\n\n```python\nimport json\n\ndef get_stock_price(ticker: str) -> float:\n    \"\"\"Gets the stock price for a given ticker symbol.\"\"\"\n    if ticker.upper() == \"GOOG\":\n        return 175.50\n    return 100.0\n\n# Turn 1: Pass tools to the model\ninteraction = client.interactions.create(\n    model=\"gemini-3.8-flash\",\n    input=\"What is the stock price of GOOG?\",\n    tools=[get_stock_price]\n)\n\n# In the flat steps schema, a tool request is a top-level step of type\n# \"function_call\" with flat `name` and `arguments` fields (no nested tool_calls).\nfor step in interaction.steps:\n    if step.type == \"function_call\" and step.name == \"get_stock_price\":\n        ticker_arg = step.arguments.get(\"ticker\")\n        price = get_stock_price(ticker_arg)\n\n        # Turn 2: Submit the result back as a function_result step. Reference the\n        # originating call via call_id=step.id, and pass tools again (turn-scoped).\n        final_turn = client.interactions.create(\n            model=\"gemini-3.8-flash\",\n            input=[\n                {\n                    \"type\": \"function_result\",\n                    \"name\": step.name,\n                    \"call_id\": step.id,\n                    \"result\": [{\"type\": \"text\", \"text\": json.dumps(price)}],\n                }\n            ],\n            tools=[get_stock_price],\n            previous_interaction_id=interaction.id\n        )\n        print(final_turn.output_text)\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\n\u002F\u002F Define local tool and flat function tool declaration\nfunction getStockPrice({ ticker }: { ticker: string }): number {\n    if (ticker.toUpperCase() === \"GOOG\") {\n        return 175.50;\n    }\n    return 100.00;\n}\n\nconst stockTool = {\n    type: \"function\",\n    name: \"getStockPrice\",\n    description: \"Gets the stock price for a given ticker symbol.\",\n    parameters: {\n        type: \"object\",\n        properties: {\n            ticker: { type: \"string\", description: \"The stock ticker symbol\" }\n        },\n        required: [\"ticker\"]\n    }\n};\n\n\u002F\u002F Turn 1: Pass tools to the model\nconst interaction = await ai.interactions.create({\n    model: \"gemini-3.8-flash\",\n    input: \"What is the stock price of GOOG?\",\n    tools: [stockTool]\n});\n\n\u002F\u002F In the flat steps schema, a tool request is a top-level step of type\n\u002F\u002F \"function_call\" with flat `name` and `arguments` fields (no nested toolCalls).\nconst fcStep = interaction.steps.find(s => s.type === \"function_call\");\nif (fcStep && fcStep.name === \"getStockPrice\") {\n    const tickerArg = fcStep.arguments.ticker as string;\n    const price = getStockPrice({ ticker: tickerArg });\n\n    \u002F\u002F Turn 2: Submit the result back as a function_result step. Reference the\n    \u002F\u002F originating call via call_id=fcStep.id, and pass tools again (turn-scoped).\n    const finalTurn = await ai.interactions.create({\n        model: \"gemini-3.8-flash\",\n        input: [{\n            type: \"function_result\",\n            name: fcStep.name,\n            call_id: fcStep.id,\n            result: [{ type: \"text\", text: JSON.stringify(price) }]\n        }],\n        tools: [stockTool],\n        previous_interaction_id: interaction.id\n    });\n    console.log(finalTurn.output_text);\n}\n```\n\n---\n\n### Agents & Long-Running Tasks\n\nBeyond foundation models, the Interactions API provides access to specialized, autonomous agents via the `agent` parameter:\n\n*   **`antigravity-preview-09-2026`**: Antigravity Agent — general-purpose\n    managed agent with code execution, file management, and web browsing in a\n    secure sandboxed Linux environment (pass `environment=\"remote\"` to\n    provision a sandbox).\n*   **`deep-research-preview-04-2026`**: Deep Research Agent — executes multi-step web research tasks, synthesizing information from multiple sources into comprehensive reports.\n*   **Custom agents**: Configured and managed via `client.agents.create()`, `list()`, `get()`, and `delete()` (pass `environment=\"remote\"` when invoking).\n\nAgents typically run asynchronously in the background using `background=True`. Poll the interaction status to retrieve the completed result:\n\n#### Python\n\n```python\nimport time\n\ninteraction = client.interactions.create(\n    input=\"Analyze competitive positioning for solar energy providers.\",\n    agent=\"deep-research-preview-04-2026\",\n    background=True\n)\nprint(f\"Research started: {interaction.id}\")\n\nwhile True:\n    interaction = client.interactions.get(interaction.id)\n    if interaction.status == \"completed\":\n        print(interaction.output_text)\n        break\n    elif interaction.status in (\"failed\", \"cancelled\"):\n        print(f\"Research ended with status: {interaction.status}\")\n        break\n    time.sleep(10)\n```\n\n#### TypeScript\u002FJavaScript\n\n```typescript\nconst initialInteraction = await ai.interactions.create({\n    agent: \"deep-research-preview-04-2026\",\n    input: \"Analyze competitive positioning for solar energy providers.\",\n    background: true\n});\n\nwhile (true) {\n    const interaction = await ai.interactions.get(initialInteraction.id);\n    if (interaction.status === \"completed\") {\n        console.log(interaction.output_text);\n        break;\n    } else if ([\"failed\", \"cancelled\"].includes(interaction.status)) {\n        console.log(`Research ended with status: ${interaction.status}`);\n        break;\n    }\n    await new Promise(resolve => setTimeout(resolve, 10000));\n}\n```\n\n---\n\n## 4. Accessing the Interactions API via REST\n\nFor shell-based scripts, debugging, or non-Python\u002FJS environments, communicate with the stateful Interactions API over HTTP\u002FREST (`curl`) at `POST https:\u002F\u002Faiplatform.googleapis.com\u002Fv1beta1\u002Fprojects\u002F{PROJECT_ID}\u002Flocations\u002F{LOCATION}\u002Finteractions` (or `POST https:\u002F\u002Faiplatform.googleapis.com\u002Fv1beta1\u002Flocations\u002Fglobal\u002Finteractions` with `x-goog-api-key` for Express Mode). Pass `\"model\"` or `\"agent\"`, `\"input\"` steps with `\"type\": \"user_input\"`, and optional `\"previous_interaction_id\"`, `\"background\": true`, or `\"stream\": true` (which streams Server-Sent Events via `Content-Type: text\u002Fevent-stream` and `Transfer-Encoding: chunked` that `curl` prints continuously in real time).\n\nFor complete `curl` examples (single-turn, multi-turn stateful, SSE streaming, and background managed agents) and response schemas, read [references\u002Frest_api.md](references\u002Frest_api.md).\n\n---\n\n## 5. Data Model & Step Types Reference\n\nAn `Interaction` response contains a flat `steps` timeline (`user_input`, `model_output`, `thought`, `function_call`, `function_result`, and built-in tool steps) along with convenience accessors (`output_text`, `output_image`, `output_audio`) and SSE streaming events (`interaction.created`, `step.start`, `step.delta`, `step.stop`, `interaction.completed`).\n\nFor the complete step types, content types, streaming event table, and 7-day retention rules, read [references\u002Fdata_model.md](references\u002Fdata_model.md).\n\n",{"name":5,"metadata":25,"description":7},{"version":26,"category":27},"2.0.2","AiAndMachineLearning","main","2a870f189175a48c39f5f7e26a6d93b0be9cd13b",0,"https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills","https:\u002F\u002Ftangyixiao.github.io\u002Ftangyixiao-skills\u002F","https:\u002F\u002Fgithub.com\u002Ftangyixiao","http:\u002F\u002Fwww.sxyz.net\u002F","I am Tang Yixiao, a student in Shaoxing No.1 High School. I am eager to learn on GitHub and contribute my part to this community.","2026-11-11 15:45:59",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add tangyixiao\u002Ftangyixiao-skills --skill gemini-interactions-api",{"tool":43,"command":44},"bunx","bunx skills add tangyixiao\u002Ftangyixiao-skills --skill gemini-interactions-api",{"tool":46,"command":47},"pnpm","pnpm dlx skills add tangyixiao\u002Ftangyixiao-skills --skill gemini-interactions-api","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fgemini-interactions-api\u002FSKILL.md",true,[51,57,61,65,69],{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"INSTALL-SOURCE.json","REFERENCE","参考文档",529,"https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fgemini-interactions-api\u002FINSTALL-SOURCE.json",{"path":58,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":16},"LICENSE","许可证",11358,{"path":62,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":63,"sourceHtmlUrl":64},"references\u002Fattribution.md",1917,"https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fgemini-interactions-api\u002Freferences\u002Fattribution.md",{"path":66,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":67,"sourceHtmlUrl":68},"references\u002Fdata_model.md",4311,"https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fgemini-interactions-api\u002Freferences\u002Fdata_model.md",{"path":70,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Frest_api.md",5533,"https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fgemini-interactions-api\u002Freferences\u002Frest_api.md",[74,82,91,99,107,115],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":78,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":20},"01M7D8JK8FYBFNNAJXWD89CFH7","xlsx","Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like \"the xlsx in my downloads\") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fxlsx\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fxlsx\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":87,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":20},"01M7D8JG8ERGGQQAMX0DWCG9GR","writing-shape","Writing, exploit: shape raw material into an article, paragraph by paragraph.","MIT","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fwriting-shape\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fwriting-shape\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":95,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":20},"01M7D8JE672GW3EHSE8EF185M4","writing-fragments","Writing, explore: mine raw fragments, no structure yet.","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fwriting-fragments\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fwriting-fragments\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":103,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":20},"01M7D8JBK572YDFMND8Q6CEYJW","writing-for-agents","Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fwriting-for-agents\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fwriting-for-agents\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":111,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":20},"01M7D8J5QPWEXX61EGBKYH73R8","writing-clearly-and-concisely","Use when writing prose humans will read—documentation, commit messages, error messages, explanations, reports, or UI text. Applies Strunk's timeless rules for clearer, stronger, more professional writing.","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fwriting-clearly-and-concisely\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fwriting-clearly-and-concisely\u002FSKILL.md",[],[],{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":119,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":20},"01M7D8J36YWC8WZS5DK5AH03CD","writing-beats","Writing, exploit; assemble raw material into a journey of beats, grounding each term before a beat leans on it.","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fwriting-beats\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ftangyixiao\u002Ftangyixiao-skills\u002Fblob\u002Fmain\u002Fwriting-beats\u002FSKILL.md",[],[]]