Enable model event notification with Cloud Functions and Pub/Sub

In Gemini Enterprise Agent Platform Vision, models receive media data from devices like cameras, run AI predictions on the data, and produce annotations continuously. Frequently you send that processed data to a data destination ("data sink") such as a media warehouse or BigQuery for further analytic jobs. However, you may have a case where some annotations must be handled differently, or the annotation needs are time-sensitive. Integrations with Cloud Run functions and Pub/Sub help you address these needs.

To be able to enable model event notifications, you need to do the following:

  1. Listen to the model data and generate events from it using Cloud Run functions.
  2. Send the Cloud Run functions generated events through the Pub/Sub event channel.

Supported models

The following models offer Cloud Run functions event generation and Pub/Sub event notification integrations:

Before you begin

Configure Cloud Run functions to process model output

To trigger event-based notifications, you must first set up Cloud Run functions to process model output and generate events.

Your Cloud Run function connects to the model and listens to its output as its post-processing action. The Cloud Run function you should return an AppPlatformCloudFunctionResponse. The events (appplatformeventbody) are sent to the Pub/Sub topic you configure in the next step.

Sample Cloud Run function (occupancy analytics model)

Sample Cloud Run function

/**
* Responds to any HTTP request.
*
* @param {!express:Request} req HTTP request context.
* @param {!express:Response} res HTTP response context.
*/
exports.hello_http = (req, res) => {
// Logging statement can be read with cmd `gcloud functions logs read {$functionName}`.
// For more about logging, please see https://cloud.google.