Документация / API
Поиск и ранжирование
Векторные представления текста и ранжирование документов по запросу.
Модели эмбеддингов →Модели ранжирования →
Эмбеддинги переводят текст в векторы для поиска по смыслу; ранжирование упорядочивает документы по запросу.
/v1/embeddingsCreate embeddings
Ключ: заголовок Authorization: Bearer <ключ>. Как получить ключ →
Тело запроса
application/json
dimensionsintegerencoding_formatstringЗначения:
float,base64inputstring | array of stringобязательноеText or texts.
modelstringобязательное- Остальные поля формата OpenRouter передаются модели без изменений.
Пример запроса
{
"input": "The quick brown fox",
"model": "openai/text-embedding-3-small"
}Ответ 200
Embeddings.
dataarray of objectобязательноеembeddingarray of numberindexintegerobjectstring
modelstringobjectstringusageobjectcompletion_tokensintegercostnumber | nullAmount actually charged, in roubles with five decimals (thousandths of a kopeck). null while the provider cost is being fetched (pending) or the charge is under review.
cost_statusstringfinal — charged by the provider's actual cost; estimated — by our price table; pending — the cost is being fetched, the charge follows; review — an operator decides.
Значения:
final,estimated,pending,reviewprompt_tokensintegertotal_tokensinteger
- Остальные поля формата OpenRouter передаются модели без изменений.
Пример ответа
{
"data": [
{
"embedding": [
0.0123,
-0.0456
],
"index": 0,
"object": "embedding"
}
],
"model": "openai/text-embedding-3-small",
"object": "list",
"usage": {
"cost": 0.00009,
"cost_status": "final",
"prompt_tokens": 5,
"total_tokens": 5
}
}Ошибки
- 400The request is invalid or its cost cannot be bounded in advance. Nothing is charged.
- 401Missing or invalid API key.
- 402The balance does not cover the reserve of this request.
- 403The input was flagged by moderation; metadata.reasons lists why.
- 404The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 413The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 422The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 429Too many requests, or the model provider is busy. Retry-After, when present, says when to retry.
- 502The model provider failed or returned an error.
- 503Billing or the model provider is temporarily unavailable.
Формат тела ошибки и что делать — Лимиты и ошибки.
/v1/rerankRerank documents
Ключ: заголовок Authorization: Bearer <ключ>. Как получить ключ →
Тело запроса
application/json
documentsarray of stringобязательноеmodelstringобязательноеquerystringобязательноеtop_ninteger- Остальные поля формата OpenRouter передаются модели без изменений.
Пример запроса
{
"documents": [
"Paris is the capital of France.",
"Berlin is in Germany."
],
"model": "cohere/rerank-v3.5",
"query": "capital of France"
}Ответ 200
Documents ordered by relevance.
idstringmodelstringresultsarray of objectобязательноеindexintegerrelevance_scorenumber
usageobjectcompletion_tokensintegercostnumber | nullAmount actually charged, in roubles with five decimals (thousandths of a kopeck). null while the provider cost is being fetched (pending) or the charge is under review.
cost_statusstringfinal — charged by the provider's actual cost; estimated — by our price table; pending — the cost is being fetched, the charge follows; review — an operator decides.
Значения:
final,estimated,pending,reviewprompt_tokensintegertotal_tokensinteger
- Остальные поля формата OpenRouter передаются модели без изменений.
Пример ответа
{
"id": "gen-rerank-1",
"model": "cohere/rerank-v3.5",
"results": [
{
"index": 0,
"relevance_score": 0.98
},
{
"index": 1,
"relevance_score": 0.02
}
],
"usage": {
"cost": 0.17,
"cost_status": "final"
}
}Ошибки
- 400The request is invalid or its cost cannot be bounded in advance. Nothing is charged.
- 401Missing or invalid API key.
- 402The balance does not cover the reserve of this request.
- 403The input was flagged by moderation; metadata.reasons lists why.
- 404The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 413The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 422The model provider rejected the request (its status is kept: 400, 404, 413 or 422); metadata.provider_message, when present, is the provider's explanation.
- 429Too many requests, or the model provider is busy. Retry-After, when present, says when to retry.
- 502The model provider failed or returned an error.
- 503Billing or the model provider is temporarily unavailable.
Формат тела ошибки и что делать — Лимиты и ошибки.