# Google Generative AI — card for AI agents

Official SDK for Google Gemini API to build AI-powered applications.

Category: Model SDKs · npm package `@google/genai` · latest version 2.32.0 (checked 2026-11-01)
Install: `npm install @google/genai`
License: Apache-2.0 (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## Google Gen AI SDK (@google/genai)
- Read the official `codegen_instructions.md` before writing code for this SDK. The maintainers say models may suggest outdated or legacy code for it.
- Import `GoogleGenAI` from `@google/genai` and reach features through the instance: `ai.models`, `ai.chats`, `ai.files`, `ai.caches`, `ai.live`, `ai.interactions`.
- Keep API keys out of client-side code. The README says to use server-side implementations in production.
- On 2.x the prerequisite is Node.js 20 or later. Version 3.0.0 will require Node.js 22 and bring the listed removals. To defer that migration, the README advises pinning the SDK to `< 3.0.0` to avoid unexpected updates.
- Use `ThinkingConfig`, not `GenerationConfigThinkingConfig`. Use the `source` argument for video generation. The README lists the old forms for removal. Also note that the next major version will only run automatic function calling from `Chats`, not from direct `generateContent` calls.
- When sending `FunctionCall` or `FunctionResponse` parts, pass a full `Content[]` with explicit roles. Otherwise the SDK throws an exception.
- The SDK uses beta endpoints by default. Set `apiVersion: 'v1'` when you need stable endpoints. For API errors the SDK provides an `ApiError` class. The README's example catches the error and logs `e.name`, `e.message` and `e.status`.

## Docs written for agents
- [llms.txt (index of the docs)](https://ai.google.dev/gemini-api/docs/llms.txt)

## What it is
- `@google/genai` is the Google Gen AI SDK for TypeScript and JavaScript. The repository describes it as a "TypeScript/JavaScript SDK for Gemini and Vertex AI". The repo was created on 2024-12-06 and is Apache-2.0 licensed. The latest GitHub release is v2.28.0, published 2026-10-07. The README says the SDK is designed to work with Gemini 2.0+ features, and its prerequisites section starts with Node.js version 20 or later.
- Everything goes through one `GoogleGenAI` instance. Most calls start at `ai.models.generateContent`, and `ai.chats` keeps multi-turn state on your side. The less usual part is `ai.interactions`. The README calls it "a unified interface for interacting with Gemini models and agents" and says it "simplifies state management, tool orchestration, and long-running tasks". Conversation state for it lives on the server, and it can start agents such as Deep Research.
- The README describes two implementations of the Gemini API that the SDK supports. One is the Gemini Developer API, which uses an API key from Google AI Studio. The other is the Gemini Enterprise Agent Platform. The README lists prerequisites for Enterprise Agent Platform users and says they do not apply to Vertex AI Studio users. The prerequisites are a Google Cloud project, billing enabled, the Vertex AI API enabled, and authentication configured through the gcloud CLI. You pick the implementation with constructor options. In Node you can use environment variables instead.

## Caveats
- Automatic function calling moves to Chats in the next major: The README warns that in the next major version you will not be able to invoke automatic function calling from direct `Models.generateContent` calls or their stream variants. It says to invoke it from the `Chats` module instead.
- Fields slated for removal: The README lists fields to be removed, each with a replacement. `GenerationConfigThinkingConfig` gives way to `ThinkingConfig`. For video generation, the README's table names the method in snake_case as `Models.generate_videos`. Its `prompt`/`text`/`image` arguments give way to `source`. `LiveConnectConfig.generation_config` is replaced by setting fields on `LiveConnectConfig` directly.
- 3.0.0 raises the Node floor to 22: The current prerequisite is Node.js 20. From SDK version 3.0.0, Node.js 22 or later is required. The README advises pinning the SDK to `< 3.0.0` to avoid unexpected updates.
- Beta endpoints unless you say otherwise: By default the SDK calls Google's beta API endpoints so that preview features work. To get the stable endpoints, set `apiVersion: 'v1'`.
- Function call parts are not auto-wrapped: The SDK wraps plain strings and Parts into a single user `Content`. It does not do this for `FunctionCall` or `FunctionResponse` parts. For those you must pass the full `Content[]` with explicit roles. If you pass them without that structure, the SDK throws an exception.

## Numbers (AgentGid data)
- Gid Score: 69.0 (#434 of all tools, 13 of 92 in its category)
- Used in 171 public projects set up for AI coding agents (2.7%)
- Downloads last week: 34,158,057 (as of 2026-11-24), +32.6% over 4 weeks
- GitHub stars: 1,717 (as of 2026-11-24)
- Last push: 2026-11-24

## Often used with
dotenv 56.7%, Lucide React 58.5%, React 72.5%, TypeScript 88.9%, tsx 46.2%, Express 33.9%

## Checked alternatives (same job)
- OpenAI: https://agentgid.com/tools/openai-npm/agent.md
- Anthropic SDK: https://agentgid.com/tools/anthropic-ai/agent.md
- Ollama JavaScript Library: https://agentgid.com/tools/ollama-npm/agent.md
- Groq SDK: https://agentgid.com/tools/groq-sdk/agent.md
- Mistral AI: https://agentgid.com/tools/mistralai-mistralai/agent.md
- Replicate: https://agentgid.com/tools/replicate-npm/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/google-genai-npm/
- Homepage: https://github.com/googleapis/js-genai#readme
- Repository: https://github.com/googleapis/js-genai
- Source: https://github.com/googleapis/js-genai#readme
- Source: https://github.com/googleapis/js-genai
- Source: https://github.com/googleapis/js-genai/releases

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
