Skip to content

google-genai

Use when integrating Google Gemini models via the @google/genai SDK — text generation, chat, multimodal (vision, audio, video), function calling, embeddings, safety settings, streaming, or context caching. Also use when choosing between Gemini models or migrating from the older @google/generative-ai SDK.

ModelSource
sonnetpack: ai
Full Reference

┏━ 🔧 google-genai ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Use when integrating Google Gemini models via … ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Direct Gemini API access via the @google/genai SDK (GA as of May 2025). Supports both Gemini Developer API and Vertex AI.

ItemValue
Installnpm install @google/genai
SDK versionv1.x
Node.js minimum20+
Env var (Developer API)GEMINI_API_KEY
Default modelgemini-2.5-flash
Pro modelgemini-2.5-pro
Lite modelgemini-2.5-flash-lite
Embeddings modeltext-embedding-004
Context window1M tokens (all 2.5 models)
Legacy model retiringgemini-2.0-flash — March 31, 2026
I want to…File
Install the SDK and initialize the clientreference/setup.md
Choose the right Gemini modelreference/models.md
Generate text, stream responses, or run multi-turn chatreference/text-generation.md
Send images, audio, or video alongside textreference/multimodal.md
Define functions and handle tool callsreference/function-calling.md
Get schema-enforced JSON outputreference/structured-output.md
Create vector embeddings for RAG or searchreference/embeddings.md
Configure safety filters and handle blocked responsesreference/safety-settings.md
Cache large repeated context for cost and latency savingsreference/context-caching.md

Usage: Read the reference file matching your current task from the index above. Each file is self-contained with code examples and inline gotchas.

  • vercel-ai-sdk — Multi-provider abstraction layer (wraps Gemini + others)
  • anthropic-api — Claude alternative with similar capabilities
  • openai-api — GPT alternative, same skill category
  • postgresql-pgvector — Store and query Gemini embeddings in Postgres