Gemini Embedding 2
模型信息
| 模型 ID | gemini-embedding-2 |
|---|
| 提供方 | google |
|---|
| 上下文长度 | 2,048 tokens |
|---|
| 能力 | embedding |
|---|
| 权限等级 | PAID |
|---|
| 免费试用 | 否 |
|---|
| 调用端点 | POST /v1/embeddings |
|---|
| 输入模态 | TEXT |
|---|
| 输出模态 | EMBEDDING |
|---|
| 价格 | text in $0.24 / 1M |
|---|
| 计费维度 | TEXT_INPUT_TOKEN |
|---|
调用示例
curl
curl https://api.mafdet.ai/v1/chat/completions \
-H "Authorization: Bearer sk-mafdet-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-embedding-2",
"messages": [{ "role": "user", "content": "Hello" }]
}'
Node.js
const res = await fetch("https://api.mafdet.ai/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MAFDET_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gemini-embedding-2",
messages: [{ role: "user", content: "Hello" }],
}),
});
const data = await res.json();
console.log(data.choices[0].message.content);
Python
from openai import OpenAI
client = OpenAI(
base_url="https://api.mafdet.ai/v1",
api_key="sk-mafdet-xxxxxxxxxxxxxxxx",
)
resp = client.chat.completions.create(
model="gemini-embedding-2",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
常见错误
查看完整错误码与排障 →