메인 콘텐츠로 건너뛰기
시맨틱 유사도 모델을 사용하여 문서의 순위를 재조정합니다. 검색 결과 개선 및 RAG 애플리케이션에 유용합니다.

요청 본문

동기 요청 타임아웃: 이 비채팅 엔드포인트는 라우팅된 모델이 완료될 때까지 기다립니다. 큰 입력, 긴 오디오, 큰 배치는 일반적인 30s 클라이언트 기본값을 초과할 수 있으므로 HTTP 클라이언트 타임아웃을 최소 120s 로 설정하세요.
model
string
필수
사용할 reranker 모델의 ID입니다 (예: qwen3-vl-rerank).
query
string
필수
문서 순위를 매길 기준이 되는 쿼리입니다. 최대 길이: 32,000자.
documents
array
필수
재순위화할 문서(문자열) 목록입니다. 제한: 최대 1,000개 문서, 각 문서는 최대 100,000자, 전체 문서 합계는 최대 2,000,000자입니다.
top_n
integer
반환할 상위 결과 수입니다. 기본값은 모든 documents입니다. 최소 1 이상, documents.length 이하여야 합니다. provider가 나중에 더 엄격한 공개 제한을 발표하면 TokenLab은 여기에 문서화하고 적용합니다.
return_documents
boolean
기본값:"false"
응답에 원본 문서 텍스트를 포함할지 여부입니다.

응답 (Response)

results
array
점수가 포함된 문서의 순위 목록입니다.각 결과에는 다음이 포함됩니다:
  • index (integer): 원본 문서 인덱스
  • relevance_score (number): 관련성 점수 (0-1)
  • document (string): 원본 텍스트 (return_documents=true인 경우)
model
string
재순위화에 사용된 모델입니다.
usage
object
토큰 사용량 통계입니다.
curl -X POST "https://api.tokenlab.sh/v1/rerank" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-vl-rerank",
    "query": "What is machine learning?",
    "documents": [
      "Machine learning is a subset of AI",
      "The weather is nice today",
      "Deep learning uses neural networks"
    ],
    "top_n": 2,
    "return_documents": true
  }'
import requests

response = requests.post(
    "https://api.tokenlab.sh/v1/rerank",
    headers={"Authorization": "Bearer sk-your-api-key"},
    json={
        "model": "qwen3-vl-rerank",
        "query": "What is machine learning?",
        "documents": [
            "Machine learning is a subset of AI",
            "The weather is nice today",
            "Deep learning uses neural networks"
        ],
        "top_n": 2
    }
)

print(response.json())
const response = await fetch('https://api.tokenlab.sh/v1/rerank', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer sk-your-api-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: 'qwen3-vl-rerank',
    query: 'What is machine learning?',
    documents: [
      'Machine learning is a subset of AI',
      'The weather is nice today',
      'Deep learning uses neural networks'
    ],
    top_n: 2
  })
});

const data = await response.json();
console.log(data.results);
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    payload := map[string]interface{}{
        "model": "qwen3-vl-rerank",
        "query": "What is machine learning?",
        "documents": []string{
            "Machine learning is a subset of AI",
            "The weather is nice today",
            "Deep learning uses neural networks",
        },
        "top_n": 2,
    }
    body, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST", "https://api.tokenlab.sh/v1/rerank", bytes.NewBuffer(body))
    req.Header.Set("Authorization", "Bearer sk-your-api-key")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    fmt.Println(result["results"])
}
<?php
$ch = curl_init('https://api.tokenlab.sh/v1/rerank');

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'Authorization: Bearer sk-your-api-key'
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'model' => 'qwen3-vl-rerank',
        'query' => 'What is machine learning?',
        'documents' => [
            'Machine learning is a subset of AI',
            'The weather is nice today',
            'Deep learning uses neural networks'
        ],
        'top_n' => 2
    ])
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
print_r($data['results']);
{
  "results": [
    {
      "index": 0,
      "relevance_score": 0.95,
      "document": "Machine learning is a subset of AI"
    },
    {
      "index": 2,
      "relevance_score": 0.82,
      "document": "Deep learning uses neural networks"
    }
  ],
  "model": "qwen3-vl-rerank",
  "usage": {
    "prompt_tokens": 45,
    "total_tokens": 45
  }
}