--
:api: get-trained-models
:request: GetTrainedModelsRequest
:response: GetTrainedModelsResponse
--
[role="xpack"]
[id="{upid}-{api}"]
=== Get trained models API


Retrieves one or more trained models.
The API accepts a +{request}+ object and returns a +{response}+.

[id="{upid}-{api}-request"]
==== Get trained models request

A +{request}+ requires either a trained model ID, a comma-separated list of
IDs, or the special wildcard `_all` to get all trained models.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request]
--------------------------------------------------
<1> Constructing a new GET request referencing an existing trained model.
<2> Set the paging parameters.
<3> Indicate if the complete model definition should be included.
<4> Indicate if the total feature importance for the features used in training
    should is included in the metadata.
<5> Indicate if the feature importance baselines that were used in training are
    included in the metadata.
<6> Should the definition be fully decompressed on GET.
<7> Allow empty response if no trained models match the provided ID patterns.
    If false, an error will be thrown if no trained models match the
    ID patterns.
<8> An optional list of tags used to narrow the model search. A trained model
    can have many tags or none. The trained models in the response will
    contain all the provided tags.
<9> Optional boolean value for requesting the trained model in a format that can
    then be put into another cluster. Certain fields that can only be set when
    the model is imported are removed.

include::../execution.asciidoc[]

[id="{upid}-{api}-response"]
==== Response

The returned +{response}+ contains the requested trained model.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-response]
--------------------------------------------------
