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 ベクトルを作成します。テキストのみのリクエストは入力ごとに1つのベクトルを返し、検索、セマンティック検索、クラスタリング、分類、RAG に適しています。メディア(base64 data URI として渡す画像、音声、動画)を含むリクエストは、すべての入力を単一のクロスモーダルベクトルに融合します。アセットごとに1つのベクトルが必要な場合は、各アセットを個別のリクエストで embedding してください。OpenAI Embeddings API フォーマットと互換性があります。このエンドポイントはストリーミングに対応していません。
認証
string
必須
Bearerトークン。APIキーをAuthorizationヘッダーのBearerトークンとして使用してください。Format:
Bearer <SUNRA_KEY>リクエスト
このエンドポイントはJSONオブジェクトを受け付けます。string | string[]
必須
embedding する入力。単一の文字列または文字列の配列を指定できます。テキストのみの入力は独立して embedding され、入力と同じ順序で入力ごとに1つのベクトルが返されます。メディア入力は base64 data URI(
data:image/png;base64,…、data:audio/mpeg;base64,…、data:video/mp4;base64,…)として渡し、テキストと混在させることもできます。ただし、メディアを含むリクエストは、すべての入力をまとめて融合した単一のベクトルを返します。制限(上流側):1リクエストあたり画像は最大6枚、動画は最長120秒、全モダリティ合計で 8,192 トークンまで(テキストトークン換算。画像は1枚あたり258トークン、音声は1秒あたり25トークン、動画は1秒あたり66トークン)。integer
出力 embedding の次元数。柔軟な出力次元(Matryoshka Representation Learning)に対応したモデルでのみ利用できます。
google/gemini-embedding-2 のデフォルトは 3072 で、128 から 3072 までの値に対応しています。小さい値はベクトルを切り詰めますが、意味的な品質はほぼ維持されます。string
返される embedding のフォーマット。
float(デフォルト)または base64。レスポンス
string
常に
list です。object[]
string
embedding の作成に使用されたモデル。
object
リクエストのトークン使用量。embedding は入力トークンのみで課金され、モダリティごとに料金が異なります(料金はモデルページをご覧ください)。メディアを含むリクエストにはモダリティ別のトークン数が含まれます。
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