Optional
auth?: VertexAiAuthConfigAuthorization configuration for VertexAI. If not supplied, it will be loaded from the environment.
Optional
client?: HttpClient<THttpClientOptions>HTTP client to use for requests. If not supplied, a client implementing Google Cloud Application Default Credentials will be used.
The model ID as defined by Google Cloud VertexAI.
The VertexAI Model Provider
If no auth is passed and GCLOUD_LOCATION or GCLOUD_PROJECT_ID are not found in process.env
import { createVertexAiModelProvider } from "@packages/gcloud-vertex-ai";
const gemini = await createVertexAiModelProvider({
modelId: "gemini-1.0-pro", // VertexAI defined model ID
// you can explicitly pass auth here, otherwise by default it is read from process.env
});
const response = await gemini.sendRequest({
$prompt: "Brief History of NY Mets:",
// all other Gemini options available here
});
console.log(response.data.candidates[0]);
Creates a Google Cloud VertexAI ModelProvider with the GoogleGeminiApi.
Provider Setup and Notes
Enable VertexAI in your Google Cloud Console. Note: VertexAI is currently only available in certain regions.
By default, this provider uses Google Cloud Application Default Credentials, meaning auth credentials will be found automatically based on the application environment. This is the preferred method of authentication if your app is running in Google Cloud.
Please follow instructions in "Set up Application Default Credentials" to set up ADC credentials.
If you pass in a custom client, Application Default Credentials will NOT be used, and auth logic will be left to the custom client. See google-auth-library for possible strategies about different ways to authenticate.
If you do not pass a VertexAiAuthConfig to
auth
, the values will be read from the environment asGCLOUD_LOCATION
andGCLOUD_PROJECT_ID
.Model Parameters
Model IDs