All Products
Search
Document Center

OpenSearch:Rerank

Last Updated:Aug 05, 2025

AI Search Open Platform allows you to call the re-rank service by using an SDK.

Prerequisites

AI Search Open Platform is activated. For more information, see Activate AI Search Open Platform.

You have completed identity authentication by using an API key. For more information about how to obtain the authentication information, see Manage API key.

Parameter description

  • The request body cannot exceed 8 MB in size.

  • For more information about parameters, see Re-rank service.

from alibabacloud_tea_openapi.models import Config
from alibabacloud_searchplat20240529.client import Client
from alibabacloud_searchplat20240529.models import GetDocumentRankRequest

if __name__ == '__main__':
    # Configure the service token and endpoint.
    config = Config(bearer_token="Your API key",
                    # endpoint: Configure the unified request entry point. Remove http://.
                    endpoint="You API endpoint",
                    # Specify the request protocol. Valid values: HTTPS and HTTP.
                    protocol="http")
    client = Client(config=config)

    # --------------- Request parameters ---------------
    request = GetDocumentRankRequest(docs=["test", "text"], query="test")

    # default: Replace this value with your workspace name. ops-bge-reranker-larger: Replace this value with your service ID.
    response = client.get_document_rank("default", "ops-bge-reranker-larger", request)
    print(response)