创建向量
curl --request POST \
--url https://api.omnirelay.ai/v1/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": "<string>"
}
'import requests
url = "https://api.omnirelay.ai/v1/embeddings"
payload = {
"model": "<string>",
"input": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', input: '<string>'})
};
fetch('https://api.omnirelay.ai/v1/embeddings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"object": "list",
"model": "<string>",
"data": [
{
"object": "embedding",
"index": 1,
"embedding": [
123
]
}
],
"usage": {
"prompt_tokens": 1,
"total_tokens": 1
},
"cost_microusd": 123
}{
"error": {
"code": "unsupported_parameter"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "unauthorized"
}
}{
"error": {
"code": "insufficient_balance"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_not_allowed"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_unavailable"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "payload_too_large"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "rate_limited"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_unavailable",
"message": "The model does not exist or is disabled.",
"type": "not_found_error",
"param": "<string>"
},
"request_id": "<string>"
}{
"error": {
"code": "live_provider_not_configured"
},
"request_id": "2f6c1d0e9a"
}向量
创建向量
面向 capabilities.embeddings=true 模型的仅输入计费向量接口。目前没有开通向量模型;开放前需核验模型、维度、整次请求输入上界及输入价格。仅支持 float 向量,批量和可调整维度按模型合同决定。
POST
/
v1
/
embeddings
创建向量
curl --request POST \
--url https://api.omnirelay.ai/v1/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": "<string>"
}
'import requests
url = "https://api.omnirelay.ai/v1/embeddings"
payload = {
"model": "<string>",
"input": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', input: '<string>'})
};
fetch('https://api.omnirelay.ai/v1/embeddings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"object": "list",
"model": "<string>",
"data": [
{
"object": "embedding",
"index": 1,
"embedding": [
123
]
}
],
"usage": {
"prompt_tokens": 1,
"total_tokens": 1
},
"cost_microusd": 123
}{
"error": {
"code": "unsupported_parameter"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "unauthorized"
}
}{
"error": {
"code": "insufficient_balance"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_not_allowed"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_unavailable"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "payload_too_large"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "rate_limited"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_unavailable",
"message": "The model does not exist or is disabled.",
"type": "not_found_error",
"param": "<string>"
},
"request_id": "<string>"
}{
"error": {
"code": "live_provider_not_configured"
},
"request_id": "2f6c1d0e9a"
}授权
在 OmniRelay 控制台创建的 API Key。所有者确认身份后可在控制台再次查看。
请求头
本次调用的标签,以逗号分隔的 key=value,例如 client=acme,env=prod。与 API Key 的默认标签合并;同名 key 以请求体 tags 字段为准。X-OmniRelay-Tags 是同一个请求头的旧名,继续接受。
传 enabled 时,响应会附带 gateway_metadata,说明网关为本次调用做出的决定。其他值或不传此头,响应保持不变。X-OmniRelay-Metadata 是同一个请求头的旧名,继续接受。
可用选项:
enabled 请求体
application/json
Required string length:
1 - 65536可用选项:
float 要求所选向量模型已验证可调整维度。
必填范围:
1 <= x <= 16384本次调用的标签。与请求头和 Key 默认标签合并后最多 10 个。key 为 1 至 64 个字符,统一存为小写;value 为 1 至 128 个字符。两者只能包含字母、数字和 - _ . : /。以 gateway: 或 omnirelay: 开头的 key 为保留字。tags 不是对象时会被忽略。
Show child attributes
Show child attributes
示例:
{ "client": "acme", "project": "invoices" }