Platform notice: all DeepSeek models are now live. New users receive trial credits on sign-up.
Api reference

Rerank

Reorder candidate documents by relevance to a query, callable with API Keys and billed per call.

Rerank is the precision stage after retrieval: it scores and reorders recalled candidate documents against the query.

POST /api/v1/rerank
  • Auth: Authorization: Bearer sk-tp-...
  • Content-Type: application/json

Request body

ParameterTypeRequiredDescription
modelstringYesPlatform rerank model name, see Models
querystringYesQuery text
documentsstring[]YesCandidate documents; must not be empty
top_nnumberNoReturn only the first N results
return_documentsbooleanNoInclude the original document text in the results
curl https://api.openruler.ai/api/v1/rerank \
  -H "Authorization: Bearer sk-tp-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bge-reranker-v2-m3",
    "query": "How do I request an invoice?",
    "documents": ["Invoice request flow", "Creating an API Key", "Top-up methods"],
    "top_n": 2
  }'

Response

The upstream rerank result is passed through, typically { results: [{ index, relevance_score }], usage }; exact fields depend on the model.

Billing

  • Billed per call at "yuan per call"; the model must use per-call pricing.
  • Responses include X-Cost-Yuan (cost) and X-Bill-Units (always 1) headers.

Pre-checks

  1. Key valid and not revoked (including all parents), account active → otherwise 401
  2. Model exists and is live (LIVE), priced per call with a unit price → otherwise 400
  3. Model category is "rerank" → otherwise 400
  4. query and documents are not empty → otherwise 400
  5. Balance above zero and Key chain quota not exhausted → otherwise 402

Errors

For error format and troubleshooting see FAQ · Error codes. Upstream errors are passed through unchanged.

On this page

OpenRuler