All Products
Search
Document Center

OpenSearch:Custom models

Last Updated:Mar 18, 2025

OpenSearch Vector Search Edition allows you to call custom models. You can create custom models on the Custom Models tab and perform management operations on the models, such as view, edit, debug, disable, or restore a model.

Create a model

In the left-side navigation pane of the details page of your OpenSearch instance, choose Model Management > Models. On the Custom Models tab of the page that appears, click Create Model. In the Create Custom Model panel, configure the parameters based on the custom model format.

image

Custom model format

{
  "modelName": "custom_model",
  "modelType": "text_embedding",
  "dimension": 1536,
  "url": "http://xxx/api/v2/services/embeddings",
  "method": "POST"
  "request": {
    "header": {
      "Authorization": "fj42091fjlgnlsvu023nva",
      "Content-Type": "application/json"
    },
    "urlParams": {
      "build": {},
      "search": {}
    },
    "requestBody": "{\"input\": [\"%{input}\"],\"input_type\": \"${input_type}\"}",
    "parameters": {
      "build": {
        "input_type": "document"
      },
      "search": {
        "input_type": "query"
      }
    }
  },
  "response": {
    "embeddings": "$.result.embeddings[*].embedding"
  }
}

Parameters

Parameter

Description

modelName

The name of the model.

modelType

The type of the model. Valid values:

  • text_embedding: dense text model

  • text_sparse_embedding: sparse text model

  • image_embedding: image vector model

  • image_analyze: image content analysis model

dimension

The number of dimensions of the model. You need to configure this parameter if you set the modelType parameter to text_embedding or image_embedding.

url

The endpoint of the model service.

method

The HTTP method used to access the model service. Valid values: PUT and POST.

request

The request method.

request.header

The HTTP header used to access the model service, which is passed to the model service without any processing.

request.urlParams

The parameters in the URL. Some model services need to pass parameters through a URL, such as ?abc=123.

request.urlParams.build

The parameters that are passed when an index is created.

request.urlParams.search

The parameters that are passed during a query.

request.requestBody

The template string of the request body.

  • Template variable format:

    %{Parameter name}. Example: { "input": "%{input}" }.

  • Built-in variable:

    • %{input}: the input text.

    • %{modal}: the modal. If a multimodal model is used, you can specify the modal to use in a query.

request.parameters

If you want to distinguish between parameters in the build phase and parameters in the search phase in the request body, you can define them in this parameter.

  • build: the parameters in the index creation phase.

  • search: the parameters in the query phase.

response

The format used to parse results. A JSON path is used.

JSON path description

Operators

Operator

Description

$

The root element. A path must start with $.

*

The wildcard that indicates any value. You can use a wildcard to replace a name or number.

.<name>

Used to access the attributes of objects.

[<number>]

Used to access the elements of array subscripts.

Examples

{
  "store": {
    "books": [
      {
        "title": "java",
        "price": 56
      },
      {
        "title": "c++",
        "price": 99
      }
    ]
  }
}
  • Extract the titles of all books

    • json path: $.store.books[*].title

    • Result: ["java", "c++"]

  • Extract the title of the first book

    • json path: $.store.books[0].title

    • Result: ["java"]

Manage a model

  • Debug a model

    On the Custom Models tab of the Models page, find the model that you want to manage and click Debug in the Actions column to test the effect of the model.

  • Disable a model

    After a model is disabled, the table that invokes the model no longer processes the related data and queries. Proceed with caution.

  • Delete a model

    Only disabled models can be deleted.

  • Restore a model

    You can restore disabled models.

Call a model

When you configure a table, click Configure for the field that you want to preprocess. You can select the created custom model from the displayed models.

image

image