Overview
This interface is used to rerank the input documents and return the documents most relevant to the query. It is an alias for the /api/v1/rerank interface and behaves identically.
API details
Constraints
- The caller must have an API Key. For more information, see Manage AI API Key.
Request path
POST {BASE_URL}/api/v1/reranks
Request header
Name |
Required |
Example value |
Description |
|---|---|---|---|
| Authorization | Yes | Bearer {token} | Authentication information |
| Content-Type | No | application/json | Request body format |
Request parameters
Path
None
Query
None
Body
Name |
Type |
Required |
Example value |
Description |
|---|---|---|---|---|
| model | string | Yes | rerank-model-v1 | The identifier for the reranking model |
| query | string | Yes | What is machine learning? | The query text |
| documents | array | Yes | ["Document A content", "Document B content"] | The list of documents to be sorted |
| input | object | No | {} | Input parameters object |
| top_n | integer | No | 5 | The number of most relevant documents to return. Defaults to returning all. |
| return_documents | boolean | No | false | Whether to include document content in the response |
| parameters | object | No | {} | Model-specific parameters |
Response
Response parameters
Name |
Type |
Description |
|---|---|---|
| success | boolean | Whether the request was successful |
| code | string | The response code |
| message | string | The response message |
| data | object | The business response data |
data
The specific structure of the returned data depends on the model and parameters, and typically includes information such as the sorted document index and score.
Request example
curl --request POST '{BASE_URL}/api/v1/reranks' \
--header 'Authorization: Bearer {token}' \
--header 'Content-Type: application/json' \
--data '{
"model": "rerank-model-v1",
"query": "What is machine learning?",
"documents": ["Machine learning is a branch of artificial intelligence...", "Deep learning is a type of machine learning..."],
"top_n": 3
}'
Response example
{
"success": true,
"code": "200",
"message": "successful",
"data": {
"results": [
{
"index": 0,
"relevance_score": 0.95
},
{
"index": 1,
"relevance_score": 0.82
}
]
}
}
