Skip to main content
For authentication and model list, see Overview.

Installation

pip install langchain-google-genai

Code Examples

import os
from langchain_google_genai import ChatGoogleGenerativeAI

llm = ChatGoogleGenerativeAI(
  model='gemini-3-flash-preview',
  google_api_key=os.getenv('PIPELLM_API_KEY'),
  transport='rest',
  client_options={'api_endpoint': 'https://api.pipellm.com'}
)

response = llm.invoke([
  ('user', 'Why is the sky blue?')
])

print(response.content)

Streaming

import os
from langchain_google_genai import ChatGoogleGenerativeAI

llm = ChatGoogleGenerativeAI(
  model='gemini-3-flash-preview',
  google_api_key=os.getenv('PIPELLM_API_KEY'),
  transport='rest',
  client_options={'api_endpoint': 'https://api.pipellm.com'},
  streaming=True
)

for chunk in llm.stream('Tell me a story'):
  print(chunk.content, end='', flush=True)