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.
- Auth:
Authorization: Bearer sk-tp-... - Content-Type:
application/json
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Platform rerank model name, see Models |
| query | string | Yes | Query text |
| documents | string[] | Yes | Candidate documents; must not be empty |
| top_n | number | No | Return only the first N results |
| return_documents | boolean | No | Include the original document text in the results |
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) andX-Bill-Units(always 1) headers.
Pre-checks
- Key valid and not revoked (including all parents), account active → otherwise
401 - Model exists and is live (
LIVE), priced per call with a unit price → otherwise400 - Model category is "rerank" → otherwise
400 queryanddocumentsare not empty → otherwise400- 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.