Google Gen AI SDK

Google's official TypeScript/JavaScript SDK for building applications with the Gemini API and Vertex AI.

SDK
npm
v2.31.0
1,690 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
89 /100 Excellent
Development Activity 100
Maintenance 100
Community 72
Maturity 44
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
84 /100 Excellent
Architecture 87
Code Quality 84
Innovation 86
Learning Curve 78

@google/genai is Google’s official TypeScript and JavaScript SDK for building applications powered by Gemini models. It provides a single, unified client that works with both the Gemini Developer API (using an API key from Google AI Studio) and the Gemini Enterprise Agent Platform (formerly Vertex AI), so teams can prototype against the consumer API and later move to enterprise infrastructure without rewriting application code.

The SDK wraps content generation, streaming, function calling, file uploads, context caching, live bidirectional sessions, batch jobs, and fine-tuning behind a consistent, well-typed API surface, and ships isomorphic builds that run in both Node.js and the browser.

What You Get

  • A single GoogleGenAI client that switches between the Gemini Developer API (API key) and Vertex AI / Gemini Enterprise (Cloud project credentials) without changing application code
  • First-class support for text, image, audio, and video generation, plus streaming responses via generateContentStream
  • Built-in function calling with JSON-schema tool declarations, automatic function calling, and native Model Context Protocol (MCP) tool support
  • Context caching (ai.caches), file uploads (ai.files), batch jobs (ai.batches), fine-tuning (ai.tunings), and low-latency bidirectional Live sessions (ai.live) for audio/video
  • Isomorphic builds for Node.js (CommonJS + ESM) and the browser, plus a bundled SentencePiece tokenizer for local token counting

Common Use Cases

  • Building chatbots and multi-turn conversational agents with the ai.chats module
  • Adding multimodal generation (text, image, audio) to web and Node.js applications
  • Implementing tool-using/agentic workflows via function calling and MCP tool integration
  • Building real-time voice/video assistants using the Live API’s bidirectional streaming sessions
  • Migrating between prototyping with a Gemini API key and production deployment on Vertex AI without rewriting client code

Under The Hood

Architecture - Isomorphic design split across src/node, src/web, and src/cross directories behind a shared public API in client.ts/index.ts; a single GoogleGenAI entry point composes focused submodules (Models, Chats, Caches, Files, Live, Tokens, Tunings, Batches, Operations, FileSearchStores) each in its own file, with an internal ApiClient (_api_client.ts) abstracting HTTP/auth differences between the Gemini Developer API and the Gemini Enterprise Agent Platform (Vertex AI) so the same application code can target either backend.

Tech Stack - Pure TypeScript compiled with Rollup into dual ESM/CJS bundles for Node and web, using google-auth-library for Vertex/enterprise auth, ws for the Live streaming/WebSocket API, protobufjs for the bundled SentencePiece tokenizer, and Microsoft’s api-extractor to generate and diff public API reports on every build; tests run on Jasmine with recorded system/integration suites.

Code Quality - Consistently documented with TSDoc comments on nearly every public type and method (types.ts alone is roughly 8,600 lines of typed request/response models), enforced via ESLint/Prettier and strict TypeScript; the public surface is intentionally kept small behind underscore-prefixed internal modules (_api_client, _transformers, _afc), though the sheer size of the generated types file is a maintenance-heavy artifact.

API Design - A single new GoogleGenAI({...}) client exposes cleanly namespaced submodules (ai.models, ai.chats, ai.caches, ai.files, ai.live), supports both one-shot and streaming generateContent calls, declarative function calling with JSON-schema tool definitions (including automatic function calling and native MCP tool support), and works identically whether authenticated via a simple API key or full enterprise credentials — a deliberately low-friction entry point for a very large capability surface.

Used by 26 apps in this directory

TypeScript
90%
MIT

OpenClaw

AI Agents · AI Assistants

392,894

An open-source AI assistant that runs on your own hardware and meets you in Discord, Slack, WhatsApp, iMessage, Telegram, and 20+ other channels, with native apps for every major platform.

View details
88
Repo Health
88
Technical
66
Dependency
Built with
TypeScript 90%
Updated yesterday
Python
49%
Other

Arize Phoenix

Analytics · Devops · Monitoring

11,976

Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.

View details
92
Repo Health
88
Technical
67
Dependency
Built with
Python 49%
TypeScript 43%
Updated yesterday
TypeScript
96%
MIT

Pi

AI Agents

117,476

An open-source, self-extensible agent harness and coding agent CLI — a modular runtime (agent core, unified multi-provider LLM API, TUI) with no built-in permission system by default, documented containerization patterns for sandboxing instead.

View details
88
Repo Health
73
Technical
73
Dependency
Built with
TypeScript 96%
Updated 2 days ago
Rust
89%
MIT

Prime Agent

AI Agents · AI Code Assistants · Developer Tools

22,296

An open-source coding and research agent built around a Recursive Language Model that treats context as variables and a persistent Python REPL as its only tool.

View details
85
Repo Health
89
Technical
69
Dependency
Built with
Rust 89%
Updated yesterday
TypeScript
64%
AGPL 3.0

Puter

Developer Tools · File Storage

43,864

A self-hostable, web-based internet OS with desktop GUI, cloud storage, AI drivers, and a developer SDK — all running in your browser.

View details
88
Repo Health
88
Technical
67
Dependency
Built with
TypeScript 64%
JavaScript 33%
Updated yesterday
TypeScript
48%
MIT

supermemory

AI Development · AI Memory · Note Taking

31,370

The state-of-the-art memory and context engine for AI agents — ranked #1 on all three major AI memory benchmarks.

View details
88
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 48%
MDX 32%
Python 17%
Updated yesterday
TypeScript
97%
AGPL 3.0

Swetrix

Analytics

1,213

Privacy-first, cookieless web analytics with error tracking, session replays, and performance monitoring — self-host or use Cloud.

View details
87
Repo Health
71
Technical
66
Dependency
Built with
TypeScript 97%
Updated 3 days ago
TypeScript
95%
Apache 2.0

Void

AI Code Assistants · Automation · Code Editors

28,733

Open-source AI code editor with direct LLM integration and data privacy

View details
44
Repo Health
84
Technical
68
Dependency
Built with
TypeScript 95%
Updated 4 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers