Skip to content
TutujinAPI

API reference

Rerank API

Parameters, request and response examples for POST /v1/rerank — score and sort candidate documents by relevance to a query, typically right after retrieval in knowledge-base RAG. Uses the common query, documents and top_n format. Requests are relayed as-is.

POST /v1/rerank takes a query and a list of candidate documents, gives each document a relevance score and returns them sorted from most to least relevant. In knowledge-base RAG you typically retrieve a few dozen passages with vector search, then rerank them and pass only the best few to the chat model: answers get more accurate and the chat model reads less irrelevant text. The request uses the common query, documents and top_n fields and is relayed to the model service as-is.

POSThttps://www.tutujin.com/v1/rerank

Headers

HeaderRequiredDescription
AuthorizationYesBearer sk-..., an API key from the console
Content-TypeYesapplication/json

Request body

ParameterTypeRequiredDescription
modelstringYesModel name, e.g. qwen3-reranker-8b
querystringYesThe query, usually the user's question
documentsarrayYesCandidate documents, as an array of strings
top_nintegerNoReturn only the N highest-scoring documents; omit to return all
return_documentsbooleanNotrue includes each document's text in the results

Request example

curl https://www.tutujin.com/v1/rerank \
  -H "Authorization: Bearer $TUTUJIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-reranker-8b",
    "query": "Can I return an item after opening it?",
    "documents": [
      "Unopened items can be returned within 7 days of delivery, no reason needed.",
      "Orders ship within 48 hours of payment; holidays push this back.",
      "Opened items without a quality issue cannot be returned without a reason."
    ],
    "top_n": 2
  }'

Response example

JSON
{
  "results": [
    { "index": 2, "relevance_score": 0.93 },
    { "index": 0, "relevance_score": 0.71 }
  ],
  "usage": { "prompt_tokens": 96, "total_tokens": 96 }
}
FieldDescription
results[].indexPosition of the document in documents, starting at 0
results[].relevance_scoreRelevance score; higher is more relevant. Ranges differ by model, so compare scores within one request only
results[].documentPresent when return_documents is true; contains the document text
usageBilled usage; some models bill by tokens, some per request

Notes

  • This endpoint is relayed as-is and has not been verified separately on this site; check the response shape with a little traffic first.
  • Results are already sorted by score; use index to look up the original text.
  • More and longer candidates mean more usage. Retrieving 20 to 50 passages and keeping a top_n of 3 to 8 is usually enough.
  • Tune any score threshold on your own data. Scores mean different things on different models, so re-tune after switching models.
  • The full flow with vector search is in Enterprise knowledge base and RAG.

Models that support this endpoint

ModelVendorCheapest groupInput ¥/1MOutput ¥/1MPer request ¥
qwen3-reranker-0.6bQwenStandard——¥0.002
qwen3-reranker-4bQwenStandard——¥0.002
qwen3-reranker-8bQwenChina Models¥0.00308¥0.00308—
jina-reranker-v2-base-multilingualOtherStandard¥0.4¥0.4—
netease-youdao/bce-reranker-base_v1OtherStandard¥0.4¥0.4—
BAAI/bge-reranker-v2-m3OtherStandard¥0.4¥0.4—

Prices in CNY, cheapest group for each model; updated Nov 13, 2026, 6:08 PM.

Still stuck? Add our WeChat support JsnonoChat and send the request id from the error message, and we will look into it.