curl --request POST \
--url 'https://api.elkapi.com/v1/embeddings' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "text-embedding-3-large",
"input": "今天天气真好,适合出去散步。"
}'
import requests
url = "https://api.elkapi.com/v1/embeddings"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "text-embedding-3-large",
"input": "今天天气真好,适合出去散步。"
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/embeddings";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "text-embedding-3-large",
"input": "今天天气真好,适合出去散步。"
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 1,
"embedding": [
1
]
}
],
"model": "text-embedding-3-large",
"usage": {
"prompt_tokens": 1,
"total_tokens": 1
}
}
原生 OpenAI 格式
创建 Embedding
- 将文本转换为向量嵌入
POST
/
v1
/
embeddings
curl --request POST \
--url 'https://api.elkapi.com/v1/embeddings' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "text-embedding-3-large",
"input": "今天天气真好,适合出去散步。"
}'
import requests
url = "https://api.elkapi.com/v1/embeddings"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "text-embedding-3-large",
"input": "今天天气真好,适合出去散步。"
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/embeddings";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "text-embedding-3-large",
"input": "今天天气真好,适合出去散步。"
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 1,
"embedding": [
1
]
}
],
"model": "text-embedding-3-large",
"usage": {
"prompt_tokens": 1,
"total_tokens": 1
}
}
curl --request POST \
--url 'https://api.elkapi.com/v1/embeddings' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "text-embedding-3-large",
"input": "今天天气真好,适合出去散步。"
}'
import requests
url = "https://api.elkapi.com/v1/embeddings"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "text-embedding-3-large",
"input": "今天天气真好,适合出去散步。"
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/embeddings";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "text-embedding-3-large",
"input": "今天天气真好,适合出去散步。"
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 1,
"embedding": [
1
]
}
],
"model": "text-embedding-3-large",
"usage": {
"prompt_tokens": 1,
"total_tokens": 1
}
}
Authorizations
string
必填
所有接口均需要使用 Bearer Token 进行认证。在请求头中添加:
Authorization: Bearer YOUR_API_KEY
Body
string
默认值:"text-embedding-3-large"
必填
示例:
text-embedding-3-largestring or array<string>
必填
要嵌入的文本
string
默认值:"float"
可选值:
float、base64integer
输出向量维度
Response
string
示例:
liststring
默认值:"text-embedding-3-large"
示例:
text-embedding-3-large⌘I