import requests
response = requests.post(
"https://crazyrouter.com/v1/rerank",
headers={
"Authorization": "Bearer sk-xxx",
"Content-Type": "application/json"
},
json={
"model": "BAAI/bge-reranker-v2-m3",
"query": "What is a vector database",
"documents": [
"A vector database is a database system specialized for storing and retrieving high-dimensional vectors",
"Relational databases use tables to store structured data",
"Vector databases support approximate nearest neighbor search, suitable for semantic retrieval scenarios",
"Redis is an in-memory key-value store"
],
"top_n": 2,
"return_documents": True
}
)
data = response.json()
for result in data["results"]:
print(f"[{result['relevance_score']:.4f}] {result['document']['text']}")