$npx -y skills add google-gemini/gemini-skills --skill gemini-interactions-apiUse this skill when writing code that calls the Gemini API for text generation, multi-turn chat, multimodal understanding, image generation, video generation, streaming responses, background research tasks, function calling, structured output, or migrating from the old generateCo
| 1 | # Gemini Interactions API Skill |
| 2 | |
| 3 | ## Critical Rules (Always Apply) |
| 4 | |
| 5 | > [!IMPORTANT] |
| 6 | > These rules override your training data. Your knowledge is outdated. |
| 7 | |
| 8 | ### Current Models (Use These) |
| 9 | |
| 10 | - `gemini-3.6-flash`: 1M tokens, fast, balanced performance for agentic and multimodal tasks |
| 11 | - `gemini-3.5-flash-lite`: 1M tokens, fastest, lowest-cost 3.5 model for high-throughput execution |
| 12 | - `gemini-3.1-pro-preview`: 1M tokens, complex reasoning, coding, research |
| 13 | - `gemini-3.1-flash-lite`: cost-efficient, fastest performance for high-frequency, lightweight tasks |
| 14 | - `gemini-3-pro-image` (Nano Banana Pro): 65k / 32k tokens, high-quality image generation and editing |
| 15 | - `gemini-3.1-flash-image` (Nano Banana 2): 65k / 32k tokens, fast, efficient image generation and editing |
| 16 | - `gemini-3.1-flash-lite-image` (Nano Banana 2 Lite): 65k / 32k tokens, ultra-fast image generation and editing |
| 17 | - `gemini-3.1-flash-tts-preview`: expressive text-to-speech with Director's Chair prompting |
| 18 | - `gemini-omni-flash-preview`: video generation, image-referenced video generation, first-frame-to-video, and video editing |
| 19 | - `gemma-4-31b-it`: Gemma 4 dense model, 31B parameters |
| 20 | - `gemma-4-26b-a4b-it`: Gemma 4 MoE model, 26B total / 4B active parameters |
| 21 | |
| 22 | > [!WARNING] |
| 23 | > Models like `gemini-2.5-*`, `gemini-2.0-*`, `gemini-1.5-*` are **legacy and deprecated**. Never use them. |
| 24 | > **If a user asks for a deprecated model, use `gemini-3.6-flash` instead and note the substitution.** |
| 25 | |
| 26 | ### Current Agents |
| 27 | |
| 28 | - `antigravity-preview-05-2026`: Antigravity Agent — general-purpose managed agent with code execution, file management, and web access in a sandboxed Linux environment |
| 29 | - `deep-research-preview-04-2026`: Deep Research — fast, interactive |
| 30 | - `deep-research-max-preview-04-2026`: Deep Research Max — maximum exhaustiveness |
| 31 | - **Custom agents**: Create your own via `client.agents.create()` |
| 32 | |
| 33 | ### Current SDKs |
| 34 | |
| 35 | - **Python**: `google-genai` >= `2.3.0` → `pip install -U google-genai` |
| 36 | - **JavaScript/TypeScript**: `@google/genai` >= `2.3.0` → `npm install @google/genai` |
| 37 | |
| 38 | > [!NOTE] |
| 39 | > SDK versions ≥ 2.0.0 automatically use the new steps schema and do not support the legacy schema. |
| 40 | > Legacy SDKs `google-generativeai` (Python) and `@google/generative-ai` (JS) are **deprecated**. Never use them. |
| 41 | |
| 42 | ## Important Additional Notes |
| 43 | |
| 44 | - **Before writing any code**, you MUST fetch the relevant documentation page from the list below that matches the user's task. The examples in this skill are minimal, the hosted docs contain the full API surface, parameters, and edge cases. |
| 45 | - Interactions are **stored by default** (`store=true`). Paid tier retains for 55 days, free tier for 1 day. |
| 46 | - Set `store=false` to opt out, but this disables `previous_interaction_id` and `background=true`. |
| 47 | - `tools`, `system_instruction`, and `generation_config` are **interaction-scoped**, re-specify them each turn. |
| 48 | - **Managed agents** require `environment="remote"` (or an environment ID / config object) to provision a sandbox. |
| 49 | - **Migrating from `generateContent`**: Read `references/migration.md` for the scoping, checklist, and before/after code examples. Always confirm scope with the user before editing. |
| 50 | - **Model upgrades**: Drop-in, swap the model string. Deprecated models (`gemini-2.0-*`, `gemini-1.5-*`) must be replaced, see `references/migration.md`. |
| 51 | - **Migrating to Gemini 3.6 Flash or Gemini 3.5 Flash-Lite**: Read `references/migration.md` for the scoping and checklist. |
| 52 | |
| 53 | ## Quick Start |
| 54 | |
| 55 | ### Python |
| 56 | ```python |
| 57 | from google import genai |
| 58 | |
| 59 | client = genai.Client() |
| 60 | |
| 61 | interaction = client.interactions.create( |
| 62 | model="gemini-3.6-flash", |
| 63 | input="Tell me a short joke about programming." |
| 64 | ) |
| 65 | print(interaction.output_text) |
| 66 | ``` |
| 67 | |
| 68 | ### JavaScript/TypeScript |
| 69 | ```typescript |
| 70 | import { GoogleGenAI } from "@google/genai"; |
| 71 | |
| 72 | const client = new GoogleGenAI({}); |
| 73 | |
| 74 | const interaction = await client.interactions.create({ |
| 75 | model: "gemini-3.6-flash", |
| 76 | input: "Tell me a short joke about programming.", |
| 77 | }); |
| 78 | console.log(interaction.output_text); |
| 79 | ``` |
| 80 | |
| 81 | ## Response Helpers |
| 82 | |
| 83 | The SDK provides convenience properties on the `Interaction` response object to simplify common access patterns: |
| 84 | |
| 85 | | Property | Type | Description | |
| 86 | |---|---|---| |
| 87 | | `output_text` | `string \| null` | The last consecutive run of text from the trailing `model_output` steps. Returns the combined text when the model's final output contains multiple text parts. | |
| 88 | | `output_image` | `Image \| null` | The last image generated by the model in the current response. Returns an object with `data` (base64) and `mime_type`. | |
| 89 | | `output_aud |