Vertex AI

Use Vertex AI models with PraisonAI Agents

Point an Agent at Vertex AI by setting your credentials and naming the model.

Diagram

Vertex AI with PraisonAI

📝 Agent

🔧 litellm

🌐 Vertex AI API

✅ Response

Quick Start

  1. Install
    bash
    pip install "praisonaiagents[llm]"
  2. Set credentials
    bash
    export VERTEXAI_PROJECT=your-gcp-project
    export VERTEXAI_LOCATION=us-central1
  3. Run an agent
    python
    from praisonaiagents import Agent
    
    agent = Agent(
        instructions="You are a helpful assistant",
        model="vertex_ai/gemini-1.5-pro",
    )
    
    agent.start("Hello!")

How it works

The vertex_ai/ prefix tells PraisonAI to route the request through litellm to Vertex AI, which reads VERTEXAI_PROJECT, VERTEXAI_LOCATION from your environment. See Provider Auto-Detection for how model strings are resolved.

Diagram
Vertex AI APIlitellmAgentUserVertex AI APIlitellmAgentUseragent.start(“Hello!”)model=”vertex_ai/…”Request with your credentialsModel replyResponse

Common Patterns

Pick a different model

Keep the vertex_ai/ prefix and swap the rest for any model your Vertex AI account offers.

python
from praisonaiagents import Agent

agent = Agent(
    instructions="You are a helpful assistant",
    model="vertex_ai/gemini-1.5-pro",
)

Tune the response with a config dict

Pass a dict to set temperature, token limits, or other options.

python
from praisonaiagents import Agent

agent = Agent(
    instructions="You write short, friendly answers",
    model={
        "model": "vertex_ai/gemini-1.5-pro",
        "temperature": 0.3,
        "max_tokens": 500,
    },
)

agent.start("Give me three tips for better sleep.")

Use Claude on Vertex AI

Claude models hosted on Vertex AI use the same vertex_ai/ prefix.

python
from praisonaiagents import Agent

agent = Agent(
    instructions="You are a helpful assistant",
    model="vertex_ai/claude-3-5-sonnet@20240620",
)

agent.start("Hello!")

Best Practices

Prefer the shortest form

Start with model="vertex_ai/gemini-1.5-pro" and nothing else. Add a config dict only when you need to tune temperature or limits.

Set the provider key once via env

Export VERTEXAI_PROJECT, VERTEXAI_LOCATION in your shell or .env file. Keep keys out of your code.

Keep model= canonical

Always use model=. The older llm= name still works but prints a deprecation warning. See Model Parameter.

Related