New to Kestra?
Use blueprints to kickstart your first workflows.
Classify Pub/Sub events with Vertex AI Gemini, route high-priority ones to BigQuery and Discord, all orchestrated declaratively with Kestra.
Put a Gemini model from Vertex AI inline in your event pipeline as an automated guardrail. Every Pub/Sub message starts one Kestra execution, a Gemini model on Vertex AI classifies the payload as high or low priority, and an If branch routes the high-priority ones to a BigQuery audit table and a Discord channel. The classification decision is code, not a human pause, so routine event routing happens in milliseconds with a full execution record per message.
This solves a common gap in event-driven LLM pipelines: you want the language model in the decision loop, but you also want deterministic routing, retries on transient failures, and a queryable history of every classification. Wiring that together with a Pub/Sub push subscriber, a Cloud Function, and ad-hoc BigQuery inserts is brittle. Kestra gives you one declarative YAML flow with the trigger, the model call, the conditional routing, and the error handler in scope.
io.kestra.plugin.gcp.pubsub.RealtimeTrigger (on_event) subscribes to the events topic via the kestra-events-sub subscription and starts one execution per message, deserializing the payload as JSON.io.kestra.plugin.gcp.vertexai.ChatCompletion (classify) sends the event body to gemini-1.5-flash in us-central1 with a tight prompt that forces a single-word label, high or low.io.kestra.plugin.core.flow.If (guardrail) evaluates outputs.classify.predictions[0] | lower == 'high' and only enters the then-branch when the model returns high priority.io.kestra.plugin.gcp.bigquery.Query (record) inserts the message id, priority, and timestamp into the analytics.priority_events audit table.io.kestra.plugin.discord.DiscordIncomingWebhook (escalate) posts a structured alert to the configured Discord channel with the message id and the execution id.errors block pages the same Discord webhook if anything in the pipeline fails, so silent drops are not possible.Vertex AI is a model API, not a workflow engine. Pub/Sub push delivery can invoke a Cloud Function, but you still need to glue together the classification, the conditional logic, the BigQuery write, the Discord alert, and the failure path, and you still have no central place to see what ran. Kestra wraps all of it in a declarative YAML flow with built-in retries via pluginDefaults, an errors block for alerting, lineage and outputs preserved for every execution, and a UI to inspect each event run. The RealtimeTrigger keeps the event-per-execution model that Pub/Sub natively supports, so you do not lose the streaming feel.
events and a subscription named kestra-events-sub.analytics with a priority_events table (message_id STRING, priority STRING, logged_at TIMESTAMP).gemini-1.5-flash) enabled in the us-central1 region.GCP_PROJECT_ID: the GCP project hosting Pub/Sub, Vertex AI, and BigQuery.GCP_SERVICE_ACCOUNT: service account key JSON with Pub/Sub subscriber, Vertex AI user, and BigQuery data editor roles.DISCORD_WEBHOOK_URL: Discord incoming webhook URL for escalations and failure alerts.RealtimeTrigger topic and subscription at your Pub/Sub resources.disabled: true from the trigger and publish a test message to the topic.gemini-1.5-flash for gemini-1.5-pro when accuracy matters more than latency.