Vertex AI Agent Builder: using the VIDAI Control Plane as the backend¶
Vertex AI Agent Builder's agents call Cloud Functions or webhooks for their tool/action steps. Point those hooks at the control plane's OpenAI-compatible endpoint and every downstream LLM call your agent makes flows through us.
TL;DR — Cloud Function webhook¶
import functions_framework
from openai import OpenAI
client = OpenAI(
base_url="https://your-vidai-server.example.com/v1",
api_key="your-vidai-key",
)
@functions_framework.http
def agent_action(request):
body = request.get_json()
prompt = body.get("prompt", "")
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": prompt}],
)
return {"reply": resp.choices[0].message.content}
Wire this Cloud Function as a webhook / tool on your agent in the Agent Builder UI.
Prerequisites¶
- A Google Cloud project with Vertex AI Agent Builder enabled.
- A Cloud Function (or Cloud Run service) with egress to the control plane URL.
- Control plane base URL and an API key from API Keys.
- Store the API key in Secret Manager; mount it into the
function at deploy time (
--set-secrets).
Store the API key in Secret Manager¶
echo -n "your-vidai-key" | gcloud secrets create vidai-api-key --data-file=-
gcloud functions deploy agent_action \
--runtime=python312 \
--trigger-http \
--allow-unauthenticated \
--set-secrets=VIDAI_API_KEY=vidai-api-key:latest
Then read it in the function:
import os
client = OpenAI(
base_url="https://your-vidai-server.example.com/v1",
api_key=os.environ["VIDAI_API_KEY"],
)
Attribution¶
Every downstream call from the Cloud Function authenticates with
the single VIDAI API key mounted from Secret Manager. Create an
application on the Applications page
named after the Vertex agent (e.g.
vertex-support-agent), mint an agent inside it, and use that
agent's key. The Bedrock agent's spend appears as its own line
item on the Chargeback
tab.
Using Vertex Gemini models via the control plane¶
Register Vertex AI as an upstream provider on the control plane's Providers page. Then your Cloud Function can call Gemini models by name — the control plane handles the Vertex OAuth exchange:
resp = client.chat.completions.create(
model="gemini-2.0-flash",
messages=[{"role": "user", "content": prompt}],
)
Verify it works¶
Test in the Agent Builder simulator:
- Trigger the intent that invokes your webhook.
- Check the Cloud Function logs for the OpenAI call.
- Confirm a row lands on Request Logs attributed to the Cloud Function's API key.
If something's off¶
Raise an issue at github.com/vidaiUK/vidai-quickstart/issues with the webhook code and the Cloud Function log excerpt around the failing call. We'll get it sorted.
Where to go next¶
- Client integrations overview
- Applications — one per Vertex agent
- Providers — Vertex as an upstream provider
- Chargeback