{ "id": "rerank-abc123", "results": [ { "index": 0, "relevance_score": 0.98, "document": { "text": "Paris is the capital of France." } }, { "index": 2, "relevance_score": 0.61, "document": { "text": "France is a country in Western Europe." } } ], "usage": { "total_tokens": 512 }}
{ "id": "rerank-abc123", "results": [ { "index": 0, "relevance_score": 0.98, "document": { "text": "Paris is the capital of France." } }, { "index": 2, "relevance_score": 0.61, "document": { "text": "France is a country in Western Europe." } } ], "usage": { "total_tokens": 512 }}
Rerank a list of documents by relevance to a query. Returns documents sorted by relevance score.
curl https://app.firmware.ai/api/v1/rerank \ -H "Authorization: Bearer $FIRMWARE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "rerank-2.5", "query": "What is the capital of France?", "documents": [ "Paris is the capital of France.", "Berlin is the capital of Germany.", "France is a country in Western Europe." ], "top_n": 2 }'
Copy
{ "id": "rerank-abc123", "results": [ { "index": 0, "relevance_score": 0.98, "document": { "text": "Paris is the capital of France." } }, { "index": 2, "relevance_score": 0.61, "document": { "text": "France is a country in Western Europe." } } ], "usage": { "total_tokens": 512 }}