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

# Gemini JavaScript SDK Integration

> Use Gemini's JavaScript SDK to integrate with Helicone to log your Gemini AI usage.

<Warning>
  This integration method is maintained but no longer actively developed. For the best experience and latest features, use our new [AI Gateway](/gateway/overview) with unified API access to 100+ models.
</Warning>

# Proxy Integration

## Fetch

<Steps>
  <Step title="Create an account + Generate an API Key">
    Log into [helicone](https://www.helicone.ai) or create an account. Once you have an account, you
    can generate an [API key](https://helicone.ai/developer).
  </Step>

  <Step title="Create Google Generative AI API Key">
    Visit the [Google Generative AI API Key](https://aistudio.google.com/app/apikey) page.
    Follow the instructions to create a new API key. Make sure to save the key as you will need it for the next steps.
  </Step>

  <Step title="Set API keys as environment variables">
    ```bash theme={null}
    export HELICONE_API_KEY=<your Helicone API key>
    export GOOGLE_API_KEY=<your Google Generative AI API key>
    ```
  </Step>

  <Step title="Install necessary packages">
    Ensure you have the necessary packages installed in your Javascript project:

    ```bash theme={null}
    npm install node-fetch
    ```
  </Step>

  <Step title="Send a request using fetch">
    ```javascript theme={null}
    const fetch = require('node-fetch');

    const url = `https://gateway.helicone.ai/v1beta/models/model-name:generateContent?key=${process.env.GOOGLE_API_KEY}`;

    const headers = {
      'Content-Type': 'application/json',
      'Helicone-Auth': `Bearer ${process.env.HELICONE_API_KEY}`,
      'Helicone-Target-URL': `https://generativelanguage.googleapis.com`,
    };

    const body = JSON.stringify({
      contents: [{
        parts: [{
          text: 'Write a story about a magic backpack.'
        }]
      }]
    });

    fetch(url, { method: 'POST', headers: headers, body: body })
      .then(response => response.json())
      .then(data => console.log(data))
      .catch(error => console.error('Error:', error));
    ```
  </Step>
</Steps>

## Google Generative AI SDK

<Steps>
  <Step title="Create an account + Generate an API Key">
    Log into [helicone](https://www.helicone.ai) or create an account. Once you have an account, you
    can generate an [API key](https://helicone.ai/developer).
  </Step>

  <Step title="Create Google Generative AI API Key">
    Visit the [Google Generative AI API Key](https://aistudio.google.com/app/apikey) page.
    Follow the instructions to create a new API key. Make sure to save the key as you will need it for the next steps.
  </Step>

  <Step title="Set API keys as environment variables">
    ```bash theme={null}
    export HELICONE_API_KEY=<your Helicone API key>
    export GOOGLE_API_KEY=<your Google Generative AI API key>
    ```
  </Step>

  <Step title="Install necessary packages">
    Ensure you have the necessary packages installed in your Javascript project:

    ```bash theme={null}
    npm install @google/genai
    ```
  </Step>

  <Step title="Import and configure the client">
    ```javascript theme={null}
    import { GoogleGenAI } from "@google/genai";

    if (!process.env.GOOGLE_API_KEY) {
      throw new Error("GOOGLE_API_KEY environment variable must be set");
    }

    if (!process.env.HELICONE_API_KEY) {
      throw new Error("HELICONE_API_KEY environment variable must be set");
    }

    const genAI = new GoogleGenAI({
      apiKey: `${process.env.GOOGLE_API_KEY}`,
      httpOptions: {
        baseUrl: "https://gateway.helicone.ai",
        headers: {
          "Helicone-Auth": `Bearer ${process.env.HELICONE_API_KEY}`,
          "Helicone-Target-URL": "https://generativelanguage.googleapis.com", // Change this to "https://aiplatform.googleapis.com" if vertexai is set to true
        },
      },
    });

    ```
  </Step>

  <Step title="Generate content using the model">
    ```javascript theme={null}
    async function generateContent() {
      const response = await genAI.models.generateContent({
        model: "gemini-2.0-flash-001",
        contents: "Why is the sky blue?",
      });
      console.log(response.text);
    }

    generateContent();
    ```
  </Step>
</Steps>

```
```
