This topic describes the API used to vectorize text.
Prerequisites
An API key for identity authentication is obtained. When you call the API operations of OpenSearch LLM-Based Conversational Search Edition, you must be authenticated. For more information, see Manage API keys. LLM is short for large language model.
An endpoint is obtained. When you call the API operations of OpenSearch LLM-Based Conversational Search Edition, you must specify an endpoint. For more information, see Obtain endpoints.
Operation information
Request method | Request protocol | Request data format |
POST | HTTP | JSON |
Request URL
{host}/v3/openapi/apps/[app_group_identity]/actions/knowledge-embedding{host}: the endpoint that is used to call the API operation. You can call the API operation over the Internet or a virtual private cloud (VPC). For more information about how to obtain an endpoint, see Obtain endpoints.{app_group_identity}: the name of the application that you want to access. You can log on to the OpenSearch LLM-Based Conversational Search Edition console and view the application name of the corresponding instance on the Instance Management page.
Request parameters
Header parameters
Parameter | Type | Required | Description | Example |
Content-Type | string | Yes | The data format of the request. Only the JSON format is supported. Set the value to application/json. | application/json |
Authorization | string | Yes | The API key used for request authentication. The value must start with Bearer. | Bearer OS-d1**2a |
Body parameters
Parameter | Type | Required | Description | Example |
content | string | Yes | The data content to be processed. | Test text |
query | boolean | Yes | Specifies whether the text to be vectorized is a search query. Default value: false. | false |
model | string | No | The vectorization model to be used. |
Sample request body
{
"content":"Test text",
"query":false
}Response parameters
Parameter | Type | Description |
contentVector | string | The vector after the vectorization. |
Sample response body
{
"request_id":"111111111111",
"status":"OK";
"errors":[],
"result":"-0.010441,-0.002826,-0.022911,0.000847,0.025610,0.019213,-0.019912,0.008210,0.011974,-0.010120,-0.003866,-0.008091,-0.006889,-0.034774,...-0.012572,0.009668,0.010963,-0.005273,-0.005072,-0.002190,-0.001554,-0.000058"
}The vector after the text vectorization is of 1,536 dimensions.