This version of the OpenSearch documentation is no longer maintained. For the latest version, see the current documentation. For information about OpenSearch version maintenance, see Release Schedule and Maintenance Policy.

Building blueprints

All connectors consist of a JSON blueprint created by machine learning (ML) developers. The blueprint allows administrators and data scientists to make connections between OpenSearch and an AI service or model-serving technology.

The following example shows a blueprint that connects to Amazon SageMaker:

  1. POST /_plugins/_ml/connectors/_create
  2. {
  3. "name": "<YOUR CONNECTOR NAME>",
  4. "description": "<YOUR CONNECTOR DESCRIPTION>",
  5. "version": "<YOUR CONNECTOR VERSION>",
  6. "protocol": "aws_sigv4",
  7. "credential": {
  8. "access_key": "<ADD YOUR AWS ACCESS KEY HERE>",
  9. "secret_key": "<ADD YOUR AWS SECRET KEY HERE>",
  10. "session_token": "<ADD YOUR AWS SECURITY TOKEN HERE>"
  11. },
  12. "parameters": {
  13. "region": "<ADD YOUR AWS REGION HERE>",
  14. "service_name": "sagemaker"
  15. },
  16. "actions": [
  17. {
  18. "action_type": "predict",
  19. "method": "POST",
  20. "headers": {
  21. "content-type": "application/json"
  22. },
  23. "url": "<ADD YOUR Sagemaker MODEL ENDPOINT URL>",
  24. "request_body": "<ADD YOUR REQUEST BODY. Example: ${parameters.inputs}>"
  25. }
  26. ]
  27. }

Example blueprints

You can find blueprints for each connector in the ML Commons repository.

Configuration options

The following configuration options are required in order to build a connector blueprint. These settings can be used for both external and local connectors.

FieldData typeDescription
nameStringThe name of the connector.
descriptionStringA description of the connector.
versionIntegerThe version of the connector.
protocolStringThe protocol for the connection. For AWS services such as Amazon SageMaker and Amazon Bedrock, use aws_sigv4. For all other services, use http.
parametersJSON objectThe default connector parameters, including endpoint and model. Any parameters indicated in this field can be overridden by parameters specified in a predict request.
credentialMap<string, string>Defines any credential variables required to connect to your chosen endpoint. ML Commons uses AES/GCM/NoPadding symmetric encryption to encrypt your credentials. When the connection to the cluster first starts, OpenSearch creates a random 32-byte encryption key that persists in OpenSearch’s system index. Therefore, you do not need to manually set the encryption key.
actionsJSON arrayDefine what actions can run within the connector. If you’re an administrator making a connection, add the blueprint for your desired connection.
backend_rolesJSON arrayA list of OpenSearch backend roles. For more information about setting up backend roles, see Assigning backend roles to users.
access_modeStringSets the access mode for the model, either public, restricted, or private. Default is private. For more information about access_mode, see Model groups.
add_all_backend_rolesBooleanWhen set to true, adds all backend_roles to the access list, which only a user with admin permissions can adjust. When set to false, non-admins can add backend_roles.

The action parameter supports the following options.

FieldData typeDescription
action_typeStringRequired. Sets the ML Commons API operation to use upon connection. As of OpenSearch 2.9, only predict is supported.
methodStringRequired. Defines the HTTP method for the API call. Supports POST and GET.
urlStringRequired. Sets the connection endpoint at which the action takes place. This must match the regex expression for the connection used when adding trusted endpoints.
headersJSON objectSets the headers used inside the request or response body. Default is ContentType: application/json. If your third-party ML tool requires access control, define the required credential parameters in the headers parameter.
request_bodyStringRequired. Sets the parameters contained inside the request body of the action. The parameters must include \”inputText\, which specifies how users of the connector should construct the request payload for the action_type.

Next step

To see how system administrators and data scientists use blueprints for connectors, see Creating connectors for third-party ML platforms.