Create Gemini embeddings

Create embeddings with the specified engine or model

POST /v1/engines/{model}/embeddings

Service root: https://getrouter.ai

Protocol: Gemini-compatible

Authentication: x-goog-api-key: YOUR_API_KEY

Parameters

ParameterLocationTypeRequiredDescription
modelpathstringYesModel or engine ID

Request body

The request body is optional. Media type: application/json

Request fields

FieldTypeRequiredDescription
modelstringYes
inputstring or array<string>YesText to embed
encoding_formatstringNoAllowed values: float, base64; Default: "float"
dimensionsintegerNoOutput vector dimensions

Example request

curl --request POST \
  --url https://getrouter.ai/v1/engines/MODEL_ID/embeddings \
  --header "x-goog-api-key: YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "MODEL_ID",
  "input": "Hello, introduce yourself."
}'

Responses

StatusDescription
200Embeddings created successfully

Success response fields

FieldTypeRequiredDescription
objectstringNo
dataarray<object>No
modelstringNo
usageobjectNo

Example response

{
  "object": "object",
  "data": [
    {
      "object": "object",
      "index": 1,
      "embedding": [
        1
      ]
    }
  ],
  "model": "MODEL_ID",
  "usage": {
    "prompt_tokens": 1,
    "total_tokens": 1
  }
}

For complete workflows and examples, read the Gemini API API Guide.


This page is generated from the public Relay OpenAPI specification. Browse the complete specification in the API Explorer.