Skip to content
中文

Rerank documents

POST/model/v1/rerank● Supported

Official docs ↗

Request body

  • modelstringrequired

    Rerank model id; list candidates with listModels?type=reranking. Router support (supported): Verified to take effect.

    Verified to take effect.

  • querystringrequired

    Query to rank the documents against, at least 1 character. Router support (supported): Verified to take effect.

    Verified to take effect.

  • documentsarrayrequired◐ Partially supported

    Documents to rank, as plain strings, at least one. Router support (partial): Only string arrays are supported; object arrays return 400.

    Only string arrays are supported; object arrays return 400.

  • top_nintegeroptional

    Number of best results to return, at least 1; omit it to return every document. Router support (supported): Controls returned result count; zero returns 400.

    Controls returned result count; zero returns 400.

  • return_documentsbooleanoptional○ Unsupported

    bge-reranker-base returns 400; only model, query, documents and top_n are supported.

  • max_tokens_per_docintegeroptional○ Unsupported

    bge-reranker-base returns 400; only model, query, documents and top_n are supported.

  • rank_fieldsarrayoptional○ Unsupported

    bge-reranker-base returns 400; only model, query, documents and top_n are supported.

  • max_chunks_per_docintegeroptional○ Unsupported

    bge-reranker-base returns 400; only model, query, documents and top_n are supported.

  • userstringoptional○ Unsupported

    bge-reranker-base returns 400; only model, query, documents and top_n are supported.

Returns

200

Standard request fields; unrepresentable parameters return input_not_representable.

Platform errors (auth, rate limits, validation) and OCR errors use problem+json; other model call errors follow the endpoint's own format (OpenAI or Anthropic) — see error codes

Request

curl
curl https://api.deepraxis.com/model/v1/rerank \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"bge-reranker-base","query":"What is the capital of France?","documents":["Paris is the capital of France.","Berlin is the capital of Germany."],"top_n":2}'
Python
import requests

opts = dict(
    base_url="https://api.deepraxis.com/model/v1",
    api_key="$PRAXIS_API_KEY",
)

resp = requests.post(
    f"{opts['base_url']}/rerank",
    headers={"Authorization": f"Bearer {opts['api_key']}"},
    json={
        "model": "bge-reranker-base",
        "query": "What is the capital of France?",
        "documents": ["Paris is the capital of France.", "Berlin is the capital of Germany."],
        "top_n": 2,
    },
)
print(resp.json())
TypeScript
const opts = {
  baseURL: "https://api.deepraxis.com/model/v1",
  apiKey: "$PRAXIS_API_KEY",
};

const resp = await fetch(`${opts.baseURL}/rerank`, {
  method: "POST",
  headers: { Authorization: `Bearer ${opts.apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    model: "bge-reranker-base",
    query: "What is the capital of France?",
    documents: ["Paris is the capital of France.", "Berlin is the capital of Germany."],
    top_n: 2,
  }),
});
console.log(await resp.json());

Response 200

{
  "results": [
    {
      "index": 0,
      "relevance_score": 0.997886598110199
    },
    {
      "index": 1,
      "relevance_score": 0.0251021608710289
    }
  ]
}

Response

HTTP 200

Cohere v2 rerank results.

application/json

Name Type Description
results array<object> Results ordered by relevance, best first. Each entry points back to a document with index.
results[].index integer Zero-based position of the document in the request documents array.
results[].relevance_score number Relevance of the document to the query, from 0 to 1; larger is more relevant.