Rerank
PreviewCohere-compatible document reranking. Reference for API version next.
On this page
Rerank documents
POST
/api/v1/llm/v1/rerank Cohere-compatible reranking with nebula-rerank: orders up to 256 documents by relevance to a query. Metered on input tokens at the flat Nebula input rate. Requires llm:access.
Authentication
- API key in X-API-Key
- API key or session token in Authorization: Bearer
Headers
Idempotency-KeystringRun this exact request at most once in 24 hours. A replay with the same key and the same body, from the same organization, user and API key, is refused with
409before any model call. See the Idempotency guide.- Minimum length
1
Request body
modelstring- Default
nebula-rerank
querystring Requireddocumentsarray of strings Required- Maximum items
256
top_ninteger or null- Minimum
1
return_documentsboolean- Default
false
Responses
200Ranked results.Body (application/json)
idstringmodelstring- Always
nebula-rerank
resultsarray of objects3 fields in
resultsindexintegerPosition of the document in your request.
relevance_scorenumberdocumentobjectPresent when
return_documentsis true.1 field in
documenttextstring
usageobject2 fields in
usageprompt_tokensintegertotal_tokensinteger
402The organization has no spendable credit, or its self-service spend cap is reached. Top up or raise the cap in the console. This status currently carriesmessage: "Error"andcode: "INTERNAL_9001"; rely on the HTTP status.Error envelope409This exact request (sameIdempotency-Keyand body) already ran, so it was not run again. Send a newIdempotency-Keyto run it again.Error envelope429A per-user limit was exceeded (the Platform API, embeddings or rerank). This response does not use the error envelope. Wait forRetry-Afterseconds.Headers
X-Request-IDstringThe request's correlation id (yours, or one BreachLine generated). Quote it to support.
Retry-AfterintegerSeconds to wait before retrying.
Body (application/json)
detailstring Requiredretry_afterinteger Required- Always
60
503A dependency is temporarily unavailable. Retry with backoff; honourRetry-Afterwhen present.Error envelope
Example
curl -X POST "https://api.breachline.io/api/v1/llm/v1/rerank" \
-H "Authorization: Bearer $BREACHLINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "Which finding affects authentication?",
"documents": [
"Missing rate limit on the password reset endpoint",
"Verbose server banner on the marketing site"
],
"top_n": 1
}'
{
"id": "string",
"model": "nebula-rerank",
"results": [
{
"index": 0,
"relevance_score": 0,
"document": {
"text": "string"
}
}
],
"usage": {
"prompt_tokens": 0,
"total_tokens": 0
}
}