ChatVertex
ChatVertex(
model=None,
project=None,
location=None,
api_key=None,
system_prompt=None,
kwargs=None,
)Chat with a Google Vertex AI model.
Prerequisites
NotePython requirements
ChatGoogle requires the google-genai package: pip install "chatlas[vertex]".
NoteCredentials
To use Google’s models (i.e., Vertex AI), you’ll need to sign up for an account with Vertex AI, then specify the appropriate model, project, and location.
Vertex AI typically authenticates via Application Default Credentials (ADC). You can also pass a google.auth.credentials.Credentials object via kwargs:
import google.auth
credentials, project = google.auth.default()
chat = ChatVertex(
project=project,
location="us-central1",
kwargs={"credentials": credentials},
)Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| model | Optional[str] | The model to use for the chat. The default, None, will pick a reasonable default, and warn you about it. We strongly recommend explicitly choosing a model for all but the most casual use. | None |
| project | Optional[str] | The Google Cloud project ID (e.g., “your-project-id”). If not provided, the GOOGLE_CLOUD_PROJECT environment variable will be used. | None |
| location | Optional[str] | The Google Cloud location (e.g., “us-central1”). If not provided, the GOOGLE_CLOUD_LOCATION environment variable will be used. | None |
| system_prompt | Optional[str] | A system prompt to set the behavior of the assistant. | None |
Returns
| Name | Type | Description |
|---|---|---|
| Chat | A Chat object. |
Examples
import os
from chatlas import ChatVertex
chat = ChatVertex(
project="your-project-id",
location="us-central1",
)
chat.chat("What is the capital of France?")