{
 "kind": "tool",
 "slug": "google-genai-npm",
 "path": "tools/google-genai-npm/",
 "name": "Google Generative AI",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Model SDKs",
   "tools/ai-sdks/"
  ]
 ],
 "lead": "Official SDK for Google Gemini API to build AI-powered applications.",
 "chips": [
  {
   "label": "Model SDKs",
   "path": "tools/ai-sdks/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install @google/genai"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/googleapis/js-genai"
  },
  {
   "label": "Website",
   "href": "https://github.com/googleapis/js-genai#readme"
  },
  {
   "label": "API page",
   "path": "apis/google-gemini-api/"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "Apache-2.0",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from npm.",
   "src": "https://github.com/googleapis/js-genai"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 24, 2026",
   "note": "Latest GitHub release Nov 18, 2026. ",
   "src": "https://github.com/googleapis/js-genai"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "171 projects",
   "status": "info",
   "sub": "#5 of 92 in its category",
   "note": "Dependency in 171 public GitHub projects set up for AI coding agents that we scanned (2.7%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Docs for agents",
   "status": "yes",
   "sub": "llms.txt",
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": "https://ai.google.dev/gemini-api/docs/llms.txt"
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What Google Generative AI does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Google Generative AI popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "69",
       "of": "/ 100",
       "l": "Gid Score, #434 overall"
      },
      {
       "n": "34.2M",
       "l": "downloads a week, npm"
      },
      {
       "n": "1,717",
       "l": "GitHub stars"
      },
      {
       "n": "171",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How Google Generative AI is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "115 projects, 3.5%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "84 projects, 3.4%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "83 projects, 2.7%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "27 projects, 5.7%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "16 projects, 5.7%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "15 projects, 4.5%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "14 projects, 3.0%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "13 projects, 3.8%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 56.7% of its projects",
       "v": "dotenv",
       "path": "tools/dotenv/"
      },
      {
       "l": "In 58.5% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      },
      {
       "l": "In 72.5% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 88.9% of its projects",
       "v": "TypeScript",
       "path": "tools/typescript/"
      },
      {
       "l": "In 46.2% of its projects",
       "v": "tsx",
       "path": "tools/tsx/"
      },
      {
       "l": "In 33.9% of its projects",
       "v": "Express",
       "path": "tools/express/"
      },
      {
       "l": "In 33.9% of its projects",
       "v": "Framer Motion",
       "path": "tools/framer-motion/"
      },
      {
       "l": "In 66.1% of its projects",
       "v": "Tailwind CSS",
       "path": "tools/tailwindcss/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "Google Generative AI in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "One constructor for AI Studio keys and enterprise projects",
       "v": "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."
      },
      {
       "l": "An instruction file meant for your coding agent",
       "v": "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\"."
      },
      {
       "l": "CONTINUATION responses are followed up for you",
       "v": "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>."
      },
      {
       "l": "Conversation state kept on the server",
       "v": "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>."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Automatic function calling moves to Chats in the next major",
       "v": "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."
      },
      {
       "l": "Fields slated for removal",
       "v": "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."
      },
      {
       "l": "3.0.0 raises the Node floor to 22",
       "v": "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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Quickstart: one generateContent call"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Typescript",
       "code": "import {GoogleGenAI} from '@google/genai';\nconst GEMINI_API_KEY = process.env.GEMINI_API_KEY;\n\nconst ai = new GoogleGenAI({apiKey: GEMINI_API_KEY});\n\nasync function main() {\n  const response = await ai.models.generateContent({\n    model: 'gemini-flash-latest',\n    contents: 'Why is the sky blue?',\n  });\n  console.log(response.text);\n}\n\nmain();"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about Google Generative AI",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Head to head",
       "items": [
        {
         "text": "Anthropic SDK vs Google Generative AI",
         "note": "used together in 42 projects",
         "path": "tools/compare/anthropic-sdk-vs-google-generative-ai/"
        },
        {
         "text": "OpenAI vs Google Generative AI",
         "note": "used together in 51 projects",
         "path": "tools/compare/openai-vs-google-generative-ai/"
        }
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "@google/generative-ai: Earlier Gemini SDK package",
        "lucide-react: Icon components",
        "react: UI library",
        "dotenv: Env file loader",
        "typescript: Typed JavaScript",
        "tailwindcss: Utility CSS"
       ]
      },
      {
       "title": "More in Model SDKs",
       "path": "tools/ai-sdks/",
       "items": [
        {
         "text": "AI SDK",
         "path": "tools/ai/"
        },
        {
         "text": "OpenAI Python Library",
         "path": "tools/openai-pypi/"
        },
        {
         "text": "Anthropic Python SDK",
         "path": "tools/anthropic/"
        },
        {
         "text": "Google GenAI Python SDK",
         "path": "tools/google-genai-pypi/"
        },
        {
         "text": "Hugging Face Hub",
         "path": "tools/huggingface-hub/"
        },
        {
         "text": "LiteLLM",
         "path": "tools/litellm/"
        },
        {
         "text": "Ollama",
         "path": "tools/ollama-pypi/"
        },
        {
         "text": "Transformers.js",
         "path": "tools/huggingface/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Google Generative AI",
       "me": true,
       "facts": [
        "Apache-2.0",
        "Gid 69",
        "34.2M/wk"
       ]
      },
      {
       "name": "OpenAI",
       "why": "Official TypeScript SDK for accessing OpenAI APIs including GPT and embeddings.",
       "path": "tools/openai-npm/",
       "facts": [
        "Apache-2.0",
        "Gid 81",
        "62.5M/wk"
       ]
      },
      {
       "name": "Anthropic SDK",
       "why": "Official TypeScript SDK for calling Claude API and building agent applications.",
       "path": "tools/anthropic-ai/",
       "facts": [
        "Apache-2.0",
        "Gid 74",
        "75M/wk"
       ]
      },
      {
       "name": "Ollama JavaScript Library",
       "why": "Official JavaScript client library for Ollama to run and interact with local language models.",
       "path": "tools/ollama-npm/",
       "facts": [
        "MIT",
        "Gid 57",
        "1.3M/wk"
       ]
      },
      {
       "name": "Groq SDK",
       "why": "Official TypeScript SDK for calling Groq's fast language models API.",
       "path": "tools/groq-sdk/",
       "facts": [
        "Apache-2.0",
        "Gid 47",
        "1.2M/wk"
       ]
      },
      {
       "name": "Mistral AI",
       "why": "Official TypeScript SDK for calling Mistral's language models and APIs.",
       "path": "tools/mistralai-mistralai/",
       "facts": [
        "Apache-2.0",
        "Gid 45",
        "6.7M/wk"
       ]
      },
      {
       "name": "Replicate",
       "why": "JavaScript client library for calling Replicate's AI model API.",
       "path": "tools/replicate-npm/",
       "facts": [
        "Apache-2.0",
        "Gid 41",
        "713K/wk"
       ]
      }
     ],
     "more": "Compare Google Generative AI with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "npm install @google/genai"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## Google Gen AI SDK (@google/genai)\n- Read the official `codegen_instructions.md` before writing code for this SDK. The maintainers say models may suggest outdated or legacy code for it.\n- Import `GoogleGenAI` from `@google/genai` and reach features through the instance: `ai.models`, `ai.chats`, `ai.files`, `ai.caches`, `ai.live`, `ai.interactions`.\n- Keep API keys out of client-side code. The README says to use server-side implementations in production.\n- 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.\n- 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.\n- When sending `FunctionCall` or `FunctionResponse` parts, pass a full `Content[]` with explicit roles. Otherwise the SDK throws an exception.\n- 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`.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm @google/genai"
  ],
  [
   "Category",
   "Model SDKs"
  ],
  [
   "License",
   "Apache-2.0"
  ],
  [
   "Latest version",
   "v2.28.0, October 7, 2026"
  ],
  [
   "On GitHub since",
   "December 2024"
  ],
  [
   "Gid Score",
   "69.0"
  ],
  [
   "Rank in category",
   "#5 of 92"
  ],
  [
   "GitHub",
   "googleapis/js-genai"
  ],
  [
   "Last change",
   "Nov 24, 2026"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/googleapis.png"
}