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

# Gemini Integration

> How to integrate Gemini with Lytix

Use Lytix to manage your evaluation and usage diretly with the Gemini SDK. Gain access to models across providers and manage your usage and billing.

<Note>
  **Note** Currently this is only supported for the Typescript Gemini SDK.
</Note>

# Quickstart

<Info>
  **Prerequisite** First create a lytix account [here](https://lab.lytix.co/home/login)
</Info>

### Create a Lytix API Key

Start by creating and noting down a lytix api key. See instructions [here](/api-key-setup)

### Install the Gemini SDK

```sh Typescript
npm install @google/generative-ai
```

### Initialize the GoogleGenerativeAI client

```js Typescript
import { GoogleGenerativeAI } from "@google/generative-ai";

const genAI = new GoogleGenerativeAI(
  "$GEMINI_API_KEY"
);
```

### Initialize the Gemini Model with the Lytix Proxy

```js Typescript
const customHeaders = new Headers({
  "lx-api-key": "$LYTIX_API_KEY",
});

const requestOptions = {
  customHeaders: customHeaders,
  baseUrl: "https://api.lytix.co/proxy/v1/gemini",
};

const model = genAI.getGenerativeModel(
  {
    model: "$GEMINI_MODEL",
  },
  requestOptions
);
```

<Info>
  **🇪🇺 Note** You will need to use `https://eu.api.lytix.co/proxy/v1/gemini` if you are in the EU region.
</Info>

### Invoke the Model 🚀

```js Typescript
const result = await model.generateContent([
  "Hello world!"
]);

const response = result.response;
const text = await response.text();
```

#### Optional Fields

You can also track workflows, users and sessions to get a better understanding of your users and how they interact with your models.

* `sessionId`: A unique identifier for the session.
* `userId`: A unique identifier for the user.
* `workflowName`: A unique identifier for the workflow. If this workflow does not exist, it will be created and can be viewed [here](https://lab.lytix.co/home/workflows)

<CodeGroup>
  ```ts Typescript
  const customHeaders = new Headers({
    "lx-api-key": "$LYTIX_API_KEY",
    // Add your sessionId to track sessions
    "sessionId": "1234567890",
    // Add your userId to track users
    "userId": "sid@lytix.co",
    // Add your workflowName to track workflows
    "workflowName": "test-workflow",
  });

  // ...The rest of your code as normal
  ```
</CodeGroup>

# Saving Video Responses

Please see our [Video Integration Guide](/MultiModal/video) for more information.

# Using Models From Other Providers

Coming soon. ⚡
