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
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,235

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
74
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated yesterday
Java
56%
Apache 2.0

Kestra

Automation · Data Engineering · Devops

29,967

Event-driven orchestration platform for data, AI, and infrastructure workflows — define everything in YAML, run anywhere at scale.

View details
94
Repo Health
81
Technical
69
Dependency
Built with
Java 56%
TypeScript 29%
Vue 14%
Updated 2 days ago
TypeScript
98%
MIT

Kimi Code CLI

AI Agents · AI Code Assistants · Developer Tools

7,983

A single-binary, terminal-native coding agent that reads, edits, and runs code end to end, built by Moonshot AI for Kimi models but pluggable with Anthropic, OpenAI, and Google providers too.

View details
83
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 98%
Updated 2 days ago
TypeScript
85%
MIT

LibreChat

AI Assistants · Developer Tools

46,236

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
62
Dependency
Built with
TypeScript 85%
JavaScript 14%
Updated yesterday
TypeScript
98%
Other

LobeHub

AI Assistants · Automation · Productivity

83,455

Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.

View details
92
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 98%
Updated yesterday
JavaScript
81%
MIT

localforge

AI Agents · AI Code Assistants · Developer Tools

401

A local, multi-provider AI coding agent with a real desktop and web UI — bring your own Anthropic, OpenAI, Gemini, Bedrock, or local Ollama keys and let it read, edit, and run code in your own project folder.

View details
41
Repo Health
54
Technical
73
Dependency
Built with
JavaScript 81%
CSS 12%
Updated 1 years ago
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

29,041

"A coding agent that never compacts" — a terminal-based AI coding agent built on the Mastra framework, with Observational Memory instead of context compaction, multi-model support, and OAuth login for Claude Max or ChatGPT Plus.

View details
90
Repo Health
73
Technical
65
Dependency
Built with
TypeScript 99%
Updated yesterday
TypeScript
53%
MIT

MentraOS

AI Development · Developer Tools

2,391

The open source operating system and SDK that lets developers build one app and run it across smart glasses from Even Realities, Vuzix, Mentra Live, and more.

View details
92
Repo Health
77
Technical
66
Dependency
Built with
TypeScript 53%
Java 16%
Updated yesterday
TypeScript
92%
Other

n8n

Automation · No Code Platforms

208,437

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
62
Dependency
Built with
TypeScript 92%
Updated 2 days 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