curl --request POST \
--url https://api.apiyi.com/v1/rerank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"model": "bge-reranker-v2-m3",
"query": "What are the must-see attractions in Hangzhou?",
"documents": [
"West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.",
"The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.",
"Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples."
]
}
EOFimport requests
url = "https://api.apiyi.com/v1/rerank"
payload = {
"model": "bge-reranker-v2-m3",
"query": "What are the must-see attractions in Hangzhou?",
"documents": ["West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.", "The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.", "Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples."]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'bge-reranker-v2-m3',
query: 'What are the must-see attractions in Hangzhou?',
documents: [
'West Lake is Hangzhou\'s most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.',
'The Bund in Shanghai sits along the Huangpu River and is the city\'s signature landmark.',
'Lingyin Temple, in Hangzhou\'s West Lake district, is one of China\'s best-known Buddhist temples.'
]
})
};
fetch('https://api.apiyi.com/v1/rerank', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/rerank",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'bge-reranker-v2-m3',
'query' => 'What are the must-see attractions in Hangzhou?',
'documents' => [
'West Lake is Hangzhou\'s most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.',
'The Bund in Shanghai sits along the Huangpu River and is the city\'s signature landmark.',
'Lingyin Temple, in Hangzhou\'s West Lake district, is one of China\'s best-known Buddhist temples.'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/rerank"
payload := strings.NewReader("{\n \"model\": \"bge-reranker-v2-m3\",\n \"query\": \"What are the must-see attractions in Hangzhou?\",\n \"documents\": [\n \"West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.\",\n \"The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.\",\n \"Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples.\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/rerank")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"bge-reranker-v2-m3\",\n \"query\": \"What are the must-see attractions in Hangzhou?\",\n \"documents\": [\n \"West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.\",\n \"The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.\",\n \"Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples.\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/rerank")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"bge-reranker-v2-m3\",\n \"query\": \"What are the must-see attractions in Hangzhou?\",\n \"documents\": [\n \"West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.\",\n \"The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.\",\n \"Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples.\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"document": {
"text": "West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda."
},
"index": 0,
"relevance_score": 0.97265625
},
{
"document": {
"text": "Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples."
},
"index": 2,
"relevance_score": 0.1181640625
}
],
"usage": {
"prompt_tokens": 70,
"total_tokens": 91
}
}재정렬 API 레퍼런스
bge-reranker-v2-m3 재정렬 API 레퍼런스 및 실시간 플레이그라운드: /v1/rerank 매개변수, 응답 구조, 오류 코드 표 및 디버깅 노트.
curl --request POST \
--url https://api.apiyi.com/v1/rerank \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"model": "bge-reranker-v2-m3",
"query": "What are the must-see attractions in Hangzhou?",
"documents": [
"West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.",
"The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.",
"Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples."
]
}
EOFimport requests
url = "https://api.apiyi.com/v1/rerank"
payload = {
"model": "bge-reranker-v2-m3",
"query": "What are the must-see attractions in Hangzhou?",
"documents": ["West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.", "The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.", "Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples."]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'bge-reranker-v2-m3',
query: 'What are the must-see attractions in Hangzhou?',
documents: [
'West Lake is Hangzhou\'s most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.',
'The Bund in Shanghai sits along the Huangpu River and is the city\'s signature landmark.',
'Lingyin Temple, in Hangzhou\'s West Lake district, is one of China\'s best-known Buddhist temples.'
]
})
};
fetch('https://api.apiyi.com/v1/rerank', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/rerank",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'bge-reranker-v2-m3',
'query' => 'What are the must-see attractions in Hangzhou?',
'documents' => [
'West Lake is Hangzhou\'s most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.',
'The Bund in Shanghai sits along the Huangpu River and is the city\'s signature landmark.',
'Lingyin Temple, in Hangzhou\'s West Lake district, is one of China\'s best-known Buddhist temples.'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/rerank"
payload := strings.NewReader("{\n \"model\": \"bge-reranker-v2-m3\",\n \"query\": \"What are the must-see attractions in Hangzhou?\",\n \"documents\": [\n \"West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.\",\n \"The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.\",\n \"Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples.\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/rerank")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"bge-reranker-v2-m3\",\n \"query\": \"What are the must-see attractions in Hangzhou?\",\n \"documents\": [\n \"West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.\",\n \"The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.\",\n \"Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples.\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/rerank")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"bge-reranker-v2-m3\",\n \"query\": \"What are the must-see attractions in Hangzhou?\",\n \"documents\": [\n \"West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda.\",\n \"The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.\",\n \"Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples.\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"document": {
"text": "West Lake is Hangzhou's most famous attraction, known for Broken Bridge, Su Causeway and Leifeng Pagoda."
},
"index": 0,
"relevance_score": 0.97265625
},
{
"document": {
"text": "Lingyin Temple, in Hangzhou's West Lake district, is one of China's best-known Buddhist temples."
},
"index": 2,
"relevance_score": 0.1181640625
}
],
"usage": {
"prompt_tokens": 70,
"total_tokens": 91
}
}Bearer sk-your-api-key를
Authorization에 넣은 다음 전송을 누르십시오 — 예시 본문은 이미 채워져 있습니다.매개변수 참조
| 매개변수 | Type | 필수 | 비고 |
|---|---|---|---|
model | string | ✓ | 항상 bge-reranker-v2-m3입니다. 대소문자를 구분합니다(잘못된 이름을 사용하면 404가 아니라 503을 반환합니다) |
query | string | ✓ | 검색 쿼리입니다. 빈 문자열을 보내면 400 query is required를 반환합니다 |
documents | string[] | ✓ | 후보입니다. 평문 문자열 배열만 허용됩니다. 빈 배열을 보내면 400을 반환합니다 |
top_n | int | 상위 N개를 반환합니다. 생략 / 0 / 음수는 모두 전체를 반환하며, 문자열을 보내면 400을 반환합니다 | |
return_documents | bool | ⚠️ 이 채널에서는 효과가 없습니다 — 텍스트는 항상 그대로 에코됩니다 |
max_chunks_per_doc, rank_fields, truncate, …)는 거부되지 않고 조용히 무시됩니다.
응답 참고 사항
{
"results": [
{ "document": { "text": "..." }, "index": 0, "relevance_score": 0.97265625 }
],
"usage": { "prompt_tokens": 70, "total_tokens": 91,
"input_tokens": 0, "output_tokens": 0 }
}
index— 문서의 원래 위치입니다. 이는 사용자가 보낸documents배열에서의 위치입니다. 이를 사용해 자신의 문서 객체를 조회하십시오; 반환된text를 기준으로 일치시키지 마십시오.relevance_score— 범위 0–1. 단일 요청 내에서만 비교 가능합니다. 쿼리 간에는 비교할 수 없으며, 다국어 경우에서는 체계적으로 더 낮습니다. 개요의 임계값 논의를 참조하십시오.results은 항상relevance_score내림차순으로 정렬되며;index값은 완전하고 고유합니다.- 사용량은
prompt_tokens(query 1회 집계 + 모든 문서)와total_tokens(query 쌍당 집계)에서 읽으십시오;input_tokens/output_tokens는 이 채널에서 항상 0입니다. 이번 라운드에서는 과금에서 어떤 필드가 청구되는지 확인할 수 없었습니다 — 콘솔 청구서를 기준으로 삼으십시오.
오류 코드
| HTTP | 메시지 | 원인 및 해결 방법 |
|---|---|---|
| 400 | query is required | query이(가) 없거나 빈 문자열입니다 |
| 400 | documents is required | documents이(가) 없거나 빈 배열입니다 |
| 400 | Input should be a valid string | documents에 객체를 전달했습니다. 일반 문자열을 사용하십시오 |
| 400 | cannot unmarshal string into ... top_n of type int | top_n이 문자열이었습니다. 정수를 전달하십시오 |
| 400 | This model's maximum context length is 8192 tokens | 쿼리-문서 쌍 하나가 8192 tokens를 초과했습니다. 청크로 나누어 다시 시도하십시오 |
| 401 | Invalid token. | 잘못된 API 키이거나 Authorization 헤더가 없습니다 |
| 429 | 업스트림 부하가 포화되었습니다 | 업스트림 쿼터(TPM 20,000 / RPM 120)에 도달했습니다. 두 원인 모두 같은 메시지를 반환합니다: ① 약 4~5개를 초과하는 동시 인플라이트 요청; ② 1분 동안 누적 20,000 tokens 초과(단일 1000-candidate 요청만으로도 이미 초과합니다). 동시 실행 수는 4로 제한하고, 백오프를 추가하며, tokens 예산을 관리하십시오. 이 쿼터는 확대 중입니다 — 더 높은 용량이 필요하면 APIYI 지원팀에 문의하십시오 |
| 503 | Current group ... has no available channels for model | 모델 이름이 대소문자까지 포함해 잘못되었거나, 해당 그룹에 실제로 채널이 없습니다. 먼저 철자를 확인하십시오 |
Content-Type: text/plain), 게이트웨이는 model 필드를 읽지 않고 빈 모델 이름으로 동일한 503을
반환합니다. 이 경우 채널 장애처럼 보이지만 실제로는 그렇지 않습니다./rerank와 /v2/rerank(Cohere v2 SDK의
기본값) 모두 HTTP 200과 웹사이트의 HTML 홈페이지를 반환하며, 클라이언트 측에서는
파싱할 수 없는 응답으로 나타납니다. https://api.apiyi.com/v1/rerank만 유효한 경로입니다.디버깅 노트
후보 3개만으로 테스트하지 마십시오
후보 3개만으로 테스트하지 마십시오
크로스링구얼 테스트에서 낮은 점수는 예상됩니다
크로스링구얼 테스트에서 낮은 점수는 예상됩니다
약 2초의 지연시간 하한이 있습니다
약 2초의 지연시간 하한이 있습니다
디버깅 중에 쿼터를 소진할 수 있습니다
디버깅 중에 쿼터를 소진할 수 있습니다
인증
Add the Authorization: Bearer YOUR_API_KEY request header
본문
Always bge-reranker-v2-m3 (case-sensitive; a wrong name returns 503)
"bge-reranker-v2-m3"
The search query. An empty string returns 400
Candidate documents. Plain string array only — passing Cohere-style
[{"text": "..."}] objects returns 400. Cannot be empty. Keep to 100 or fewer.
Return the top N results. Omitting it, or passing 0 or a negative number, returns all. Must be an integer — a string returns 400. Does not affect usage: every candidate is scored regardless.
2
Whether to echo the document text in results.
Note: this parameter currently has no effect on this channel — document.text
is always echoed. If response size matters, map results back by index yourself
rather than relying on this flag to trim the payload.
true
이 페이지가 도움이 되었나요?