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

# Google AI

> Route Google Gemini model requests through Orq.ai's AI Router. Set up your Google AI Studio API key for chat, embedding, and multimodal models.

## Setup Your API Key

To use Google AI with Orq.ai, follow these steps:

1. Navigate to **AI Router** > Providers
2. Find **Google AI** in the list
3. Click the **Configure** button next to Google AI
4. In the modal that opens, select **Setup your own API Key**
5. Enter a name for this configuration (e.g., "Google AI Production")
6. Paste your Google AI API Key into the provided field
7. Click **Save** to complete the setup

Your Google AI API key is now configured and ready to use with Orq.ai in **AI Studio** or through the **AI Router**.

## Available Models

The **AI Router** supports all current Google Gemini models. Here are the most commonly used:

### Recommended Models

| Model                                          | Context | Best For                                        |
| ---------------------------------------------- | ------- | ----------------------------------------------- |
| `google-ai/gemini-3.1-pro-preview`             | 1M      | Latest Gemini 3.1, most advanced (experimental) |
| `google-ai/gemini-3.1-pro-preview-customtools` | 1M      | Gemini 3.1 with custom tools support            |
| `google-ai/gemini-3.1-flash-lite-preview`      | 1M      | Cost-efficient Gemini 3.1 inference             |
| `google-ai/gemini-2.5-pro`                     | 1M      | Latest stable, most capable                     |
| `google-ai/gemini-2.5-flash`                   | 1M      | Fast, balanced performance                      |
| `google-ai/gemini-2.5-flash-lite`              | 1M      | Lightweight, cost-effective                     |

