Google 통합
Google 통합
LangChain JavaScript로 Google과 통합하는 방법을 알아봅니다.
LangChain은 @langchain/google 패키지를 통해 Google AI Studio와 Gemini Enterprise Agent Platform과의 통합을 제공해요.
이전의
@langchain/google-genai또는@langchain/google-vertexai패키지를 찾고 계신가요? 그들은 장기 지원 아래 유지 관리되지만 새 프로젝트에는 더 이상 권장되지 않습니다.
출처: 문서
본문
채팅 모델(Chat models)
ChatGoogle 클래스는 Gemini 모델(gemini-2.5-pro, gemini-2.5-flash, gemini-3.1-pro-preview 등)과 Gemma 같은 오픈 모델에 접근하는 권장 방법입니다. 단일 인터페이스로 Google AI Studio와 Gemini Enterprise Agent Platform을 모두 지원합니다.
LangChain 패키지 설치에 대한 일반적인 지침은 이 섹션을 참조하세요.
npm install @langchain/google @langchain/core
yarn add @langchain/google @langchain/core
pnpm add @langchain/google @langchain/core
API 키를 구성하세요:
export GOOGLE_API_KEY=your-api-key
import { ChatGoogle } from "@langchain/google";
const model = new ChatGoogle("gemini-2.5-flash");
const res = await model.invoke([
["human", "What would be a good company name for a company that makes colorful socks?"],
]);
ChatGoogle은 도구 호출, 구조화된 출력, 멀티모달 입력(이미지, 오디오, 비디오), 추론/사고, 이미지 생성, 텍스트-음성, 그리고 Google 검색 접지(grounding)와 코드 실행 같은 Gemini 특화 네이티브 도구를 지원합니다.
- ChatGoogle — 설정, 호출, 스트리밍, 구조화된 출력 등을 포함한 전체 채팅 모델 문서.
- Gemini 네이티브 도구 — Google Search, Code Execution, URL Context, Google Maps, File Search, Computer Use, MCP 서버.
Gemini Enterprise Agent Platform의 제3자 모델
Anthropic Claude 모델도 Gemini Enterprise Agent Platform 플랫폼을 통해 사용할 수 있습니다. 모델 접근 활성화와 사용할 모델 이름에 대한 자세한 내용은 Gemini Enterprise Agent Platform에서 Claude 사용하기를 참조하세요.
Postgres 벡터 스토어(Cloud SQL)
@langchain/google-cloud-sql-pg 패키지의 PostgresVectorStore 모듈은 CloudSQL for PostgreSQL을 사용해 벡터 임베딩을 저장하는 방법을 제공합니다.
npm install @langchain/google-cloud-sql-pg @langchain/core
레거시 패키지(Legacy packages)
다음 패키지는 기존 사용자를 위해 장기 지원 아래 유지 관리됩니다. 새 프로젝트는 대신 @langchain/google을 사용해야 합니다.
@langchain/google-genai
@langchain/google-genai 패키지는 Google AI Studio를 통해 Gemini 모델에 접근하기 위한 ChatGoogleGenerativeAI와 GoogleGenerativeAIEmbeddings를 제공합니다. 이 패키지는 더 이상 사용되지 않는 Google SDK를 기반으로 하며 새 기능이 추가되지 않습니다.
npm install @langchain/google-genai @langchain/core
@langchain/google-vertexai
@langchain/google-vertexai 패키지는 Node.js에서 Gemini Enterprise Agent Platform을 위한 ChatVertexAI, VertexAIEmbeddings, VertexAI를 제공합니다. 인증을 위해 @langchain/google-gauth에 의존합니다. 이 패키지는 채팅용 @langchain/google에 내장된 Gemini Enterprise Agent Platform 지원으로 대체되었습니다.
npm install @langchain/google-vertexai @langchain/core
@langchain/google-vertexai-web
@langchain/google-vertexai-web 패키지는 브라우저 및 Edge 런타임을 위한 동일한 Gemini Enterprise Agent Platform 채팅, 임베딩, LLM 클래스를 제공합니다. 웹 환경에서 실행할 때는 이 패키지(@langchain/google-vertexai 아님)를 설치하세요. @langchain/google-webauth에 의존합니다.
npm install @langchain/google-vertexai-web @langchain/core
GOOGLE_WEB_CREDENTIALS와 웹 import 경로에 대해서는 Gemini Enterprise Agent Platform 채팅 페이지를 참조하세요.
@langchain/google-webauth
@langchain/google-webauth 패키지는 레거시 Gemini Enterprise Agent Platform 통합을 위한 브라우저 및 Edge 인증을 제공합니다. @langchain/google-vertexai-web와 함께 자동으로 설치됩니다—@langchain/google-gauth와 함께 설치하지 마세요.
GOOGLE_WEB_CREDENTIALS(또는 더 이상 사용되지 않는 GOOGLE_VERTEX_AI_WEB_CREDENTIALS)에 서비스 계정 JSON을 설정하세요. 모델 생성자에 apiKey 또는 authOptions를 전달하거나 API_KEY 환경 변수를 설정할 수도 있습니다.
@langchain/google-gauth
@langchain/google-gauth 패키지는 @langchain/google-common을 기반으로 하는 레거시 Google 통합을 위한 Node.js 인증을 제공합니다. @langchain/google-vertexai를 추가할 때 자동으로 설치됩니다—보통 @langchain/google-gauth를 직접 설치하거나 import하지 않습니다.
Node.js에서는 자격 증명이 다음 순서로 해석됩니다:
- 모델 생성자에 전달된
apiKey - 모델 생성자에 전달된
authOptions API_KEY환경 변수GOOGLE_APPLICATION_CREDENTIALS의 경로에 있는 서비스 계정 JSON- Application Default Credentials(예:
gcloud auth application-default login후, 또는 Google Cloud에서)
같은 프로젝트에서 @langchain/google-gauth와 @langchain/google-webauth를 사용하지 마세요.
통합된 @langchain/google 패키지는 google-auth-library를 직접 사용하므로 @langchain/google-gauth 또는 @langchain/google-webauth가 필요하지 않습니다.
@langchain/google-cloud-sql-pg
@langchain/google-cloud-sql-pg 패키지는 Cloud SQL for PostgreSQL을 위한 PostgresVectorStore와 PostgresLoader를 제공합니다. 위의 Gemini 채팅 패키지와는 별개입니다.
@langchain/google-common
@langchain/google-common 패키지는 @langchain/google-vertexai 같은 레거시 통합을 위한 공유 Gemini 클라이언트 추상화를 제공합니다. 인증 코드를 포함하지 않으며 추천 패키지가 아닙니다—직접 설치하거나 import하지 마세요.
@langchain/google-genai또는@langchain/google-vertexai에서@langchain/google로 마이그레이션하려면 ChatGoogle 페이지의 설정 지침을 참조하세요.ChatGoogle클래스는 Google AI Studio와 Gemini Enterprise Agent Platform 양쪽에 통합 접근하는 동등한 기능을 제공합니다.
더 알아보기 (Learn more)
- 이 문서를 MCP로 연결하면 Claude, VSCode 등에서 실시간 답변을 받을 수 있어요.
- GitHub에서 이 페이지 편집하기 또는 이슈 제출하기.