Skip to main content
POST
https://console.mixroute.io
/
v1
/
models
/
{model}
:embedContent
curl --request POST \
  --url https://console.mixroute.io/v1/models/gemini-embedding-001:embedContent \
  --header 'Authorization: Bearer sk-xxxxxxxxxx' \
  --header 'Content-Type: application/json' \
  --data '{
    "content": {
      "parts": [{"text": "This is a test text"}]
    }
  }'
{
  "embedding": {
    "values": [0.0023064255, -0.009327292, 0.015797347]
  },
  "metadata": {
    "usage": {
      "prompt_tokens": 6,
      "total_tokens": 6
    }
  }
}

Introduction

Convert text to vector embeddings using Gemini native interface. The model is specified via URL path (e.g., gemini-embedding-001), suitable for scenarios requiring Google embedding models or alignment with Gemini API. Complements the OpenAI format in Text Embedding: this document covers the Gemini native path; the same capability is also available via POST /v1/embeddings.

Authentication

Bearer Token, e.g., Bearer sk-xxxxxxxxxx

Path Parameters

model
string
required
Embedding model name, e.g., gemini-embedding-001.

Request Parameters

content
object
required
Content to embed. Must contain a parts array, each item as { "text": "text content" }.
outputDimensionality
integer
Output vector dimensions (only supported by some models, e.g., gemini-embedding-001, text-embedding-004).
taskType
string
Task type, e.g., RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY (optional).

Code Examples

curl -X POST "https://console.mixroute.io/v1/models/gemini-embedding-001:embedContent" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -d '{
    "content": {
      "parts": [
        { "text": "Text content to embed" }
      ]
    }
  }'

Response Example

{
  "embedding": {
    "values": [0.0023064255, -0.009327292, 0.015797347, ...]
  },
  "metadata": {
    "usage": {
      "prompt_tokens": 6,
      "total_tokens": 6
    }
  }
}

Batch Interface (batchEmbedContents)

For batch embedding, use: POST /v1/models/{model}:batchEmbedContents. The request body is a requests array, each item with the same structure as single requests (including content.parts), and do not include the model field in each item.
curl -X POST "https://console.mixroute.io/v1/models/gemini-embedding-001:batchEmbedContents" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -d '{
    "requests": [
      { "content": { "parts": [{ "text": "First text" }] } },
      { "content": { "parts": [{ "text": "Second text" }] } }
    ]
  }'

Supported Models

ModelDescription
gemini-embedding-001General-purpose embedding model, supports outputDimensionality
text-embedding-004High-precision embedding model

Notes

  • content.parts is required, at least one text must be non-empty
  • Model is specified via URL path, do not include model field in request body
  • Usage information is in metadata.usage in the response (prompt_tokens, total_tokens)
If your application already uses the OpenAI SDK, consider using the /v1/embeddings compatible interface to minimize code changes.
curl --request POST \
  --url https://console.mixroute.io/v1/models/gemini-embedding-001:embedContent \
  --header 'Authorization: Bearer sk-xxxxxxxxxx' \
  --header 'Content-Type: application/json' \
  --data '{
    "content": {
      "parts": [{"text": "This is a test text"}]
    }
  }'
{
  "embedding": {
    "values": [0.0023064255, -0.009327292, 0.015797347]
  },
  "metadata": {
    "usage": {
      "prompt_tokens": 6,
      "total_tokens": 6
    }
  }
}