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

# Google AI

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

## Setup Your API Key

To use Google AI with Toqan Router, follow these steps:

1. Navigate to **AI Gateway** > BYOK
2. Find **Google AI** in the list
3. Click the **Configure** button next to Google AI
4. In the modal that opens, select <kbd>Setup your own API Key</kbd>
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 Toqan Router in **AI Studio** or through the **AI Gateway**.

## Available Models

The **AI Gateway** 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-2.5-pro` | 1M | Stable, high capability |
| `google-ai/gemini-3.5-flash` | 1M | Fast, balanced performance |
| `google-ai/gemini-2.5-flash-lite` | 1M | Lightweight, cost-effective |

> [accordion] View all Google Gemini models
>
> #### 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
>
> #### Current Generation (Gemini 2.5)
>
> * `google-ai/gemini-2.5-pro`: Stable, high capability
> * `google-ai/gemini-2.5-flash`: Stable, reliable
> * `google-ai/gemini-2.5-flash-lite`: Lightweight, cost-effective
> * `google-ai/gemini-3.5-flash`: Fast, balanced performance
>
> For a complete and up-to-date list of all available Google Gemini models, see [Supported Models](/docs/ai-gateway/supported-models.md#chat-models).
>
> All models are available through the **AI Gateway** with the `google-ai/` prefix.

> [!TIP]
>
> Use `google-ai/gemini-3.1-pro-preview` for the latest preview, `google-ai/gemini-2.5-pro` for a stable, high-capability model, or `google-ai/gemini-3.5-flash` for the best balance of performance and cost.

## Quick Start

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

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST https://router.toqan.ai/eu/v3/router/responses \
  -H "Authorization: Bearer $TOQAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google-ai/gemini-2.5-pro",
    "input": "Explain quantum computing in simple terms"
  }'
```

```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.TOQAN_API_KEY,
  baseURL: "https://router.toqan.ai/eu/v3/router",
});

const response = await client.responses.create({
  model: "google-ai/gemini-2.5-pro",
  input: "Explain quantum computing in simple terms",
});

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

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

client = OpenAI(
    api_key=os.environ.get("TOQAN_API_KEY"),
    base_url="https://router.toqan.ai/eu/v3/router",
)

response = client.responses.create(
    model="google-ai/gemini-2.5-pro",
    input="Explain quantum computing in simple terms",
)

print(response.output_text)
```

```typescript TypeScript (Chat Completions) theme={"theme":{"light":"github-light","dark":"github-dark"}}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.TOQAN_API_KEY,
  baseURL: "https://router.toqan.ai/eu/v3/router",
});

const response = await client.chat.completions.create({
  model: "google-ai/gemini-2.5-pro",
  messages: [{ role: "user", content: "Explain quantum computing in simple terms" }],
});

console.log(response.choices[0].message.content);
```

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

client = OpenAI(
    api_key=os.environ.get("TOQAN_API_KEY"),
    base_url="https://router.toqan.ai/eu/v3/router",
)

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

print(response.choices[0].message.content)
```

## Using the AI Gateway

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

> [!NOTE]
>
> Google AI models use the provider slug format: `google-ai/model-name`. For example: `google-ai/gemini-2.5-pro`

### Prerequisites

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

**Endpoint**

```
POST https://router.toqan.ai/eu/v3/router/responses
```

**Required Headers**

Include the following headers in all requests:

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

**Getting your API Key:**

1. Go to API Keys
2. Click <kbd>Create API Key</kbd> and copy it
3. Store it in your environment as `TOQAN_API_KEY`

**SDK Installation**

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

```bash Node.js/TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
npm install openai
# or
yarn add openai
```

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

### Basic Usage

> [!TIP]
>
> If your OpenAI code is already functioning, you only need to change the `base_url` and `api_key` to the router endpoint and `TOQAN_API_KEY`.

Send messages to Gemini models and get intelligent responses:

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST https://router.toqan.ai/eu/v3/router/responses \
  -H "Authorization: Bearer $TOQAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google-ai/gemini-2.5-pro",
    "input": "Explain machine learning"
  }'
```

```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.TOQAN_API_KEY,
  baseURL: "https://router.toqan.ai/eu/v3/router",
});

const response = await client.responses.create({
  model: "google-ai/gemini-2.5-pro",
  input: "Explain machine learning",
});

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

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

client = OpenAI(
    api_key=os.environ.get("TOQAN_API_KEY"),
    base_url="https://router.toqan.ai/eu/v3/router",
)

response = client.responses.create(
    model="google-ai/gemini-2.5-pro",
    input="Explain machine learning",
)

print(response.output_text)
```

```typescript TypeScript (Chat Completions) theme={"theme":{"light":"github-light","dark":"github-dark"}}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.TOQAN_API_KEY,
  baseURL: "https://router.toqan.ai/eu/v3/router",
});

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

console.log(response.choices[0].message.content);
```

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

client = OpenAI(
    api_key=os.environ.get("TOQAN_API_KEY"),
    base_url="https://router.toqan.ai/eu/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)
```

#### Streaming

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

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST https://router.toqan.ai/eu/v3/router/responses \
  -H "Authorization: Bearer $TOQAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google-ai/gemini-2.5-pro",
    "input": "Write a short poem about the ocean",
    "stream": true
  }'
```

```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.TOQAN_API_KEY,
  baseURL: "https://router.toqan.ai/eu/v3/router",
});

const stream = await client.responses.create({
  model: "google-ai/gemini-2.5-pro",
  input: "Write a short poem about the ocean",
  stream: true,
});

for await (const event of stream) {
  if (event.type === "response.output_text.delta") {
    process.stdout.write(event.delta);
  }
}
```

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

client = OpenAI(
    api_key=os.environ.get("TOQAN_API_KEY"),
    base_url="https://router.toqan.ai/eu/v3/router",
)

stream = client.responses.create(
    model="google-ai/gemini-2.5-pro",
    input="Write a short poem about the ocean",
    stream=True,
)

for event in stream:
    if event.type == "response.output_text.delta":
        print(event.delta, end="", flush=True)
```

```typescript TypeScript (Chat Completions) theme={"theme":{"light":"github-light","dark":"github-dark"}}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.TOQAN_API_KEY,
  baseURL: "https://router.toqan.ai/eu/v3/router",
});

const stream = await 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 await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
```

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

client = OpenAI(
    api_key=os.environ.get("TOQAN_API_KEY"),
    base_url="https://router.toqan.ai/eu/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)
```

## AI Gateway Features

> [card] [Reasoning models](/docs/ai-gateway/features/reasoning.md)
>
> Configure `thinking_level` for Gemini 3 preview models and `budget_tokens` for Gemini 2.5 through the **AI Gateway**.

> [card] [Web Search](/docs/ai-gateway/features/web-search.md)
>
> Enable Google Search grounding for supported Gemini models via the Responses API.

## Reference

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.