원하는 패키지는 @google/genai
공식 TypeScript/JavaScript SDK 는 @google/genai (npm scoped 패키지). @google/generative-ai 를 대체 — 그건 2025 년 8 월 EOL. Node.js ≥ 20 필요.
생성할 클래스 하나
Entry point 가 GoogleGenAI. Python SDK 와 미러링되는 세 생성 패턴:
new GoogleGenAI({ apiKey: '...' })— explicit key.new GoogleGenAI({})— env 의GOOGLE_API_KEY읽음 (Node.js).new GoogleGenAI({ vertexai: true, project: '...', location: '...' })— Vertex AI.
Submodule
생성된 ai 객체가 Python client 와 같은 surface 노출:
ai.models— generate, stream, count tokens.ai.chats— multi-turn chat.ai.files— File API 업로드.ai.caches— context caching.ai.live— live multimodal session.
자주 쓸 헬퍼 import
패키지가 schema 헬퍼와 content factory 도 export:
Type— schema type enum (Type.STRING,Type.OBJECT등).createUserContent,createPartFromUri— multimodal content builder.FunctionCallingConfigMode—AUTO,ANY,NONE.ApiError— exception 클래스.