Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

Google Generative AI

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

Model SDKsNPM

GitHubWebsiteAPI page

1. License

License from npm.

github.com/googleapis/js-genai

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What Google Generative AI does

Google's own TypeScript/JavaScript client for Gemini. One <code>GoogleGenAI</code> object reaches either the Gemini Developer API or Google's enterprise platform, and the maintainers publish a separate instruction file for coding agents because, they write, models "may suggest outdated or legacy code" for it.

Google Generative AI popularity

69 / 100
Gid Score, #434 overall
34.2M
downloads a week, npm
1,717
GitHub stars
171
agent projects use it
Google Generative AI: downloads per weeknpm, @google/genai 34,158,057
Google Generative AI: GitHub starsgoogleapis/js-genai 1,717

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How Google Generative AI is used

  • Google Generative AI is a dependency in 171 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (3.5% of the 4,867 JavaScript/TypeScript ones), #5 of 92 in model sdks.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 792; those are left out of every share on this page.
  • The most used alternative in our scan is OpenAI (286 projects).
  • Projects that use it most often also use dotenv (56.7%), Lucide React (58.5%), React (72.5%).
  • It is more common in projects set up for Gemini CLI (5.7%) than for GitHub Copilot (2.7%).

By coding agent

115 projects, 3.5%
84 projects, 3.4%
83 projects, 2.7%
27 projects, 5.7%
16 projects, 5.7%
15 projects, 4.5%
14 projects, 3.0%
13 projects, 3.8%

Often used with

In 56.7% of its projects
In 58.5% of its projects
In 72.5% of its projects
In 88.9% of its projects
In 46.2% of its projects
In 33.9% of its projects
In 33.9% of its projects
In 66.1% of its projects

Google Generative AI in practice

Strengths

One constructor for AI Studio keys and enterprise projects

Pass an <code>apiKey</code> for the Developer API. For the enterprise platform, pass <code>enterprise: true</code> with a project and location. In Node you can leave the constructor empty and set <code>GOOGLE_API_KEY</code>. For the enterprise platform, set <code>GOOGLE_GENAI_USE_ENTERPRISE</code>, <code>GOOGLE_CLOUD_PROJECT</code> and <code>GOOGLE_CLOUD_LOCATION</code> instead.

An instruction file meant for your coding agent

The maintainers publish <code>codegen_instructions.md</code> and recommend pasting it into your development environment. They say generative models may not know recent SDK updates and "may suggest outdated or legacy code".

CONTINUATION responses are followed up for you

Automatic continuation is on by default. When a response stops with <code>finishReason</code> set to <code>CONTINUATION</code> and returns a <code>continuationToken</code>, the SDK sends follow-up requests with that token until generation completes. It then returns the merged response. You can turn this off with <code>automaticContinuation: false</code>.

Conversation state kept on the server

With the Interactions API you continue a conversation by passing the previous interaction's id instead of resending history. The README's Deep Research example starts the agent with <code>background: true</code>. It then polls <code>ai.interactions.get</code> once a second and stops when the status is <code>completed</code>, <code>failed</code> or <code>cancelled</code>.

Watch out for

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 <code>Models.generateContent</code> calls or their stream variants. It says to invoke it from the <code>Chats</code> module instead.

Fields slated for removal

The README lists fields to be removed, each with a replacement. <code>GenerationConfigThinkingConfig</code> gives way to <code>ThinkingConfig</code>. For video generation, the README's table names the method in snake_case as <code>Models.generate_videos</code>. Its <code>prompt</code>/<code>text</code>/<code>image</code> arguments give way to <code>source</code>. <code>LiveConnectConfig.generation_config</code> is replaced by setting fields on <code>LiveConnectConfig</code> 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 <code>&lt; 3.0.0</code> to avoid unexpected updates.

Quickstart: one generateContent call

import {GoogleGenAI} from '@google/genai';
const GEMINI_API_KEY = process.env.GEMINI_API_KEY;

const ai = new GoogleGenAI({apiKey: GEMINI_API_KEY});

async function main() {
  const response = await ai.models.generateContent({
    model: 'gemini-flash-latest',
    contents: 'Why is the sky blue?',
  });
  console.log(response.text);
}

main();

More about Google Generative AI

Head to head
Packages around it
  • @google/generative-ai: Earlier Gemini SDK package
  • lucide-react: Icon components
  • react: UI library
  • dotenv: Env file loader
  • typescript: Typed JavaScript
  • tailwindcss: Utility CSS
More in Model SDKs

Alternatives

Google Generative AI This page

Apache-2.0Gid 6934.2M/wk

OpenAI

Official TypeScript SDK for accessing OpenAI APIs including GPT and embeddings.

Apache-2.0Gid 8162.5M/wk

Anthropic SDK

Official TypeScript SDK for calling Claude API and building agent applications.

Apache-2.0Gid 7475M/wk

Ollama JavaScript Library

Official JavaScript client library for Ollama to run and interact with local language models.

MITGid 571.3M/wk

Groq SDK

Official TypeScript SDK for calling Groq's fast language models API.

Apache-2.0Gid 471.2M/wk

Mistral AI

Official TypeScript SDK for calling Mistral's language models and APIs.

Apache-2.0Gid 456.7M/wk

Replicate

JavaScript client library for calling Replicate's AI model API.

Apache-2.0Gid 41713K/wk

Compare Google Generative AI with another tool

Get started

Install it.

npm install @google/genai

Rules for your agent

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`.