> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gravitex.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Rerank

> 쿼리와의 관련성에 따라 문서를 재정렬

## 소개

쿼리와의 관련성에 따라 후보 문서 목록을 재정렬합니다. RAG 및 지식베이스 검색에서 자주 사용됩니다.

## 인증

<ParamField header="Authorization" type="string" required>
  Bearer Token, 예: `Bearer sk-xxxxxxxxxx`
</ParamField>

## 요청 매개변수

<ParamField body="model" type="string" required>
  Rerank 모델, 예: `rerank-english-v2.0`
</ParamField>

<ParamField body="query" type="string" required>
  쿼리 텍스트
</ParamField>

<ParamField body="documents" type="array" required>
  재정렬할 문서(문자열 또는 객체)
</ParamField>

<ParamField body="top_n" type="integer">
  상위 N개 결과 반환
</ParamField>

<ParamField body="return_documents" type="boolean" default="false">
  결과에 문서 텍스트 포함
</ParamField>

## 요청 예시

```bash theme={null}
curl -X POST "https://api.gravitex.ai/v1/rerank" \
  -H "Authorization: Bearer sk-xxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "rerank-english-v2.0",
    "query": "What is a vector database?",
    "documents": [
      "Vector databases store and search embeddings",
      "Today is sunny",
      "RAG pipelines often use reranking"
    ],
    "top_n": 2,
    "return_documents": true
  }'
```

## 주요 매개변수

* **query**: 사용자 질문 또는 검색 쿼리
* **documents**: 후보 문단
* **top\_n**: 상위 N개 결과로 제한
* **return\_documents**: `true`일 때 원본 텍스트 포함

`results` 배열에는 `index`와 `relevance_score`가 포함되며, 점수 순으로 정렬됩니다.
