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

# Gemini

> Integrate your application with Gemini

# Proxy Integration

<Warning>
  VertexAI requires proper Google Cloud authentication. Make sure you have run `gcloud auth application-default login` and that your service account has the required permissions before configuring the proxy.
</Warning>

<Tabs>
  <Tab title="VertexAI Python">
    <Steps>
      <Step title="Create an account + Generate an API Key">
        Log into [qualifire](https://qualifire.ai) or create an account. Once you have an account, you
        can generate an [API key](https://qualifire.ai/settings/api-keys).
      </Step>

      <Step title="Set API keys as environment variables">
        ```bash theme={null}
        export QUALIFIRE_API_KEY=<your API key>
        ```
      </Step>

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

        ```bash theme={null}
          pip install --upgrade google-cloud-aiplatform
          gcloud auth application-default login
        ```
      </Step>

      <Step title="Import VertexAI and configure the client">
        ```python theme={null}
        import vertexai
        from vertexai.generative_models import GenerativeModel

        LOCATION = "us-central1"


        vertexai.init(
          project="<PROJECT-ID>",
          location="<LOCATION>",
          api_transport="rest",
          api_endpoint="https://proxy.qualifire.ai/api/providers/google",
          request_metadata=[
              ("X-Qualifire-Base-Url", f"https://{LOCATION}-aiplatform.googleapis.com"),
              ("X-Qualifire-API-Key", "<your API key>"),
          ],
        ) 

        model = GenerativeModel(
          "gemini-1.5-flash-002",
        )

        ```
      </Step>

      <Step title="Call the API">
        ```python theme={null}
        def generate():
            responses = model.generate_content(
                ["""tell me a joke about cats"""],
                generation_config=generation_config,
                stream=True,
            )

            for response in responses:
                print(response.text, end="")

        generation_config = {
              "max_output_tokens": 8192,
              "temperature": 1,
              "top_p": 0.95,
        }

        generate()
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="VertexAI JS">
    ## VertexAI SDK

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

      <Step title="Set API keys as environment variables">
        ```bash theme={null}
        export QUALIFIRE_API_KEY=<your API key>
        export GCLOUD_API_KEY=<your Google Cloud 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-cloud/vertexai
        ```
      </Step>

      <Step title="Import VertexAI and configure the client">
        ```javascript theme={null}
        import { VertexAI } from "@google-cloud/vertexai";

        const vertex_ai = new VertexAI({
          project: "your-project-id",
          location: "your-location",
          apiEndpoint: "proxy.qualifire.ai",
        });
        ```
      </Step>

      <Step title="Set up custom headers">
        ```javascript theme={null}
        const customHeaders = new Headers({
          "X-Qualifire-Api-Key": `${process.env.QUALIFIRE_API_KEY}`,
          "X-Qualifire-Target-URL": `https://${LOCATION}-aiplatform.googleapis.com`,
        });

        ```
      </Step>

      <Step title="Call the API">
        ```javascript theme={null}
        const model = genAI.getGenerativeModel(
            {
                model: "model-name",
            },
            requestOptions
        );

        async function run() {
            const prompt = "Write a story about a magic backpack.";
            const result = await model.generateContent(prompt);
            const response = result.response;
            const text = await response.text();
            console.log(text);
        }

        run();
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Fetch">
    ## Fetch

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

      <Step title="Set API keys as environment variables">
        ```bash theme={null}
            export QUALIFIRE_API_KEY=<your API key>
            export GCLOUD_API_KEY=<your Google Cloud 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://proxy.qualifire.ai/api/providers/google/';

        const headers = {
          'Authorization': `Bearer ${process.env.GCLOUD_API_KEY}`,
          'Content-Type': 'application/json',
          'X-Qualifire-Api-Key': `${process.env.QUALIFIRE_API_KEY}`,
          'X-Qualifire-Target-URL': `https://${LOCATION}-aiplatform.googleapis.com`,
          'User-Agent': 'node-fetch'
        };

        const requestOptions = {
            customHeaders: customHeaders,
            baseUrl: "https://proxy.qualifire.ai/api/providers/google/",
        } as RequestOptions;
        ```
      </Step>

      <Step title="Call the API">
        ```javascript theme={null}
        const url = "https://proxy.qualifire.ai/api/providers/google";
        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>
  </Tab>
</Tabs>
