curl --request POST \
--url https://api.mixroute.ai/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"}]
}
}'
import requests
url = "https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent"
headers = {
"Authorization": "Bearer sk-xxxxxxxxxx",
"Content-Type": "application/json"
}
payload = {
"content": {
"parts": [{"text": "This is a test text"}]
}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch('https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-xxxxxxxxxx',
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: {
parts: [{ text: 'This is a test text' }]
}
})
});
const data = await response.json();
console.log(data);
<?php
$client = new GuzzleHttp\Client();
$response = $client->post('https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent', [
'headers' => [
'Authorization' => 'Bearer sk-xxxxxxxxxx',
'Content-Type' => 'application/json',
],
'json' => [
'content' => [
'parts' => [['text' => 'This is a test text']]
]
]
]);
echo $response->getBody();
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
payload := map[string]interface{}{
"content": map[string]interface{}{
"parts": []map[string]string{
{"text": "This is a test text"},
},
},
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer sk-xxxxxxxxxx")
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
import java.net.http.*;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String json = """
{
"content": {
"parts": [{"text": "This is a test text"}]
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent"))
.header("Authorization", "Bearer sk-xxxxxxxxxx")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
require 'net/http'
require 'json'
uri = URI('https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer sk-xxxxxxxxxx'
request['Content-Type'] = 'application/json'
request.body = {
content: {
parts: [{ text: 'This is a test text' }]
}
}.to_json
response = http.request(request)
puts response.body
{
"embedding": {
"values": [0.0023064255, -0.009327292, 0.015797347]
},
"metadata": {
"usage": {
"prompt_tokens": 6,
"total_tokens": 6
}
}
}
Embedding Series
Gemini Text Embedding (embedContent)
Convert text to vector embeddings using Gemini native interface
POST
/
v1
/
models
/
{model}
:embedContent
curl --request POST \
--url https://api.mixroute.ai/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"}]
}
}'
import requests
url = "https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent"
headers = {
"Authorization": "Bearer sk-xxxxxxxxxx",
"Content-Type": "application/json"
}
payload = {
"content": {
"parts": [{"text": "This is a test text"}]
}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch('https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-xxxxxxxxxx',
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: {
parts: [{ text: 'This is a test text' }]
}
})
});
const data = await response.json();
console.log(data);
<?php
$client = new GuzzleHttp\Client();
$response = $client->post('https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent', [
'headers' => [
'Authorization' => 'Bearer sk-xxxxxxxxxx',
'Content-Type' => 'application/json',
],
'json' => [
'content' => [
'parts' => [['text' => 'This is a test text']]
]
]
]);
echo $response->getBody();
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
payload := map[string]interface{}{
"content": map[string]interface{}{
"parts": []map[string]string{
{"text": "This is a test text"},
},
},
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer sk-xxxxxxxxxx")
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
import java.net.http.*;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String json = """
{
"content": {
"parts": [{"text": "This is a test text"}]
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent"))
.header("Authorization", "Bearer sk-xxxxxxxxxx")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
require 'net/http'
require 'json'
uri = URI('https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer sk-xxxxxxxxxx'
request['Content-Type'] = 'application/json'
request.body = {
content: {
parts: [{ text: 'This is a test text' }]
}
}.to_json
response = http.request(request)
puts response.body
{
"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
string
required
Embedding model name, e.g.,
gemini-embedding-001.Request Parameters
object
required
Content to embed. Must contain a
parts array, each item as { "text": "text content" }.integer
Output vector dimensions (only supported by some models, e.g.,
gemini-embedding-001, text-embedding-004).string
Task type, e.g.,
RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY (optional).Code Examples
- cURL
- cURL (with dimensions)
- Python
curl -X POST "https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"content": {
"parts": [
{ "text": "Text content to embed" }
]
}
}'
curl -X POST "https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"content": {
"parts": [
{ "text": "Text content to embed" }
]
},
"outputDimensionality": 768
}'
import requests
url = "https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer sk-xxxxxxxxxx"
}
payload = {
"content": {
"parts": [
{ "text": "Text content to embed" }
]
}
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
embedding = data["embedding"]["values"]
print(f"Vector dimensions: {len(embedding)}")
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://api.mixroute.ai/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
| Model | Description |
|---|---|
| gemini-embedding-001 | General-purpose embedding model, supports outputDimensionality |
| text-embedding-004 | High-precision embedding model |
Notes
content.partsis required, at least onetextmust be non-empty- Model is specified via URL path, do not include
modelfield in request body - Usage information is in
metadata.usagein 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://api.mixroute.ai/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"}]
}
}'
import requests
url = "https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent"
headers = {
"Authorization": "Bearer sk-xxxxxxxxxx",
"Content-Type": "application/json"
}
payload = {
"content": {
"parts": [{"text": "This is a test text"}]
}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch('https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-xxxxxxxxxx',
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: {
parts: [{ text: 'This is a test text' }]
}
})
});
const data = await response.json();
console.log(data);
<?php
$client = new GuzzleHttp\Client();
$response = $client->post('https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent', [
'headers' => [
'Authorization' => 'Bearer sk-xxxxxxxxxx',
'Content-Type' => 'application/json',
],
'json' => [
'content' => [
'parts' => [['text' => 'This is a test text']]
]
]
]);
echo $response->getBody();
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
payload := map[string]interface{}{
"content": map[string]interface{}{
"parts": []map[string]string{
{"text": "This is a test text"},
},
},
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer sk-xxxxxxxxxx")
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
import java.net.http.*;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String json = """
{
"content": {
"parts": [{"text": "This is a test text"}]
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent"))
.header("Authorization", "Bearer sk-xxxxxxxxxx")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
require 'net/http'
require 'json'
uri = URI('https://api.mixroute.ai/v1/models/gemini-embedding-001:embedContent')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer sk-xxxxxxxxxx'
request['Content-Type'] = 'application/json'
request.body = {
content: {
parts: [{ text: 'This is a test text' }]
}
}.to_json
response = http.request(request)
puts response.body
{
"embedding": {
"values": [0.0023064255, -0.009327292, 0.015797347]
},
"metadata": {
"usage": {
"prompt_tokens": 6,
"total_tokens": 6
}
}
}
⌘I