Update a model

Introduced 2.12

Updates a model based on the model_ID.

For information about user access for this API, see Model access control considerations.

Path and HTTP methods

  1. PUT /_plugins/_ml/models/<model_id>

Request fields

The following table lists the updatable fields. Not all request fields are applicable to all models. To determine whether the field is applicable to your model type, see Register Model API.

FieldData typeDescription
connectorObjectContains specifications for a connector for a model hosted on a third-party platform. For more information, see Creating a connector for a specific model. For information about the updatable fields within a connector, see Update Connector API request fields.
connector_idOptionalThe connector ID of a standalone connector for a model hosted on a third-party platform. For more information, see Standalone connector. To update a standalone connector, you must undeploy the model, update the connector, and then redeploy the model.
descriptionStringThe model description.
is_enabledBooleanSpecifies whether the model is enabled. Disabling the model makes it unavailable for Predict API requests, regardless of the model’s deployment status. Default is true.
model_configObjectThe model’s configuration, including the model_type, embedding_dimension, and framework_type. all_config is an optional JSON string that contains all model configurations. For more information, see The model_config object.
model_group_idStringThe model group ID of the model group to which to register this model.
nameStringThe model name.
rate_limiterObjectLimits the number of times any user can call the Predict API on the model. For more information, see Rate limiting inference calls.
rate_limiter.limitIntegerThe maximum number of times any user can call the Predict API on the model per unit of time. By default, there is no limit on the number of Predict API calls. Once you set a limit, you cannot reset it to no limit. As an alternative, you can specify a high limit value and a small time unit, for example, 1 request per nanosecond.
rate_limiter.unitStringThe unit of time for the rate limiter. Valid values are DAYS, HOURS, MICROSECONDS, MILLISECONDS, MINUTES, NANOSECONDS, and SECONDS.
guardrailsObjectThe guardrails for the model.
interfaceObjectThe interface for the model.

Example request: Disabling a model

  1. PUT /_plugins/_ml/models/MzcIJX8BA7mbufL6DOwl
  2. {
  3. "is_enabled": false
  4. }

copy

Example request: Rate limiting inference calls for a model

The following request limits the number of times you can call the Predict API on the model to 4 Predict API calls per minute:

  1. PUT /_plugins/_ml/models/T_S-cY0BKCJ3ot9qr0aP
  2. {
  3. "rate_limiter": {
  4. "limit": "4",
  5. "unit": "MINUTES"
  6. }
  7. }

copy

Example requests: Updating the guardrails

  1. PUT /_plugins/_ml/models/MzcIJX8BA7mbufL6DOwl
  2. {
  3. "guardrails": {
  4. "type": "local_regex",
  5. "input_guardrail": {
  6. "stop_words": [
  7. {
  8. "index_name": "updated_stop_words_input",
  9. "source_fields": ["updated_title"]
  10. }
  11. ],
  12. "regex": ["updated_regex1", "updated_regex2"]
  13. },
  14. "output_guardrail": {
  15. "stop_words": [
  16. {
  17. "index_name": "updated_stop_words_output",
  18. "source_fields": ["updated_title"]
  19. }
  20. ],
  21. "regex": ["updated_regex1", "updated_regex2"]
  22. }
  23. }
  24. }

copy

  1. PUT /_plugins/_ml/models/9uGdCJABjaMXYrp14YRj
  2. {
  3. "guardrails": {
  4. "type": "model",
  5. "input_guardrail": {
  6. "model_id": "V-G1CJABjaMXYrp1QoUC",
  7. "response_validation_regex": "^\\s*[Aa]ccept\\s*$"
  8. },
  9. "output_guardrail": {
  10. "model_id": "V-G1CJABjaMXYrp1QoUC",
  11. "response_validation_regex": "^\\s*[Aa]ccept\\s*$"
  12. }
  13. }
  14. }

copy

Example response

  1. {
  2. "_index": ".plugins-ml-model",
  3. "_id": "MzcIJX8BA7mbufL6DOwl",
  4. "_version": 10,
  5. "result": "updated",
  6. "_shards": {
  7. "total": 1,
  8. "successful": 1,
  9. "failed": 0
  10. },
  11. "_seq_no": 48,
  12. "_primary_term": 4
  13. }