Google Vertex AI

Updated

Integrate Google Vertex AI into Conversational AI Engine.

Google Vertex AI provides enterprise-grade access to Google's generative AI models with enhanced security, scaling capabilities, and integration with Google Cloud services.

Sample configuration

The following examples show how to configure Google Vertex AI LLM when starting a conversational AI agent.

from agora_agent import Agent, VertexAILLM

# client is your configured Agora client
agent = (
    Agent(client)
    .with_stt(...)  # configure your STT vendor
    .with_llm(VertexAILLM(
        api_key='your-gcp-access-token',
        project_id='your-gcp-project-id',
        location='us-central1',
        model='gemini-2.0-flash-001',
        system_messages=[{'parts': [{'text': 'You are a helpful chatbot.'}], 'role': 'user'}],
        greeting_message='Good to see you!',
        failure_message='Hold on a second.',
        max_history=32,
    ))
    .with_tts(...)  # configure your TTS vendor
)
import { Agent, VertexAILLM } from 'agora-agents';

// client is your configured Agora client
const agent = new Agent({ client })
  .withStt(/* configure your STT vendor */)
  .withLlm(new VertexAILLM({
    apiKey: 'your-gcp-access-token',
    projectId: 'your-gcp-project-id',
    location: 'us-central1',
    model: 'gemini-2.0-flash-001',
    systemMessages: [{ parts: [{ text: 'You are a helpful chatbot.' }], role: 'user' }],
    greetingMessage: 'Good to see you!',
    failureMessage: 'Hold on a second.',
    maxHistory: 32,
  }))
  .withTts(/* configure your TTS vendor */);
import "github.com/AgoraIO/agora-agents-go/v2/agentkit/vendors"

// client is your configured Agora client
agent := agentkit.NewAgent(client).WithStt(/* configure your STT vendor */).
  WithLlm(
    vendors.NewVertexAILLM(vendors.VertexAILLMOptions{
        APIKey:    "your-gcp-access-token",
        ProjectID: "your-gcp-project-id",
        Location:  "us-central1",
        Model:     "gemini-2.0-flash-001",
        SystemMessages: []map[string]interface{}{
            {"parts": []map[string]interface{}{{"text": "You are a helpful chatbot."}}, "role": "user"},
        },
        GreetingMessage: "Good to see you!",
        FailureMessage:  "Hold on a second.",
        MaxHistory:      agora.Int(32),
    }),
).WithTts(/* configure your TTS vendor */)

Use the following llm configuration in your request:

"llm": {
   "url": "https://{region}-aiplatform.googleapis.com/v1/projects/{project}/locations/{region}/publishers/google/models/{model}:streamGenerateContent?alt=sse",
   "api_key": "$(gcloud auth print-access-token)",
   "system_messages": [
       {
           "role": "user",
           "parts": [ {"text": "You are a helpful chatbot."} ]
       }
   ],
   "max_history": 32,
   "greeting_message": "Good to see you!",
   "failure_message": "Hold on a second.",
   "params": {
       "model": "gemini-2.0-flash-001"
   },
   "style": "gemini"
}

Key parameters

llmrequired
api_keystring
required

Refer to Google Cloud REST authentication to get your GCP credentials.

urlstring
required

Use the Vertex AI endpoint with your Google Cloud project ID and region in the URL path. Refer to the Google Vertex AI API documentation for details.

system_messagesarray[object]
optional

Use a parts array with text objects instead of a simple content string.

stylestring
required

Set to gemini to use Gemini's message format.

paramsobject
required
modelstring
required

Refer to Vertex AI models for available models.

For advanced configuration options, model capabilities, and detailed parameter descriptions, see the Google Vertex AI API documentation.