Gemini Text Embedding (embedContent)
curl --request POST \
--url https://api.leapx-hub.com/v1/models/{model}:embedContent \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"content": {},
"outputDimensionality": 123,
"taskType": "<string>"
}
'import requests
url = "https://api.leapx-hub.com/v1/models/{model}:embedContent"
payload = {
"content": {},
"outputDimensionality": 123,
"taskType": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({content: {}, outputDimensionality: 123, taskType: '<string>'})
};
fetch('https://api.leapx-hub.com/v1/models/{model}:embedContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.leapx-hub.com/v1/models/{model}:embedContent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'content' => [
],
'outputDimensionality' => 123,
'taskType' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.leapx-hub.com/v1/models/{model}:embedContent"
payload := strings.NewReader("{\n \"content\": {},\n \"outputDimensionality\": 123,\n \"taskType\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.leapx-hub.com/v1/models/{model}:embedContent")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"content\": {},\n \"outputDimensionality\": 123,\n \"taskType\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.leapx-hub.com/v1/models/{model}:embedContent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": {},\n \"outputDimensionality\": 123,\n \"taskType\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"embedding": {
"values": [0.0023064255, -0.009327292, 0.015797347, ...]
},
"metadata": {
"usage": {
"prompt_tokens": 6,
"total_tokens": 6
}
}
}
Text Embedding Series
Gemini Text Embedding (embedContent)
POST
/
v1
/
models
/
{model}
:embedContent
Gemini Text Embedding (embedContent)
curl --request POST \
--url https://api.leapx-hub.com/v1/models/{model}:embedContent \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"content": {},
"outputDimensionality": 123,
"taskType": "<string>"
}
'import requests
url = "https://api.leapx-hub.com/v1/models/{model}:embedContent"
payload = {
"content": {},
"outputDimensionality": 123,
"taskType": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({content: {}, outputDimensionality: 123, taskType: '<string>'})
};
fetch('https://api.leapx-hub.com/v1/models/{model}:embedContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.leapx-hub.com/v1/models/{model}:embedContent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'content' => [
],
'outputDimensionality' => 123,
'taskType' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.leapx-hub.com/v1/models/{model}:embedContent"
payload := strings.NewReader("{\n \"content\": {},\n \"outputDimensionality\": 123,\n \"taskType\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.leapx-hub.com/v1/models/{model}:embedContent")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"content\": {},\n \"outputDimensionality\": 123,\n \"taskType\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.leapx-hub.com/v1/models/{model}:embedContent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": {},\n \"outputDimensionality\": 123,\n \"taskType\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"embedding": {
"values": [0.0023064255, -0.009327292, 0.015797347, ...]
},
"metadata": {
"usage": {
"prompt_tokens": 6,
"total_tokens": 6
}
}
}
Introduction
Use the Gemini native API to convert text to vector embeddings. The model is specified in the URL path (e.g.gemini-embedding-001). Use this when you need Google embedding models or alignment with the Gemini API.
This complements the Embeddings (OpenAI-style) endpoint: this doc describes the Gemini native path; the same capability is also available via
POST /v1/embeddings.Authentication
string
required
Bearer token, e.g.
Bearer sk-xxxxxxxxxxPath Parameters
string
required
Embedding model name, e.g.
gemini-embedding-001. Do not send model in the request body.Request Parameters
object
required
Content to embed. Must include a
parts array; each item is { "text": "your text" }.integer
Output vector dimension (supported only by some models, e.g.
gemini-embedding-001, text-embedding-004).string
Task type, e.g.
RETRIEVAL_DOCUMENT, RETRIEVAL_QUERY (optional).cURL Example
curl -X POST "https://api.leapx-hub.com/v1/models/gemini-embedding-001:embedContent" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-XyLy**************************mIqSt" \
-d '{
"content": {
"parts": [
{ "text": "Text to embed" }
]
}
}'
curl -X POST "https://api.leapx-hub.com/v1/models/gemini-embedding-001:embedContent" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-XyLy**************************mIqSt" \
-d '{
"content": {
"parts": [
{ "text": "Text to embed" }
]
},
"outputDimensionality": 768
}'
Python Example
import requests
url = "https://api.leapx-hub.com/v1/models/gemini-embedding-001:embedContent"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer sk-XyLy**************************mIqSt"
}
payload = {
"content": {
"parts": [
{ "text": "Text to embed" }
]
}
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
embedding = data["embedding"]["values"]
print(f"Dimension: {len(embedding)}")
{
"embedding": {
"values": [0.0023064255, -0.009327292, 0.015797347, ...]
},
"metadata": {
"usage": {
"prompt_tokens": 6,
"total_tokens": 6
}
}
}
Batch (batchEmbedContents)
For batch embedding use:POST /v1/models/{model}:batchEmbedContents with a requests array; each item has the same shape as a single request (including content.parts). Do not include model in each item.
curl -X POST "https://api.leapx-hub.com/v1/models/gemini-embedding-001:batchEmbedContents" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-XyLy**************************mIqSt" \
-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-accuracy embedding model |
Notes
- The model is specified in the URL path; do not include
modelin the request body content.partsis required with at least one non-emptytext- Usage is returned in
metadata.usage(prompt_tokens,total_tokens)
