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

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.

# Google Gemini

> Add a Gemini API key under Settings, Model Providers and call Gemini models through the LangWatch AI Gateway with the OpenAI SDK or the Google GenAI SDKs.

## Add the credential

Open **Settings > Model Providers**, click **Add Model Provider** and select **Gemini**. Give the row a name, pick the organization, team or project it belongs to, and fill in:

| Field | Value |
| - | - |
| `GEMINI_API_KEY` | A Google AI Studio API key, or a Google Cloud API key when you set a project. |
| `GEMINI_PROJECT` | Optional. The Google Cloud project of a Gemini Enterprise Agent Platform key. With the location set, the row calls `aiplatform.googleapis.com` instead of AI Studio. |
| `GEMINI_LOCATION` | Optional. The location for the project, for example `us-central1`. Set both or neither. |

Save the row. Every virtual key whose scope can see the row can now dispatch to it, unless the key restricts its providers. See [Virtual keys](https://langwatch.ai/docs/ai-gateway/virtual-keys.md#create-a-virtual-key).

![The Gemini model provider drawer with GEMINI\_API\_KEY filled in, GEMINI\_PROJECT and GEMINI\_LOCATION empty and the routing handle gemini](https://mintcdn.com/langwatch/6EHh-4eZyYKZhosJ/images/ai-gateway/model-provider-gemini-form.png?fit=max\&auto=format\&n=6EHh-4eZyYKZhosJ\&q=85\&s=3077179e813c9447c8ca9ac9e104605a)

The Gemini row: GEMINI\_API\_KEY, the optional GEMINI\_PROJECT and GEMINI\_LOCATION pair for a Gemini Enterprise Agent Platform key, and the routing handle gemini.

## Model names

Write `gemini/<model>`, for example `gemini/gemini-2.5-flash`. A bare name that starts with `gemini-` resolves to Gemini when the key reaches a Gemini row.

## Send a request

```bash theme={null}
curl https://gateway.langwatch.ai/v1/chat/completions \
  -H "Authorization: Bearer $LANGWATCH_VIRTUAL_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini/gemini-2.5-flash",
    "messages": [{"role": "user", "content": "Say hi in one word"}]
  }'
```

## Google GenAI SDKs

The Google GenAI SDKs call `/v1beta/*`. Point them at the gateway host and send the virtual key as the API key. The SDK puts it in the `X-Goog-Api-Key` header, which the gateway accepts.

```python theme={null}
from google import genai

client = genai.Client(
    api_key="vk-lw-...",
    http_options={"base_url": "https://gateway.langwatch.ai"},
)
response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Say hi in one word",
)
print(response.text)
```

## Endpoints

| Endpoint | Served |
| - | - |
| `POST /v1/chat/completions` | Yes |
| `POST /v1/messages` | Yes, translated |
| `POST /v1/embeddings` | Yes |
| `POST /v1/images/generations`, `POST /v1/images/edits` | Yes, non-streaming. See [Images](https://langwatch.ai/docs/ai-gateway/api/images.md) |
| `/v1beta/*` | Yes, forwarded to the Gemini API |
| `GET /v1/models` | Yes, from the Gemini catalog |


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