Skip to content

BedrockAgentRuntimeClient.rerank

rboto-bedrock-agent-runtime==0.4.0 · Service index · Types

Model summary (excerpt): Reranks the relevance of sources based on queries. For more information, see Improve the relevance of query responses with a reranker model .

Install and imports

python -m pip install "rboto[bedrock-agent-runtime]==0.4.0"
from rboto import BedrockAgentRuntimeClient
from collections.abc import Sequence
from rboto_bedrock_agent_runtime.types import (
    RerankOutput,
    RerankQuery,
    RerankSource,
    RerankingConfiguration,
)

Signature

async def rerank(
    *,
    queries: Sequence[RerankQuery],
    sources: Sequence[RerankSource],
    reranking_configuration: RerankingConfiguration,
    next_token: str | None = None,
) -> RerankOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
queries Yes An array of objects, each of which contains information about a query to submit to the reranker model.
sources Yes An array of objects, each of which contains information about the sources to rerank.
reranking_configuration Yes Contains configurations for reranking.
next_token No If the total number of results was greater than could fit in a response, a token is returned in the nextToken field. You can enter that token in this field to return the next batch of results.

Output

RerankOutput.

Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.

Field Type Presence References
results list[RerankResultOutput] Always present RerankResultOutput
next_token str | None Always present —

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

RerankOutput, RerankQuery, RerankSource, RerankingConfiguration

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

client.paginators.rerank(...) accepts the same arguments and returns AsyncIterator[RerankOutput]. Direct calls return one page. Pages preserve the Output representation above.

Input cursors: next_token. Page-size argument: not exposed.

No output stream.

Errors

Import from rboto_bedrock_agent_runtime.exceptions:

AccessDeniedError, BadGatewayError, ConflictError, DependencyFailedError, InternalServerError, ResourceNotFoundError, ServiceQuotaExceededError, ThrottlingError, ValidationError.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model