When you call the OpenSearch LLM-Based Conversational Search Edition service through an API or SDK, the caller's identity must be authenticated or authorized. This topic describes the authentication and authorization methods and how to manage API keys.
API call authentication
Authenticate API calls using an API key: This is an authentication method provided by LLM-Based Conversational Search Edition. When you call an API using this method, you must provide an access key, that is, an API key. You can create and enable up to 10 API keys per instance.
To prevent API key leaks:
-
Do not expose your API key in any way, to avoid security risks or financial losses caused by unauthorized use.
-
API calls should be initiated only from the server side. Any API call initiated from the client side, such as a browser, app, or mini program, may cause the API key to be leaked.
-
If you suspect that an API key has been leaked, you can log on to OpenSearch LLM-Based Conversational Search Edition to first disable and then delete the API key. After an API key is disabled, it can no longer be used to make API calls.
API call authorization
Authorize API calls using an AccessKey pair (AK): This is a permanent access credential provided by Alibaba Cloud, consisting of an AccessKey ID and an AccessKey secret.
An AccessKey pair is not used to log on to the console. Instead, it is used to access Alibaba Cloud through development tools (such as APIs, CLI, SDKs, and Terraform). Requests carry a signature generated by encrypting the request content with the AccessKey ID and AccessKey secret, which is used to verify your identity and the validity of the request.
We strongly recommend that you create a RAM user dedicated to API access, generate a corresponding AccessKey pair, grant permissions based on the principle of least privilege, and then call the development workbench service through the API. For more information, see Create RAM users and grant permissions.
Procedure
-
Log on to the OpenSearch console.
-
Select the target region and switch to OpenSearch LLM-Based Conversational Search Edition.
-
In the instance list, click Manage to the right of the target instance, and then choose API keys in the left-side navigation pane.
-
Click Create an API KEY. The system generates an API key. Click Copy to save the API key, or download a CSV file to save the API key information.
-
After you have securely saved the API key, click I have saved my API KEY., and then click OK to close the dialog.

-
Edit: Add a description for the API key.
-
View: View the API key.
-
Disable/Enable: When disabled, the API key cannot be used to make API calls. When enabled, the API key can be used to make API calls.
-
Delete: You can delete an API key when it is disabled.
-
API key authentication example
You can also complete call authentication using an API key. The following is an example curl request that uses API key authentication to retrieve a list of terms. After you configure the URL and API key, you can run a test.
curl --location 'http://***.opensearch-cn-shanghai.aliyuncs.com/v3/openapi/apps/[app_group_identity]/knowledge/entries' \
--header 'Authorization: Bearer Your API Key' \
--header 'Content-Type: application/json' \
Response example:
{
"request_id":"4F6F9BDC-740F-4FC1-B976-74CAFCBF1333",
"status":"OK",
"total_count":2,
"latency":0.0,
"result":[
{
"entry_id":"ca0c8c1cec7c41a280c76c16f0db79f6",
"create_time":1718188424000,
"update_time":1718188424000,
"questions":[
"Where is the office address for withdrawing housing provident fund to buy owner-occupied housing in Hangzhou"
],
"answer":"\"Hello, the office address is ****, contact phone: 0571-12329-1\""
},
{
"entry_id":"2f4c7350a7104f029f316706b61b6eb2",
"create_time":1718193627000,
"update_time":1718193627000,
"questions":[
"Can someone help handle the deregistration application for a domestic-funded branch on my behalf?"
],
"answer":"Yes, it can be handled on your behalf. When submitting materials at the on-site window, the authorization ***** and the authorized person should sign personally."
}
],
"errors":[]
}