Want to test your code snippets immediately? Try the companion Gen AI SDK v3 Migration & Payload Workbench [SIMULATED DEMO] to automatically detect deprecated model aliases, audit Node 22 engine compliance, and generate verified v3.0.0 code.
Before deploying an upgrade to @google/genai@^3.0.0 or google-genai>=3.0.0 in production, ensure your codebase passes all five validation gates:
gemini-flash-latest, gemini-flash-lite-latest, gemini-pro-latest) with pinned GA models (e.g., gemini-3.8-flash or gemini-4-argon).package.json engines.node declaration and GitHub Actions runner images to Node 22 LTS or Node 24.step.result to handle the Array<Content> | string union.client.models.generate_content calls and consolidate into stateful client.chats.create sessions.gemini-embedding-2-preview to gemini-embedding-2.import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI(); // Defaults to v1beta
// BREAKS on v1: alias does not exist!
const response = await ai.models.generateContent({
model: 'gemini-flash-latest',
contents: 'Summarize quarterly logs',
});
// BREAKS tsc: string assignment error
function handleStep(step: any) {
const text: string = step.result;
displayOutput(text);
}
import { GoogleGenAI } from '@google/genai';
// Clean v1 GA initialization
const ai = new GoogleGenAI();
// Pinned deterministic model string
const response = await ai.models.generateContent({
model: 'gemini-3.8-flash',
contents: 'Summarize quarterly logs',
});
// Explicit type narrowing for multimodal returns
function handleStep(step: CodeExecutionResultStep) {
if (typeof step.result === 'string') {
displayOutput(step.result);
} else if (Array.isArray(step.result)) {
renderMultimodalArtifacts(step.result);
}
}
from google import genai
client = genai.Client()
# AFC decoupled from generate_content in v3
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="Query inventory database",
config={"tools": [query_inventory]} # AFC legacy
)
from google import genai
client = genai.Client()
# Stateful Chats module enforces boundary tracking
chat = client.chats.create(
model="gemini-3.8-flash",
config={"tools": [query_inventory]}
)
response = chat.send_message("Query inventory database")
Ensure your automated verification pipeline enforces Node.js 22 LTS:
name: CI Test Suite
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x, 24.x]
python-version: ['3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
- run: npm test
SDK v3.0.0 is the definitive production standard for Google Gemini. If your organization has existing production agents in flight, adopt a two-phase rollout: first, set GOOGLE_GENAI_API_VERSION=v1beta in your staging environment to verify existing behavior, then systematically pin explicit model strings and narrow execution typings before cutting over to the default v1 GA pipeline.