<AccordionGroup>
  <Accordion title="View all Google Gemini models" icon="google">
    #### Latest Generation (Gemini 3.1 - Preview)

    * `google-ai/gemini-3.1-pro-preview` - Latest Gemini 3.1, most advanced
    * `google-ai/gemini-3.1-pro-preview-customtools` - Gemini 3.1 with custom tools support
    * `google-ai/gemini-3.1-flash-lite-preview` - Cost-efficient inference, Flash Lite variant

    #### Current Generation (Gemini 2.5)

    * `google-ai/gemini-2.5-pro` - Latest stable, most capable
    * `google-ai/gemini-2.5-flash` - Fast, balanced performance
    * `google-ai/gemini-2.5-flash-lite` - Lightweight, cost-effective
    * `google-ai/gemini-2.5-flash-preview-09-2025` - Flash preview
    * `google-ai/gemini-2.5-flash-lite-preview-09-2025` - Lite preview

    #### Stable Generation (Gemini 2.0)

    * `google-ai/gemini-2.0-flash` - Stable, reliable
    * `google-ai/gemini-2.0-flash-001` - Specific version
    * `google-ai/gemini-2.0-flash-lite` - Lightweight variant
    * `google-ai/gemini-2.0-flash-lite-001` - Lite specific version
    * `google-ai/gemini-2.0-flash-lite-preview-02-05` - Preview version

    #### Latest Versions

    * `google-ai/gemini-flash-latest` - Latest flash model
    * `google-ai/gemini-flash-lite-latest` - Latest lite model

    For a complete and up-to-date list of all available Google Gemini models, see [Supported Models](/docs/proxy/supported-models#chat-models).

    All models are available through the **AI Router** with the `google-ai/` prefix.
  </Accordion>
</AccordionGroup>

<Tip>
  Use `google-ai/gemini-3.1-pro-preview` for the latest preview, `google-ai/gemini-2.5-pro` for the latest stable model, or `google-ai/gemini-2.5-flash` for the best balance of performance and cost.
</Tip>

## Quick Start

Access Google Gemini models through the **AI Router**.

<CodeGroup>
  ```typescript Typescript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { GoogleGenerativeAI } from "@google/generative-ai";

  const genAI = new GoogleGenerativeAI({
    apiKey: process.env.ORQ_API_KEY,
    baseURL: "https://api.orq.ai/v3/router",
  });

  const model = genAI.getGenerativeModel({
    model: "google-ai/gemini-2.5-pro",
  });

  const response = await model.generateContent(
    "Explain quantum computing in simple terms"
  );

  console.log(response.response.text());
  ```
</CodeGroup>

## Using the AI Router

Access Google Gemini models through the **AI Router** with advanced chat completions, streaming, and intelligent model routing. All Gemini models are available with consistent formatting and automatic request logging.

<Info>
  Google AI models use the provider slug format: `google-ai/model-name`. For example: `google-ai/gemini-2.5-pro`
</Info>

### Prerequisites

Before making requests to the **AI Router**, you need to configure your environment and install the SDKs if you choose to use them.

**Endpoint**

```
POST https://api.orq.ai/v3/router/chat/completions
```

**Required Headers**

Include the following headers in all requests:

```
Authorization: Bearer $ORQ_API_KEY
Content-Type: application/json
```

**Getting your API Key:**

1. Go to [API Keys](/docs/router/api-keys)
2. Click **Create API Key** and copy it
3. Store it in your environment as `ORQ_API_KEY`

**SDK Installation**

Install the OpenAI SDK for your language (compatible with Google Gemini models):

<CodeGroup>
  ```bash Node.js/TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  npm install @google/generative-ai
  # or
  yarn add @google/generative-ai
  ```

  ```bash Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  pip install openai
  ```
</CodeGroup>

### Basic Usage

<Tip>
  If your OpenAI code is already functionning, you only need to change the `base_url` and `api_key` to the router endpoint and `ORQ_API_KEY`.
</Tip>

#### Chat Completions

Send messages to Gemini models and get intelligent responses:

<CodeGroup>
  ```typescript Typescript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const response = await model.generateContent({
    contents: [
      {
        role: "user",
        parts: [
          {
            text: "Explain machine learning",
          },
        ],
      },
    ],
  });

  console.log(response.response.text());
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from openai import OpenAI
  import os

  client = OpenAI(
      api_key=os.environ.get("ORQ_API_KEY"),
      base_url="https://api.orq.ai/v3/router",
  )

  response = client.chat.completions.create(
      model="google-ai/gemini-2.5-pro",
      messages=[
          {
              "role": "user",
              "content": "Explain machine learning",
          }
      ],
  )

  print(response.choices[0].message.content)
  ```
</CodeGroup>

#### Streaming

Stream responses for real-time output and improved user experience:

<CodeGroup>
  ```typescript Typescript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const stream = await model.generateContentStream(
    "Write a short poem about the ocean"
  );

  for await (const chunk of stream.stream) {
    const text = chunk.candidates[0]?.content?.parts[0]?.text;
    if (text) {
      process.stdout.write(text);
    }
  }
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from openai import OpenAI
  import os

  client = OpenAI(
      api_key=os.environ.get("ORQ_API_KEY"),
      base_url="https://api.orq.ai/v3/router",
  )

  stream = client.chat.completions.create(
      model="google-ai/gemini-2.5-pro",
      messages=[
          {
              "role": "user",
              "content": "Write a short poem about the ocean",
          }
      ],
      stream=True,
  )

  for chunk in stream:
      if chunk.choices[0].delta.content:
          print(chunk.choices[0].delta.content, end="", flush=True)
  ```

  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST https://api.orq.ai/v3/router/chat/completions \
    -H "Authorization: Bearer $ORQ_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "google-ai/gemini-2.5-pro",
      "messages": [
        {
          "role": "user",
          "content": "Write a short poem about the ocean"
        }
      ],
      "stream": true
    }'
  ```
</CodeGroup>

## AI Router Features

<CardGroup cols={2}>
  <Card title="Reasoning models" icon="brain" href="/docs/proxy/reasoning" horizontal>
    Configure `thinking_level` for Gemini 3 preview models and `budget_tokens` for Gemini 2.5 through the **AI Router**.
  </Card>

  <Card title="Web Search" icon="magnifying-glass" href="/docs/proxy/web-search" horizontal>
    Enable Google Search grounding for supported Gemini models via the Responses API.
  </Card>
</CardGroup>

## Reference

* [Google Gemini Documentation](https://ai.google.dev/docs)
* [Model Pricing](https://ai.google.dev/pricing)
* [API Reference](https://ai.google.dev/api)
