AI Search Open Platform supports calling multimodal embedding services through SDK.
Prerequisites
You have activated the AI Search Open Platform service. For more information, see Activate the service.
You have completed identity authentication using API-KEY. For authentication information, see Obtain API-KEY.
To call the multimodal embedding service, you need to update the SDK version to 2.1.0 or later.
pip install --upgrade alibabacloud_searchplat20240529
Parameters
The request body must not exceed 8 MB.
For more information, see Multimodal embedding.
from alibabacloud_tea_openapi.models import Config
from alibabacloud_searchplat20240529.client import Client
from alibabacloud_searchplat20240529.models import GetMultiModalEmbeddingRequest, GetMultiModalEmbeddingRequestInput
if __name__ == '__main__':
# token configuration, endpoint configuration
config = Config(bearer_token="Replace with your API-KEY",
# endpoint: Configure the unified request entry point, remove http://
endpoint="Replace with API endpoint",
# Specify the request protocol. Valid values: HTTPS and HTTP.
protocol="http")
client = Client(config=config)
# --------------- Request body parameters ---------------
request = GetMultiModalEmbeddingRequest()
request.from_map({"input":[{"text":"Science and technology are the primary productive forces"}]})
# default: Replace with your workspace name, ops-m2-encoder: service ID, can be replaced with other supported service IDs
response = client.get_multi_modal_embedding("default", "ops-m2-encoder", request)
print(response)