> For the complete documentation index, see [llms.txt](https://guides.ia.numerique.gouv.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guides.ia.numerique.gouv.fr/albert-api/api-reference/liste-des-endpoint/rerank.md).

# Rerank

## POST /v1/rerank

> Create Rerank

```json
{"openapi":"3.1.0","info":{"title":"Albert API","version":"0.4.9"},"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}},"schemas":{"CreateRerankBody":{"properties":{"query":{"type":"string","minLength":1,"title":"Query","description":"The search query to use for the reranking. `query` and `prompt` cannot both be provided."},"documents":{"items":{"type":"string","minLength":1},"type":"array","title":"Documents"},"model":{"type":"string","minLength":1,"title":"Model","description":"The model to use for the reranking, call `/v1/models` endpoint to get the list of available models, only `text-classification` model type is supported."},"top_n":{"anyOf":[{"type":"integer","minimum":1},{"type":"null"}],"title":"Top N","description":"The number of top results to return. If set to None, all results will be returned."}},"additionalProperties":true,"type":"object","required":["query","documents","model"],"title":"CreateRerankBody"},"RerankResponse":{"properties":{"object":{"type":"string","const":"list","title":"Object","default":"list"},"id":{"type":"string","title":"Id","description":"A unique identifier for the request."},"results":{"items":{"$ref":"#/components/schemas/RerankResult"},"type":"array","title":"Results","description":"The list of reranked texts."},"model":{"type":"string","title":"Model","description":"The model used to generate the reranking."},"usage":{"$ref":"#/components/schemas/api__domain__usage__entities__Usage","description":"Usage information for the request."}},"additionalProperties":true,"type":"object","required":["id","results","model"],"title":"RerankResponse"},"RerankResult":{"properties":{"relevance_score":{"type":"number","title":"Relevance Score","description":"The relevance score of the reranked text."},"index":{"type":"integer","title":"Index","description":"The index of the reranked text."}},"additionalProperties":true,"type":"object","required":["relevance_score","index"],"title":"RerankResult"},"api__domain__usage__entities__Usage":{"properties":{"prompt_tokens":{"type":"integer","title":"Prompt Tokens","default":0},"completion_tokens":{"type":"integer","title":"Completion Tokens","default":0},"total_tokens":{"type":"integer","title":"Total Tokens","default":0},"cost":{"type":"number","title":"Cost","default":0},"impacts":{"$ref":"#/components/schemas/api__domain__usage__entities__EnvironmentalImpacts","default":{"kWh":0,"kgCO2eq":0}}},"additionalProperties":true,"type":"object","title":"Usage"},"api__domain__usage__entities__EnvironmentalImpacts":{"properties":{"kWh":{"type":"number","title":"Kwh","default":0},"kgCO2eq":{"type":"number","title":"Kgco2Eq","default":0}},"additionalProperties":true,"type":"object","title":"EnvironmentalImpacts"},"api__infrastructure__fastapi__documentation__HTTPExceptionModel":{"properties":{"status_code":{"type":"integer","title":"Status Code"},"detail":{"type":"string","title":"Detail"},"headers":{"anyOf":[{"additionalProperties":{"type":"string"},"type":"object"},{"type":"null"}],"title":"Headers"}},"type":"object","required":["status_code","detail"],"title":"HTTPExceptionModel"}}},"paths":{"/v1/rerank":{"post":{"tags":["Rerank"],"summary":"Create Rerank","operationId":"create_rerank_v1_rerank_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRerankBody","description":"The rerank creation request."}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RerankResponse"}}}},"400":{"description":"Insufficient budget.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api__infrastructure__fastapi__documentation__HTTPExceptionModel"}}}},"401":{"description":"Invalid authentication scheme.<br>Invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api__infrastructure__fastapi__documentation__HTTPExceptionModel"}}}},"403":{"description":"Your account has expired. Please contact support to renew your account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api__infrastructure__fastapi__documentation__HTTPExceptionModel"}}}},"404":{"description":"Model {name} not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api__infrastructure__fastapi__documentation__HTTPExceptionModel"}}}},"422":{"description":"Model has wrong type. Expected: {expected_type}. Actual: {actual_type}.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api__infrastructure__fastapi__documentation__HTTPExceptionModel"}}}},"429":{"description":"Token/request limit per minute/day exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api__infrastructure__fastapi__documentation__HTTPExceptionModel"}}}},"503":{"description":"Model is too busy, please try again later.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/api__infrastructure__fastapi__documentation__HTTPExceptionModel"}}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://guides.ia.numerique.gouv.fr/albert-api/api-reference/liste-des-endpoint/rerank.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
