# OpenRouter APIs — Google: Gemini Embedding 2 (google/gemini-embedding-2)

Guide for calling every confirmed OpenRouter API that serves `google/gemini-embedding-2`.

Model page: https://openrouter.ai/google/gemini-embedding-2
Create an API key: https://openrouter.ai/settings/keys

## Pricing

Standard-variant prices for `google/gemini-embedding-2`, per provider, in the unit each provider bills (tokens, images, seconds of video, or characters of audio). Pay-as-you-go with no markup on the provider's price.

- Google Vertex: $0.20/M tokens (plus 4 more; see the model page for the full price list)
- Google AI Studio: $0.20/M tokens (plus 4 more; see the model page for the full price list)
- Google Vertex: $0.22/M tokens (plus 4 more; see the model page for the full price list)

Full price table, including other variants and per-request charges: https://openrouter.ai/google/gemini-embedding-2
How OpenRouter prices requests: https://openrouter.ai/pricing

## EU in-region routing

`google/gemini-embedding-2` is available through EU in-region routing. Requests sent to eu.openrouter.ai are decrypted in the EU and routed only to shared provider endpoints in Europe (the EU/EEA, the UK, and Switzerland).

- Providers in Europe: Google Vertex
- Base URL: https://eu.openrouter.ai/api/v1
- Plan: requires Business or Enterprise. Self-serve on Business: no contract, no monthly minimum. https://openrouter.ai/business/eu
- Fails closed: if no shared provider endpoint in Europe is available, the request errors instead of leaving the region. Requests served by your own BYOK key go to your deployment’s region, which you control.

Docs: https://openrouter.ai/docs/guides/features/in-region-routing

## Authentication

Send this header with every request:

- Authorization: Bearer $OPENROUTER_API_KEY

## Embeddings API

Create vector embeddings with `google/gemini-embedding-2` through OpenRouter's Embeddings API.

Docs: https://openrouter.ai/docs/api/api-reference/embeddings/submit-an-embedding-request

### Endpoint

POST https://openrouter.ai/api/v1/embeddings

Headers:
- Content-Type: application/json

### Request fields (google/gemini-embedding-2)

- model: string (required) — `"google/gemini-embedding-2"`
- input: string | string[] | { content: ({ type: "text", text: string } | { type: "image_url", image_url: { url: string } })[] }[] (required) — text, a batch of texts, or multimodal inputs; an image goes in an `image_url` part, never as a URL string
- dimensions: integer (optional) — output vector size, where the model supports it
- encoding_format: "float" | "base64" (optional)

### Response

JSON with one embedding per input, in input order, plus usage:

```json
{
  "object": "list",
  "data": [{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456] }],
  "usage": { "prompt_tokens": 8, "total_tokens": 8 }
}
```

### Examples

#### Embed text

```bash
# Note: "input" also supports batch processing with arrays: ["text1", "text2", "text3"]
        curl https://openrouter.ai/api/v1/embeddings \
          -H "Authorization: Bearer $OPENROUTER_API_KEY" \
          -H "Content-Type: application/json" \
          -d '{
            "model": "google/gemini-embedding-2",
            "input": "Your text string goes here",
            "encoding_format": "float"
          }'
```

## Errors

Failures return `{"error": {"code": <number>, "message": <string>}}` with the HTTP status:

- 400 — malformed request or an unsupported parameter
- 401 — missing or invalid API key
- 402 — insufficient credits
- 403 — spend limit reached, key disabled, or access blocked
- 404 — unknown model or no provider can serve the request
- 429 — rate limited; retry with backoff
- 502 — the operation failed upstream; failed generations are not billed

---

Canonical version of this document: https://openrouter.ai/google/gemini-embedding-2/llms.txt
