For the complete documentation index, see llms.txt. This page is also available as Markdown.

Rerank

Rerank documents

post

Returns relevance scores and the original document indexes. Text-only models accept text documents. Image documents support a multimodal reranker and a provider that supports the submitted format.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body

A query and candidate documents to rerank. Additional provider parameters may be supplied, but unsupported parameters can cause a request to fail or restrict eligible providers.

modelstringRequired

Choose an available model tagged Rerank.

Example: bge-reranker-v2-m3
querystringRequired

The query against which documents are scored.

Example: How can I reset my account password?
top_ninteger · min: 1Optional

The maximum number of ranked results to return. This does not limit the submitted documents processed by the reranker.

Example: 2
return_documentsboolean · nullableOptional

Request document content in the results. Support and returned document fields depend on the provider.

preferencestring · enumOptional

The provider preference for handling the request.

Possible values:
allowed_providersstring[] · nullableOptional

Provider IDs allowed to process the request, subject to project settings.

Example: ["berget","ionos"]
eu_nativeboolean · nullableOptional

Whether to use only providers based and regulated within the EU.

provider_orderstring · enum · nullableOptional

Set to custom to try allowed_providers in the listed order instead of using preference-based routing.

Possible values:
allow_quantizationboolean · nullableOptionalDeprecated

Deprecated. Use quantizations instead. When false, excludes quantized endpoints.

allow_zero_data_retentionboolean · nullableOptional

Whether to use only zero-data-retention providers.

enable_model_fallbackboolean · nullableOptional

Allow automatic model fallback. Project settings may override this value.

fallbacksstring[] · nullableOptional

Explicit fallback model IDs, tried in order. A nonempty list takes precedence over automatic fallback settings.

Other propertiesanyOptional
Responses
200

Ranked documents and input-token usage.

application/json
idstring · nullableOptional

Request identifier, when supplied by the provider.

post/rerank
curl https://api.cortecs.ai/v1/rerank \
  -H "Authorization: Bearer $CORTECS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "bge-reranker-v2-m3",
  "query": "How can I reset my account password?",
  "documents": [
    "To change your billing address, open Billing settings and update your payment details.",
    "To reset your password, select Forgot password on the login page and follow the emailed reset link.",
    "To update your profile picture, open Profile settings and upload a new image."
  ],
  "top_n": 2
}'
{
  "id": "rerank-example",
  "results": [
    {
      "index": 1,
      "relevance_score": 0.69482421875,
      "document": {
        "text": "To reset your password, select Forgot password on the login page and follow the emailed reset link."
      }
    },
    {
      "index": 2,
      "relevance_score": 0.000019252300262451172,
      "document": {
        "text": "To update your profile picture, open Profile settings and upload a new image."
      }
    }
  ],
  "usage": {
    "prompt_tokens": 91,
    "completion_tokens": 0,
    "total_tokens": 91,
    "cost": 10
  }
}

Last updated