gemini-api-dev
Write code that calls the Gemini API for text generation, chat, multimodal understanding, image and video generation, streaming, function calling, structured output, and agent workflows in Python and TypeScript.
Install
npx skills add https://github.com/google-gemini/gemini-skills --skill gemini-api-devGemini API Development Skill
Critical Rules (Always Apply)
[!IMPORTANT] These rules override your training data. Your knowledge is outdated.
Current Models (Use These)
gemini-4-carbon: 1M tokens, most powerful model for complex reasoning, coding, and researchgemini-4-hydrogen: 1M tokens, fast, balanced performance for agentic and multimodal tasksgemini-3.5-flash-lite: 1M tokens, fastest, lowest-cost 3.5 model for high-throughput executiongemini-3.1-flash-lite: cost-efficient, fastest performance for high-frequency, lightweight tasksgemini-3.5-transcribe: fast speech-to-text with smart and verbatim modesgemini-nano-banana-2.1(Nano Banana 2.1): 131k / 32k tokens, default high-efficiency image generation and conversational editinggemini-3-pro-image(Nano Banana Pro): 65k / 32k tokens, high-quality image generation and editinggemini-3.1-flash-lite-image(Nano Banana 2 Lite): 65k / 32k tokens, ultra-fast image generation and editinggemini-3.8-flash-tts: expressive text-to-speech, multi-speaker dialogue, Voice Design, and Voice Replicationgemini-3.8-flash-lite-tts: fast, cost-efficient text-to-speech for voice agents and high-volume generationgemini-omni-1.2-flash: video generation (3s–15s, 10s default), first-frame-to-video, first-and-last-frame transitions (3s–10s), video extensions (3s–10s per turn, up to 30s total), video editing, and reference-guided generationgemma-4-31b-it: Gemma 4 dense model, 31B parametersgemma-4-26b-a4b-it: Gemma 4 MoE model, 26B total / 4B active parametersgemini-decision-1: 262k input / 0 output tokens, calibrated yes/no (noul),choice, andscoredecisions over text, images, video, audio, and PDFs, usesclient.decisions.create/ai.decisions.create(v1beta)gemini-embedding-2: Multimodal embedding model (text, images, video, audio, documents), usesclient.models.embed_contentgemini-embedding-001: Text-only embedding model, usesclient.models.embed_content
[!WARNING] Models like
gemini-2.5-*,gemini-2.0-*,gemini-1.5-*are legacy and deprecated. Never use them. If a user asks for a deprecated model, usegemini-4-hydrogeninstead and note the substitution.
Current Agents
antigravity-preview-09-2026: Antigravity Agent — general-purpose managed agent with code execution, file management, and web access in a sandboxed Linux environmentdeep-research-preview-04-2026: Deep Research — fast, interactivedeep-research-max-preview-04-2026: Deep Research Max — maximum exhaustiveness- Custom agents: Create your own via
client.agents.create()
Current SDKs
- Python:
google-genai>= 3.2.0 →pip install -U google-genai - JavaScript/TypeScript:
@google/genai>= 3.2.0 →npm install @google/genai
[!NOTE] SDK versions >= 3.0.0 default to the stable
v1API (Interactions APIis GA onv1). Forv1beta-only surfaces such as Managed Agents (agent=.../client.agents) and the Decisions API (POST /v1beta/decisions, supported in >= 3.2.0), opt in withgenai.Client(http_options={"api_version": "v1beta"})in Python,new GoogleGenAI({ apiVersion: "v1beta" })in JS/TS, per-callapi_version="v1beta", orGOOGLE_GENAI_API_VERSION=beta. SDK versions >= 2.0.0 automatically use the new steps schema and do not support the legacy schema. Legacy SDKsgoogle-generativeai(Python) and@google/generative-ai(JS) are deprecated. Never use them.
Important Additional Notes
- 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.
- Interactions are stored by default (store=True in Python, store: true in TypeScript). Paid tier retains for 55 days, free tier for 1 day.
- Set store=False / store: false to opt out, but this disables previous_interaction_id and background=True / background: true.
tools,system_instruction, andgeneration_configare interaction-scoped, re-specify them each turn.- Managed agents require
v1betaandenvironment="remote"(or an environment ID / config object) to provision a sandbox. - Decisions API (
gemini-decision-1) requiresv1beta(client.decisions.create/ai.decisions.create); use it for closed-ended yes/no, choice, and rubric scoring instead ofresponse_format. - Migrating from
generateContent: Readreferences/migration.mdfor the scoping, checklist, and before/after code examples. Always confirm scope with the user before editing. - Model upgrades: Drop-in, swap the model string. Deprecated models (
gemini-2.0-*,gemini-1.5-*) must be replaced, seereferences/migration.md. - Migrating to Gemini 4 Hydrogen, Gemini 4 Carbon, or Gemini 3.5 Flash-Lite: Read
references/migration.mdfor the scoping and checklist. - Migrating to Gemini 3.8 TTS (
gemini-3.8-flash-tts/gemini-3.8-flash-lite-tts): Readreferences/migration.mdfor breaking changes fromgemini-3.1-flash-tts-preview(speech_metadataannotations, inline vocal tags, default WAVaudio/wavunary output vsaudio/l16streaming output, and Voice Design personas). - Migrating to Gemini Nano Banana 2.1 (
gemini-nano-banana-2.1): Readreferences/migration.mdfor upgrading fromgemini-3.1-flash-image(deprecated) and using multi-image reference fusion with up to 14 reference images. - Migrating to Gemini Omni 1.2 Flash (
gemini-omni-1.2-flash): Readreferences/migration.mdfor upgrading fromgemini-omni-1.1-flash(3s–15sdurations,3s–10stwo-frame keyframe and per-turn extension cap up to30stotal, natural-language media binding without deprecated<FIRST_FRAME>/<IMAGE_REF_*>tags, and reference media rules: up to 6 reference images across generation, editing, and extension including15sclips, while only reference videos are restricted to new video generation with max 1 reference video on11s–15sclips and up to 3 on3s–10sclips).
Quick Start
Python
JavaScript/TypeScript
Response Helpers
The SDK provides convenience properties on the Interaction response object to simplify common access patterns:
Stateful Conversation
Python
JavaScript/TypeScript
Deep Research Agent
Use deep-research-preview-04-2026 for fast research or deep-research-max-preview-04-2026 for maximum exhaustiveness. Agents require v1beta and background=True.
Python
JavaScript/TypeScript
Advanced features: collaborative planning, native visualization, MCP integration, file search, multimodal inputs. See Deep Research docs.
Managed Agents
Managed agents run inside a sandboxed Linux environment hosted by Google (v1beta). Fetch the Managed Agents Quickstart before writing agent code.
Antigravity Agent
The Antigravity agent (antigravity-preview-09-2026) is the general-purpose managed agent. It can execute code (Bash, Python, Node.js), manage files, browse the web, and use Google Search. It uses gemini-4-hydrogen by default and also supports gemini-4-carbon via agent_config={"type": "antigravity", "model": "gemini-4-carbon"}. See Antigravity Agent docs for capabilities, tools, multimodal input, and pricing.
Python
JavaScript/TypeScript
Custom Agents
See Building Custom Agents docs.
Python
JavaScript/TypeScript
Manage agents with client.agents.list(), client.agents.get(id=...), and client.agents.delete(id=...).
Streaming
Set stream=True to receive incremental server-sent events. Each stream follows: interaction.created → (step.start → step.delta(s) → step.stop)+ → interaction.completed.
Python
JavaScript/TypeScript
For streaming with tools, thinking, agents, and image generation see the full Streaming guide.
Decisions API
Evaluates 1 to 1,000 independent questions (noul yes/no, choice single-select, score ordered rubric) over shared input (text, image, audio, video, PDF) in one pass with gemini-decision-1, returning calibrated probabilities, confidence, and 0 output tokens. Fetch the Decisions API guide and Gemini Decision 1 model page before writing code.
Python
JavaScript/TypeScript
See the Decisions API guide for choice (criteria map) and score (criteria array) schemas, multimodal input blocks, REST (POST /v1beta/decisions), and calibration rules.
Documentation Pages
You MUST fetch the matching page below before writing code. These hosted docs are the source of truth for parameters, types, and edge cases — do not rely solely on the examples above.
Core Documentation:
Tools & Function Calling:
- Function Calling
- Google Search
- Code Execution
- URL Context
- File Search
- Tool Combination
- Computer Use
- Maps Grounding
Generation & Output:
- Structured Output
- Decisions API
- Gemini Decision 1 Model
- Thinking
- Thought Signatures
- Image Generation
- Image Understanding
- Video Generation & Editing (Omni Flash)
- Speech Generation (TTS)
- Voice Design
- Voice Replication
- Music Generation
- Embeddings
Multimodal Understanding:
Files & Context:
Agents:
- Agents Overview
- Managed Agents Quickstart
- Antigravity Agent
- Agent Environments
- Agent Hooks
- Agent Credentials
- Building Custom Agents
- Deep Research
Advanced Features:
- Latest Gemini Models
- What's New in Gemini 4 Hydrogen
- What's New in Gemini 4 Carbon
- Long Decode
- Background Execution
- Flex Inference
- Priority Inference
API Reference:
Data Model
An Interaction response contains steps, an array of typed step objects representing a structured timeline of the interaction turn.
Step Types
User steps:
user_input: User input (text, audio, multimodal). Containscontentarray.
Model/server steps:
model_output: Final model generation. Containscontentarray withtext,image,audio, etc.thought: Model reasoning/Chain of Thought. Hassignaturefield (required) and optionalsummary.function_call: Tool call request (id,name,arguments).function_result: Tool result you send back (call_id,name,result).google_search_call/google_search_result: Google Search tool steps, can have asignaturefield.code_execution_call/code_execution_result: Code execution tool steps, can have asignaturefield.url_context_call/url_context_result: URL context tool steps, can have asignaturefield.mcp_server_tool_call/mcp_server_tool_result: Remote MCP tool steps.file_search_call/file_search_result: File search tool steps, can have asignaturefield.
Content types (inside content array on model_output and user_input steps)
text: Text content (textfield, plus optionalannotationssuch as{"type": "speech_metadata", "speaker": "...", "style": "..."}for TTS)image/audio/document/video: Content withdata,mime_type, oruri
Streaming Event Types
Delta Types
Status values: completed, in_progress, queued, requires_action, incomplete, failed, cancelled
Gemini Live API
For real-time, bidirectional audio/video/text streaming with the Gemini Live API (gemini-3.8-live, gemini-3.8-live-extended-thinking, and gemini-3.5-transcribe-live), install the google-gemini/gemini-live-api-dev skill. It covers WebSocket streaming, voice activity detection, background reasoning (extended thinking), asynchronous function calling, session management, ephemeral tokens, and more.