> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipellm.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# LangChain (Gemini)

> Use LangChain's ChatGoogleGenerativeAI with PipeLLM's Gemini routes

For authentication and model list, see [Gemini Overview](/api-reference/gemini/overview).

<Note>
  This page is a framework integration guide. For the raw HTTP endpoint
  reference, see [Generate Content](/api-reference/gemini/generate-content).
</Note>

## Installation

```bash theme={null}
pip install langchain-google-genai
```

## Code Examples

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    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.ai'}
    )

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

    print(response.content)
    ```
  </Tab>

  <Tab title="Node.js">
    ```javascript theme={null}
    import { ChatGoogleGenerativeAI } from '@langchain/google-genai';

    const llm = new ChatGoogleGenerativeAI({
      model: 'gemini-3-flash-preview',
      apiKey: process.env.PIPELLM_API_KEY,
      baseUrl: 'https://api.pipellm.ai'
    });

    const response = await llm.invoke([
      { role: 'user', content: 'Why is the sky blue?' }
    ]);

    console.log(response.content);
    ```
  </Tab>
</Tabs>

## Streaming

```python theme={null}
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.ai'},
  streaming=True
)

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

## Related Docs

<Columns cols={3}>
  <Card title="Gemini Overview" icon="sparkles" href="/api-reference/gemini/overview">
    Headers, models, and native routes
  </Card>

  <Card title="Generate Content" icon="code" href="/api-reference/gemini/generate-content">
    Raw endpoint reference for `POST /v1beta/models/{model}:generateContent`
  </Card>

  <Card title="Developer Tools Overview" icon="terminal" href="/integrations/overview">
    More tools and framework integrations on PipeLLM
  </Card>
</Columns>
