**Full name**: projects.locations.endpoints.explain

Perform an online explanation.

If `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#body.request_body.FIELDS.deployed_model_id` is specified, the corresponding endpoints.deployModel must have `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints#DeployedModel.FIELDS.explanation_spec` populated. If `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#body.request_body.FIELDS.deployed_model_id` is not specified, all DeployedModels must have `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints#DeployedModel.FIELDS.explanation_spec` populated.

### Endpoint

post `https://{service-endpoint}/v1/{endpoint}:explain`   
Where `{service-endpoint}` is one of the [supported service endpoints](https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest#rest_endpoints).

### Path parameters

`endpoint` `string` 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 (`https://protobuf.dev/reference/protobuf/google.protobuf#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' `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints#DeployedModel.FIELDS.model` `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.models#Model.FIELDS.predict_schemata` `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/PredictSchemata#FIELDS.instance_schema_uri`.
`parameters` ``value (`https://protobuf.dev/reference/protobuf/google.protobuf#value` format)`` The parameters that govern the prediction. The schema of the parameters may be specified via Endpoint's DeployedModels' `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints#DeployedModel.FIELDS.model` `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.models#Model.FIELDS.predict_schemata` `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/PredictSchemata#FIELDS.parameters_schema_uri`.
`explanationSpecOverride` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#ExplanationSpecOverride`)`` If specified, overrides the `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints#DeployedModel.FIELDS.explanation_spec` 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.
`deployedModelId` `string` If specified, this ExplainRequest will be served by the chosen DeployedModel, overriding `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints#Endpoint.FIELDS.traffic_split`.

### Response body

Response message for `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#google.cloud.aiplatform.v1.PredictionService.Explain`.

If successful, the response body contains data with the following structure:
Fields `explanations[]` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/Explanation`)`` The explanations of the Model's `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/PredictResponse#FIELDS.predictions`.

It has the same number of elements as `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#body.request_body.FIELDS.instances` to be explained.
`deployedModelId` `string` id of the Endpoint's DeployedModel that served this explanation.
`predictions[]` ``value (`https://protobuf.dev/reference/protobuf/google.protobuf#value` format)`` The predictions that are the output of the predictions call. Same as `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/PredictResponse#FIELDS.predictions`.

| JSON representation |
|---|
| ``` { "explanations": [ { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/Explanation`) } ], "deployedModelId": string, "predictions": [ value ] } ``` |

### IAM Permissions

Requires the following [IAM](https://cloud.google.com/iam/docs) permission on the `endpoint` resource:

- `aiplatform.endpoints.explain`

For more information, see the [IAM documentation](https://cloud.google.com/iam/docs).

## ExplanationSpecOverride

The `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/ExplanationSpec` entries that can be overridden at `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#google.cloud.aiplatform.v1.PredictionService.Explain` time.
Fields `parameters` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/ExplanationSpec#ExplanationParameters`)`` The parameters to be overridden. Note that the attribution method cannot be changed. If not specified, no parameter is overridden.
`metadata` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#ExplanationMetadataOverride`)`` The metadata to be overridden. If not specified, no metadata is overridden.
`examplesOverride` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#ExamplesOverride`)`` The example-based explanations parameter overrides.

| JSON representation |
|---|
| ``` { "parameters": { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/ExplanationSpec#ExplanationParameters`) }, "metadata": { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#ExplanationMetadataOverride`) }, "examplesOverride": { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#ExamplesOverride`) } } ``` |

## ExplanationMetadataOverride

The `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/ExplanationSpec#ExplanationMetadata` entries that can be overridden at `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#google.cloud.aiplatform.v1.PredictionService.Explain` time.
Fields `inputs` ``map (key: string, value: object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#InputMetadataOverride`))`` Required. Overrides the `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/ExplanationSpec#ExplanationMetadata.FIELDS.inputs` 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 (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#InputMetadataOverride`) }, ... } } ``` |

## InputMetadataOverride

The `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/ExplanationSpec#InputMetadata` entries to be overridden.
Fields `inputBaselines[]` ``value (`https://protobuf.dev/reference/protobuf/google.protobuf#value` format)`` baseline inputs for this feature.

This overrides the `input_baseline` field of the `https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/ExplanationSpec#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 `neighborCount` `integer` The number of neighbors to return.
`crowdingCount` `integer` The number of neighbors to return that have the same crowding tag.
`restrictions[]` ``object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#ExamplesRestrictionsNamespace`)`` Restrict the resulting nearest neighbors to respect these constraints.
`returnEmbeddings` `boolean` If true, return the embeddings instead of neighbors.
`dataFormat` ``enum (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#DataFormat`)`` The format of the data being provided with each call.

| JSON representation |
|---|
| ``` { "neighborCount": integer, "crowdingCount": integer, "restrictions": [ { object (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#ExamplesRestrictionsNamespace`) } ], "returnEmbeddings": boolean, "dataFormat": enum (`https://docs.cloud.google.com/gemini-enterprise-agent-platform/reference/rest/v1/projects.locations.endpoints/explain#DataFormat`) } ``` |

## ExamplesRestrictionsNamespace

Restrictions namespace for example-based explanations overrides.
Fields `namespaceName` `string` 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_UNSPECIFIED` | Unspecified format. Must not be used. |
| `INSTANCES` | Provided data is a set of model inputs. |
| `EMBEDDINGS` | Provided data is a set of embeddings. |