Semantic Ranker
Orders documents by relevance to a query, for search and RAG.
- by Google
- Rerank
- $1 per 1,000 requests
- SearchRAG
On this page
1.Call
Send a query and a list of documents; get them back ordered by relevance. Every response carries an x-request-id trace ID.
curl https://api.ewest.ai/v1/rerank \
-H "Authorization: Bearer $EWEST_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "ewest/semantic-ranker", "query": "How do I get a refund?", "top_n": 2,
"documents": ["Refunds are issued within 5 days.", "Our office is in Yerevan.", "Contact support to cancel an order."]}'
# → {"results": [{"index": 0, "relevance_score": 0.91}, {"index": 2, "relevance_score": 0.42}]}2.Authentication
Send your API key in the Authorization: Bearer header, as the examples above do (clients built for the Anthropic API can use x-api-key). Create keys under API keys. Keep the key on your server, never in browser code. More in the authentication guide.
3.Schema
What you send and what comes back, for ewest/semantic-ranker. The output tables are read from the API's OpenAPI description.
Input
POST /v1/rerank- The model id,
modelstringRequiredewest/semantic-ranker. - What to search for.
querystringRequired - The texts to order, up to 100.
documentsarrayRequired - Return only the best n results.
top_nintegerOptional
Output
Returns a ranking of your documents. POST /v1/rerank answers 200: Results, best first.
- Unique id of the request.
idstringSometimes - Ordered by
resultsarray of objectAlwaysrelevance_score, best first. - Position in
results[].indexintegerAlwaysdocuments. - How well the document matches the query; higher is better.
results[].relevance_scorenumberAlways - The document (
results[].documentobjectSometimes{"text": ...}). Present on every result when the request setreturn_documents: true, absent otherwise (useindexto find the document in your own list). - The document text.
results[].document.textstringSometimes - Usage information of the request.
metaobjectSometimes - What the request was billed for.
meta.billed_unitsobjectSometimes - Number of search units billed.
meta.billed_units.search_unitsintegerSometimes
Sample response
{
"results": [
{
"index": 0,
"relevance_score": 0.97
},
{
"index": 1,
"relevance_score": 0.04
}
]
}4.Details
- Documents
- Up to 100 per request
- API
- POST /v1/rerank (Cohere-style request and response)