The Reasoning Engine API provides the managed runtime for your customized agentic workflows in generative AI applications. You can create an application using orchestration frameworks such as LangChain, and deploy it with Reasoning Engine. This service has all the security, privacy, observability, and scalability benefits of Vertex AI integration.
For more conceptual information about Reasoning Engine, see Deploy the application.
Limitations
- The Reasoning Engine API only supports Python orchestration frameworks.
- The Reasoning Engine API is only supported in the
us-central1
region.
Example syntax
Syntax to create and register a reasoning engine resource.
Python
class SimpleAdditionApp: def query() -> str: """ ... """ return ... reasoning_engine = reasoning_engines.ReasoningEngine.create( SimpleAdditionApp(), display_name="", description="", requirements=[...], extra_packages=[...], )
Parameter list
Parameters | |
---|---|
display_name |
Required: The display name of the |
description |
Optional: The description of the |
spec |
Required: Configurations of the |
package_spec |
Required: A user provided package specification, such as pickled objects and package requirements. |
class_methods |
Optional: Declarations for object class methods. |
PackageSpec
PackageSpec contains the reference to the Cloud Storage URI storing the OpenAPI YAML file.
Parameters | |
---|---|
pickle_object_gcs_uri |
Optional: The Cloud Storage URI of the pickled python object. |
dependency_files_gcs_uri |
Optional: The Cloud Storage URI of the dependency files with the |
requirements_gcs_uri |
Optional: The Cloud Storage URI of the |
python_version |
Optional: The Python version. Supported versions include Python |
QueryReasoningEngine
Parameters | |
---|---|
input |
The arguments inside |
Examples
Deploy a basic app configuration
The following example uses an application that adds two integers and a remote app with Reasoning Engine:
Python
To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.
Deploy an advanced app configuration
This is an advanced example that uses LangChain's chain, prompt templates, and the Gemini API:
Python
To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.
Query Reasoning Engine
Query a reasoning engine.
This example uses the SimpleAdditionApp
class from the Deploy a basic app configuration example.
REST
Before using any of the request data, make the following replacements:
- PROJECT_ID: Your project ID.
- LOCATION: The region to process the request. Must be
us-central1
. - REASONING_ENGINE_ID: The ID of the reasoning engine.
- INPUT:
protobuf.struct:
The arguments insideinput
should match the arguments inside of thedef query(self, question: str)
method defined during the Deploy a basic app configuration.
HTTP method and URL:
POST https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/REASONING_ENGINE_ID:query
Request JSON body:
{ "input": { INPUT } }
To send your request, choose one of these options:
curl
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/REASONING_ENGINE_ID:query"
PowerShell
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/REASONING_ENGINE_ID:query" | Select-Object -Expand Content
Python
To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.
List Reasoning Engines
List reasoning engines in a project.
REST
Before using any of the request data, make the following replacements:
- PROJECT_ID: Your project ID.
- PROJECT_ID: Your project ID.
- LOCATION: The region to process the request. Must be
us-central1
.
HTTP method and URL:
GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines" | Select-Object -Expand Content
Python
To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.
Get Reasoning Engine
Get details of a reasoning engine.
REST
Before using any of the request data, make the following replacements:
- PROJECT_ID: Your project ID.
- PROJECT_ID: Your project ID.
- LOCATION: The region to process the request. Must be
us-central1
. - REASONING_ENGINE_ID: The ID of the reasoning engine.
HTTP method and URL:
GET https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/REASONING_ENGINE_ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/REASONING_ENGINE_ID"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/REASONING_ENGINE_ID" | Select-Object -Expand Content
Python
To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.
Delete Reasoning Engine
Delete a reasoning engine.
REST
Before using any of the request data, make the following replacements:
- PROJECT_ID: Your project ID.
- LOCATION: The region to process the request. Must be
us-central1
. - REASONING_ENGINE_ID: The ID of the reasoning engine.
HTTP method and URL:
DELETE https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/REASONING_ENGINE_ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/REASONING_ENGINE_ID"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/REASONING_ENGINE_ID" | Select-Object -Expand Content
Python
To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Python API reference documentation.
What's next
- Learn more about using Vertex AI client libraries.