Skip to content

OpenAI Reranks ​

During the retrieval stage, search systems prioritize efficiency, which may result in candidate documents that are not sufficiently precise. Reranking models perform a second-stage ranking on the retrieved documents, placing the most relevant results at the top to significantly improve retrieval accuracy.

Endpoint ​

MethodEndpoint
POSThttps://neolink.com/api/v1/rerank

Authentication ​

MethodDescription
Bearer TokenInclude Authorization: Bearer <API_key> in the request header for account verification.

Request Headers ​

ParameterTypeRequiredDescription
Content-TypestringYesMedia type of the request body, set to application/json
AuthorizationstringYesBearer API_key for account verification

Request Body ​

ParameterTypeRequiredDefaultDescription
modelstringYes-Model ID to use
querystringYes-User's query text for relevance matching with documents
documentsarrayYes-List of documents to be ranked, each element is a string document
top_nintNo-Return the top N most relevant documents after ranking. If not specified, returns all documents in ranked order
instructstringNo-Task instruction to guide the model on how to understand the relationship between query and documents
return_documentsboolNotrueWhether to return original document content in the results

Request Example ​

bash
curl --location 'https://neolink.com/api/v1/rerank' \
     --header 'Authorization: Bearer <API Key>' \
     --header 'Content-Type: application/json' \
     --data '{
         "model": "<Model ID>",
         "documents": [
             "Text reranking models are widely used in search engines and recommendation systems to rank candidate texts based on their relevance.",
             "Quantum computing is a cutting-edge field in computer science.",
             "The development of pretrained language models has led to significant advances in text reranking models."
         ],
         "query": "What is a text reranking model?",
         "top_n": 2,
         "instruct": "Given a web search query, retrieve relevant passages that answer the query."
     }'
python
import requests

url = "https://neolink.com/api/v1/rerank"

headers = {
    "Authorization": "Bearer <API Key>",
    "Content-Type": "application/json",
}

payload = {
    "model": "<Model ID>",
    "documents": [
        "Text reranking models are widely used in search engines and recommendation systems to rank candidate texts based on their relevance.",
        "Quantum computing is a cutting-edge field in computer science.",
        "The development of pretrained language models has led to significant advances in text reranking models.",
    ],
    "query": "What is a text reranking model?",
    "top_n": 2,
    "instruct": (
        "Given a web search query, retrieve relevant passages "
        "that answer the query."
    ),
}

response = requests.post(
    url,
    headers=headers,
    json=payload,
    timeout=60,
)

response.raise_for_status()

print(response.status_code)
print(response.json())

Supported Model IDs:

  • qwen3-rerank