Method: endpoints.explain

Full name: projects.locations.endpoints.explain

Perform an online explanation.

IfdeployedModelId is specified, the corresponding endpoints.deployModel must haveexplanationSpec populated. IfdeployedModelId is not specified, all DeployedModels must haveexplanationSpec populated.

Endpoint

posthttps://{service-endpoint}/v1/{endpoint}:explain

Where{service-endpoint} is one of thesupported service endpoints.

Path parameters

endpointstring

Required. The name of the Endpoint requested to serve the explanation. Format:projects/{project}/locations/{location}/endpoints/{endpoint}

Request body

The request body contains data with the following structure:

Fields
instances[]value (Value format)

Required. The instances that are the input to the explanation call. A DeployedModel may have an upper limit on the number of instances it supports per request, and when it is exceeded the explanation call errors in case of AutoML Models, or, in case of customer created Models, the behaviour is as documented by that Model. The schema of any single instance may be specified via Endpoint's DeployedModels'Model'sPredictSchemata'sinstanceSchemaUri.

parametersvalue (Value format)

The parameters that govern the prediction. The schema of the parameters may be specified via Endpoint's DeployedModels'Model'sPredictSchemata'sparametersSchemaUri.

explanationSpecOverrideobject (ExplanationSpecOverride)

If specified, overrides theexplanationSpec of the DeployedModel. Can be used for explaining prediction results with different configurations, such as: - Explaining top-5 predictions results as opposed to top-1; - Increasing path count or step count of the attribution methods to reduce approximate errors; - Using different baselines for explaining the prediction results.

deployedModelIdstring

If specified, this ExplainRequest will be served by the chosen DeployedModel, overridingEndpoint.traffic_split.

Response body

Response message forPredictionService.Explain.

If successful, the response body contains data with the following structure:

Fields
explanations[]object (Explanation)

The explanations of the Model'sPredictResponse.predictions.

It has the same number of elements asinstances to be explained.

deployedModelIdstring

id of the Endpoint's DeployedModel that served this explanation.

predictions[]value (Value format)

The predictions that are the output of the predictions call. Same asPredictResponse.predictions.

JSON representation
{"explanations":[{object (Explanation)}],"deployedModelId":string,"predictions":[value]}

ExplanationSpecOverride

TheExplanationSpec entries that can be overridden atonline explanation time.

Fields
parametersobject (ExplanationParameters)

The parameters to be overridden. Note that the attribution method cannot be changed. If not specified, no parameter is overridden.

The metadata to be overridden. If not specified, no metadata is overridden.

examplesOverrideobject (ExamplesOverride)

The example-based explanations parameter overrides.

JSON representation
{"parameters":{object (ExplanationParameters)},"metadata":{object (ExplanationMetadataOverride)},"examplesOverride":{object (ExamplesOverride)}}

ExplanationMetadataOverride

TheExplanationMetadata entries that can be overridden atonline explanation time.

Fields
inputsmap (key: string, value: object (InputMetadataOverride))

Required. Overrides theinput metadata of the features. The key is the name of the feature to be overridden. The keys specified here must exist in the input metadata to be overridden. If a feature is not specified here, the corresponding feature's input metadata is not overridden.

JSON representation
{"inputs":{string:{object (InputMetadataOverride)},...}}

InputMetadataOverride

Theinput metadata entries to be overridden.

Fields
inputBaselines[]value (Value format)

baseline inputs for this feature.

This overrides theinput_baseline field of theExplanationMetadata.InputMetadata object of the corresponding feature's input metadata. If it's not specified, the original baselines are not overridden.

JSON representation
{"inputBaselines":[value]}

ExamplesOverride

Overrides for example-based explanations.

Fields
neighborCountinteger

The number of neighbors to return.

crowdingCountinteger

The number of neighbors to return that have the same crowding tag.

restrictions[]object (ExamplesRestrictionsNamespace)

Restrict the resulting nearest neighbors to respect these constraints.

returnEmbeddingsboolean

If true, return the embeddings instead of neighbors.

dataFormatenum (DataFormat)

The format of the data being provided with each call.

JSON representation
{"neighborCount":integer,"crowdingCount":integer,"restrictions":[{object (ExamplesRestrictionsNamespace)}],"returnEmbeddings":boolean,"dataFormat":enum (DataFormat)}

ExamplesRestrictionsNamespace

Restrictions namespace for example-based explanations overrides.

Fields
namespaceNamestring

The namespace name.

allow[]string

The list of allowed tags.

deny[]string

The list of deny tags.

JSON representation
{"namespaceName":string,"allow":[string],"deny":[string]}

DataFormat

data format enum.

Enums
DATA_FORMAT_UNSPECIFIEDUnspecified format. Must not be used.
INSTANCESProvided data is a set of model inputs.
EMBEDDINGSProvided data is a set of embeddings.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-06-27 UTC.