Method: projects.locations.extensions.execute

Executes the request against a given extension.

Endpoint

post https://{endpoint}/v1beta1/{name}:execute

Where {service-endpoint} is one of the supported service endpoints.

Path parameters

name string

Required. name (identifier) of the extension; Format: projects/{project}/locations/{location}/extensions/{extension}

Request body

The request body contains data with the following structure:

Fields
operationId string

Required. The desired id of the operation to be executed in this extension as defined in ExtensionOperation.operation_id.

operationParams object (Struct format)

Optional. Request parameters that will be used for executing this operation.

The struct should be in a form of map with param name as the key and actual param value as the value. E.g. If this operation requires a param "name" to be set to "abc". you can set this to something like {"name": "abc"}.

runtimeAuthConfig object (AuthConfig)

Optional. Auth config provided at runtime to override the default value in [Extension.manifest.auth_config][]. The AuthConfig.auth_type should match the value in [Extension.manifest.auth_config][].

Example request

Python

import vertexai
from vertexai.preview import extensions

# TODO(developer): Update and un-comment below lines
# PROJECT_ID = "your-project-id"
# extension_id = "your-extension-id"
vertexai.init(project=PROJECT_ID, location="us-central1")

extension = extensions.Extension(extension_id)

response = extension.execute(
    operation_id="generate_and_execute",
    operation_params={"query": "find the max value in the list: [1,2,3,4,-5]"},
)
print(response)
# Example response:
# {
#     "generated_code": "```python\n# Find the maximum value in the list\ndata = [1, 2,..", ..
#     "execution_result": "The maximum value in the list is: 4\n",
#     "execution_error": "",
#     "output_files": [],
# }

Response body

Response message for ExtensionExecutionService.ExecuteExtension.

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

Fields
content string

Response content from the extension. The content should be conformant to the response.content schema in the extension's manifest/OpenAPI spec.

JSON representation
{
  "content": string
}