curl -X POST https://api-llm.sunra.ai/v1/embeddings \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-embedding-2",
"input": [
"The quick brown fox jumps over the lazy dog.",
"Sunra is a platform for AI models."
],
"dimensions": 768
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/embeddings",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "google/gemini-embedding-2",
"input": [
"The quick brown fox jumps over the lazy dog.",
"Sunra is a platform for AI models."
],
"dimensions": 768
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/embeddings", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "google/gemini-embedding-2",
input: [
"The quick brown fox jumps over the lazy dog.",
"Sunra is a platform for AI models."
],
dimensions: 768
})
});
const data = await response.json();
console.log(data);
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.011253, -0.020551, 0.049236, "..."]
},
{
"object": "embedding",
"index": 1,
"embedding": [0.031744, 0.008122, -0.014307, "..."]
}
],
"model": "google/gemini-embedding-2",
"usage": {
"prompt_tokens": 18,
"total_tokens": 18
}
}
LLM
Create embeddings
POST
/
v1
/
embeddings
curl -X POST https://api-llm.sunra.ai/v1/embeddings \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-embedding-2",
"input": [
"The quick brown fox jumps over the lazy dog.",
"Sunra is a platform for AI models."
],
"dimensions": 768
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/embeddings",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "google/gemini-embedding-2",
"input": [
"The quick brown fox jumps over the lazy dog.",
"Sunra is a platform for AI models."
],
"dimensions": 768
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/embeddings", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "google/gemini-embedding-2",
input: [
"The quick brown fox jumps over the lazy dog.",
"Sunra is a platform for AI models."
],
dimensions: 768
})
});
const data = await response.json();
console.log(data);
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.011253, -0.020551, 0.049236, "..."]
},
{
"object": "embedding",
"index": 1,
"embedding": [0.031744, 0.008122, -0.014307, "..."]
}
],
"model": "google/gemini-embedding-2",
"usage": {
"prompt_tokens": 18,
"total_tokens": 18
}
}
從文字或媒體輸入建立 embedding 向量。純文字請求每條輸入回傳一個向量,適用於檢索、語義搜尋、聚類、分類和 RAG。包含媒體(以 base64 data URI 形式傳入的圖片、音訊或影片)的請求會將所有輸入融合為單一跨模態向量——如需每個資產各得一個向量,請將每個資產放在單獨的請求中進行 embedding。相容 OpenAI Embeddings API 格式。此端點不支援串流。
認證
string
必填
Bearer 令牌。在 Authorization 請求標頭中使用您的 API 金鑰作為 Bearer 令牌。Format:
Bearer <SUNRA_KEY>請求
此端點接受一個 JSON 物件。string | string[]
必填
要進行 embedding 的輸入,可以是單一字串或字串陣列。純文字輸入獨立進行 embedding,按輸入順序每條回傳一個向量。媒體輸入以 base64 data URI 形式傳入(
data:image/png;base64,…、data:audio/mpeg;base64,…、data:video/mp4;base64,…),可與文字混合——但任何包含媒體的請求都會為全部輸入回傳一個融合後的單一向量。限制(來自上游):每個請求最多 6 張圖片,影片最長 120 秒,所有模態合計不超過 8,192 個 token(按文字 token 計;圖片每張 258 個 token,音訊每秒 25 個 token,影片每秒 66 個 token)。integer
輸出 embedding 的維度數。僅支援具有靈活輸出維度(Matryoshka Representation Learning)的模型。
google/gemini-embedding-2 預設為 3072,支援 128 到 3072 之間的值。較小的值會截斷向量,同時保留大部分語義品質。string
回傳 embedding 的格式。
float(預設)或 base64。回應
string
始終為
list。object[]
string
用於建立 embedding 的模型。
object
curl -X POST https://api-llm.sunra.ai/v1/embeddings \
-H "Authorization: Bearer <SUNRA_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-embedding-2",
"input": [
"The quick brown fox jumps over the lazy dog.",
"Sunra is a platform for AI models."
],
"dimensions": 768
}'
import requests
response = requests.post(
"https://api-llm.sunra.ai/v1/embeddings",
headers={
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
json={
"model": "google/gemini-embedding-2",
"input": [
"The quick brown fox jumps over the lazy dog.",
"Sunra is a platform for AI models."
],
"dimensions": 768
}
)
print(response.json())
const response = await fetch("https://api-llm.sunra.ai/v1/embeddings", {
method: "POST",
headers: {
"Authorization": "Bearer <SUNRA_KEY>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "google/gemini-embedding-2",
input: [
"The quick brown fox jumps over the lazy dog.",
"Sunra is a platform for AI models."
],
dimensions: 768
})
});
const data = await response.json();
console.log(data);
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.011253, -0.020551, 0.049236, "..."]
},
{
"object": "embedding",
"index": 1,
"embedding": [0.031744, 0.008122, -0.014307, "..."]
}
],
"model": "google/gemini-embedding-2",
"usage": {
"prompt_tokens": 18,
"total_tokens": 18
}
}
⌘I