All Products
Search
Document Center

OpenSearch:Text embedding

Last Updated:Apr 01, 2026

Generates vector embeddings for one or more text inputs using the OpenSearch compatible mode embedding service.

Endpoint

POST {host}/compatible-mode/v1/embeddings

host: The endpoint for the service. The service is accessible over the Internet or a Virtual Private Cloud (VPC). To get your endpoint, see Query service endpoint.

AI apikey截图.png

Request parameters

ParameterTypeRequiredDescriptionExample
modelStringYesThe service ID to use. System service IDs start with ops-. For supported service IDs, see List of supported services.ops-text-embedding-001
inputArray/StringYesThe text to embed. Accepts a single string or an array of strings. Maximum 32 inputs per request. The maximum length of each input depends on the selected model. Empty strings are not accepted.["Science and technology are the primary productive forces", "OpenSearch product documentation"]

Response parameters

ParameterTypeDescriptionExample
dataListThe embedding results.
data.embeddingArray[float]The embedding vector for the input at the corresponding index. ops-text-embedding-001 returns 1536 floats.[0.003143, 0.009750, ..., -0.017395]
data.indexIntThe position of this result in the request input array, starting from 0.0
data.objectStringThe object type. Always embedding.embedding
objectStringThe response type. Always list.list
modelStringThe service ID specified in the request.ops-text-embedding-001
usageObjectToken usage statistics for this request.
usage.prompt_tokensIntThe number of tokens in the request input.5
usage.total_tokensIntThe total number of tokens used (usage.prompt_tokens + usage.completion_tokens).5

Example

Request

curl http://xxxx-shanghai.opensearch.aliyuncs.com/compatible-mode/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your-api-key>" \
  -d '{
    "model": "ops-text-embedding-001",
    "input": "Search development platform"
  }'

Response

{
  "id": "9085118afe14bee71d59c4a609fcf7c0",
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        0.0021381378173828125,
        0.12109375,
        ...,
        -0.0389404296875
      ],
      "index": 0
    }
  ],
  "model": "ops-text-embedding-001",
  "usage": {
    "prompt_tokens": 5,
    "total_tokens": 5
  }
}

Status codes

For status code descriptions, see Status code description.