Example: Using Vertex AI
This example answers an inbound Voximplant call and connects Gemini Live API through Vertex AI. It separates the Vertex service account credentials into a dedicated scenario so you can keep them isolated and reuse them across routes.
⬇️ Jump to the Full VoxEngine scenario.
Prerequisites
- Set up an inbound entrypoint for the caller:
- Phone number: https://voximplant.com/docs/getting-started/basic-concepts/phone-numbers
- WhatsApp: https://voximplant.com/docs/guides/integrations/whatsapp
- SIP user / SIP registration: https://voximplant.com/docs/guides/calls/sip
- Voximplant user: https://voximplant.com/docs/getting-started/basic-concepts/users (see also https://voximplant.com/docs/guides/calls/scenarios#how-to-call-a-voximplant-user)
- Create a routing rule that points the destination (number / WhatsApp / SIP username) to this scenario: https://voximplant.com/docs/getting-started/basic-concepts/routing-rules
- Store your Vertex parameters in Voximplant
ApplicationStorage:GCP_PROJECT_IDGCP_REGION
For full Vertex setup details, see: https://voximplant.com/docs/voice-ai/google/vertex To create a service account key (JSON), see: https://docs.cloud.google.com/iam/docs/keys-create-delete
Credentials scenario (separate route entry)
Store the Vertex service account JSON in a separate scenario and include it before the main scenario in your routing rule.
Routing rule scenario order:
Why a separate scenario?
Vertex credentials JSON is typically too large for ApplicationStorage. VoxEngine shares global scope across scenarios in the same routing rule, so a credentials scenario can set a global variable for the main scenario to read.
Example credentials scenario:
Credentials are redacted
The example credentials are intentionally obfuscated and will not work. Create your own credentials scenario with your real service account JSON.
Session setup
The Gemini Live API session is configured via connectConfig, passed into Gemini.createLiveAPIClient(...).
In the full scenario, see GEMINI_CONNECT_CONFIG:
responseModalities: ["AUDIO"]asks Gemini to speak back in real time.apiVersion: "v1alpha"matches the Vertex Live API endpoint.speechConfigselects a prebuilt voice.systemInstructiondefines the assistant behavior.toolsandtoolConfigenable function calling.
The Vertex-specific parameters are passed directly to Gemini.createLiveAPIClient(...):
backend: Gemini.Backend.VERTEX_AIproject→GCP_PROJECT_IDlocation→GCP_REGIONcredentials→ the JSON string set by the credentials scenario
Connect call audio
After Gemini.LiveAPIEvents.SetupComplete, bridge audio between the call and Gemini:
The same handler sends a starter message to trigger the greeting:
Events
The scenario logs Gemini events for debugging:
Gemini.LiveAPIEvents:SetupComplete,ServerContent,ToolCall,ToolCallCancellation,ConnectorInformation,UnknownGemini.Events:WebSocketMediaStarted,WebSocketMediaEnded
Notes
- This example uses the Vertex AI backend (
Gemini.Backend.VERTEX_AI). - The credentials scenario only sets
GEMINI_VERTEX_CREDENTIALSin the shared global scope and does not start any calls.
See the VoxEngine API Reference for more details.