Skip to main content

Reranker

Cross-encoder reranker for retrieval pipelines. Non-OpenAI extension — schema follows Cohere's /rerank API.

POST https://api.ecohash.com/v1/rerank

Headers

HeaderValue
AuthorizationBearer eco_YOUR_KEY
Content-Typeapplication/json

Request body

FieldTypeRequiredNotes
modelstringyesReranker model ID
querystringyesUser's query
documentsarray of stringsyesCandidate documents to rerank — 1 to 1000
top_nintegernoReturn only the top N scoring documents (default: all)
return_documentsboolnoInclude the document text in each result (default: false)

Example request

curl https://api.ecohash.com/v1/rerank \
-H "Authorization: Bearer eco_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "bge-reranker-v2-m3",
"query": "how does solar power work?",
"documents": [
"Solar panels convert sunlight into electricity.",
"My cat enjoys the sun but cannot generate power.",
"Photovoltaic cells transform photons into electric current."
],
"top_n": 2
}'

Response body

{
"results": [
{ "index": 0, "relevance_score": 0.987 },
{ "index": 2, "relevance_score": 0.945 }
],
"model": "bge-reranker-v2-m3",
"usage": { "total_tokens": 64 }
}

results is sorted by relevance_score descending. index maps back to the original documents array position.

If return_documents: true, each result also includes a document: {text: "..."} field.

Errors

See Errors. Common: 401, 402, 404, 429.