Google Gen AI SDK
Google's official TypeScript/JavaScript SDK for building applications with the Gemini API and Vertex AI.
Repository Health
Technical Analysis
@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
GoogleGenAIclient 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.chatsmodule - 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
Helicone
AI Development · Analytics · Monitoring
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.
Kestra
Automation · Data Engineering · Devops
Event-driven orchestration platform for data, AI, and infrastructure workflows — define everything in YAML, run anywhere at scale.
Kimi Code CLI
AI Agents · AI Code Assistants · Developer Tools
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.
LibreChat
AI Assistants · Developer Tools
Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.
LobeHub
AI Assistants · Automation · Productivity
Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.
localforge
AI Agents · AI Code Assistants · Developer Tools
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.
Mastra Code
AI Code Assistants
"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.
MentraOS
AI Development · Developer Tools
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.
n8n
Automation · No Code Platforms
Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.