PACKAGE · API

@google/genai

[![NPM Downloads](https://img.shields.io/npm/dw/%40google%2Fgenai)](https://www.npmjs.com/package/@google/genai) [![Node Current](https://img.shields.io/node/v/%40google%2Fgenai)](https://www.npmjs.com/package/@google/genai)

WEEKLY DOWNLOADS 6.9M
STARS 1.6K
FORKS 245
OPEN ISSUES 200
GZIP SIZE 60.1 kB
UNPACKED SIZE 15.3 MB
LAST UPDATED 2mo ago
DOWNLOAD TRENDS

@google/genai downloads — last 12 months

Download trends for @google/genai1 download series from Jun 2025 to May 2026. Use left and right arrow keys to inspect monthly values.012.7M25.3M38.0M50.6MJun 2025SepDecMarMay 2026
@google/genai
ABOUT @GOOGLE/GENAI

The @google/genai package provides a JavaScript client for interacting with Google's generative AI models, enabling developers to integrate powerful AI capabilities directly into their applications. It addresses the need for seamless access to state-of-the-art AI services for tasks such as text generation, summarization, and complex reasoning, abstracting away the complexities of direct API calls.

This library is designed with developers in mind, aiming to offer a developer-friendly experience for harnessing AI. Its primary audience includes web developers, backend engineers, and data scientists who want to augment their applications with intelligent features without needing deep machine learning expertise. The focus is on providing an intuitive interface to advanced AI models.

Key features include easy instantiation of generative models and methods for sending prompts and receiving responses. Developers can leverage patterns like streaming responses for real-time user experiences, and manage conversation history for context-aware interactions. The SDK supports different model families, allowing selection based on specific task requirements and performance needs.

The package is built for Node.js environments and can be integrated into various JavaScript-based workflows. It fits well within server-side rendering frameworks, backend APIs, and even client-side applications where appropriate security measures are in place. The straightforward API encourages rapid prototyping and integration into existing CI/CD pipelines.

With a reported bunde size of 60.1 kB (gzip) and being actively maintained (last updated 2026-06-04), the package offers a balance between functionality and performance. While the unpacked size is 15.3 MB, the client-side impact is minimized by its compressed size, making it suitable for a wide range of web applications. The project has a strong community presence with 1.6K GitHub stars and 245 forks.

Developers should be aware of the dependency on network connectivity to access the Google AI services. For applications requiring offline AI capabilities or highly specialized model fine-tuning beyond what the API offers, this package may not be the sole solution. The provided API is subject to Google's terms of service and usage policies for their AI models.

WHEN TO USE
  • When generating creative text formats, like poems, code, scripts, musical pieces, email, letters, etc., using the `generateContent` method.
  • For building conversational applications that require maintaining context over multiple turns of dialogue by managing conversation history.
  • To integrate AI-powered summarization capabilities into document processing workflows using the `generateContent` function.
  • When needing to perform complex reasoning or question-answering tasks based on provided context via the SDK.
  • For implementing real-time AI features in web applications by leveraging streaming response capabilities.
  • When developing backend services that offer AI-driven content creation or analysis to front-end clients.
  • To easily incorporate Google's latest generative AI models into a Node.js application without complex HTTP request management.
WHEN NOT TO USE
  • If your application requires entirely offline AI model processing, as this package relies on network access to Google's services.
  • For very simple text transformations that can be achieved with native string manipulation or smaller, dedicated libraries.
  • When you need fine-grained control over model training or hyperparameter tuning beyond the configuration options offered by the SDK.
  • If your project has exceptionally strict serverless cold-start time requirements and a 60.1 kB (gzip) bundle size is too significant.
  • For use cases where data privacy concerns prohibit sending prompts or data to external API endpoints. Consider on-premise solutions in such scenarios.
  • If the goal is to build a lightweight chatbot without needing advanced generative capabilities; a simpler rule-based system might suffice.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 5
@google/genai vs graphql ★ 20.3K · 19.3M/wk @google/genai vs msw ★ 18.0K · 8.9M/wk @google/genai vs @trpc/server ★ 40.3K · 1.9M/wk @google/genai vs googleapis ★ 12.2K · 4.3M/wk @google/genai vs openapi-typescript ★ 8.2K · 2.1M/wk