public class VertexAI extends Object implements AutoCloseable
Note: The VertexAI instance will start a service client when the first API call is made. Please close the VertexAI instance after making any API calls so that clients get closed as well.
try (VertexAI vertexAi = new VertexAI("my-project", "us-central1"); ) {
GenerativeModel model = new GenerativeModel("gemini-pro", vertexAi)
// Do something with the model.
}
| Modifier and Type | Class and Description |
|---|---|
static class |
VertexAI.Builder
Builder for
VertexAI. |
| Constructor and Description |
|---|
VertexAI()
Constructs a VertexAI instance.
|
VertexAI(String projectId,
String location)
Constructs a VertexAI instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the VertexAI instance together with all its instantiated clients.
|
String |
getApiEndpoint()
Returns the default endpoint to use when making API calls.
|
com.google.auth.Credentials |
getCredentials()
Returns the default credentials to use when making API calls.
|
Map<String,String> |
getHeaders()
Returns the headers to use when making API calls.
|
LlmUtilityServiceClient |
getLlmUtilityClient()
Returns the
LlmUtilityServiceClient with GRPC or REST, based on the Transport type. |
String |
getLocation()
Returns the default location to use when making API calls.
|
PredictionServiceClient |
getPredictionServiceClient()
Returns the
PredictionServiceClient with GRPC or REST, based on the Transport type. |
String |
getProjectId()
Returns the default project to use when making API calls.
|
Transport |
getTransport()
Returns the default
Transport layer to use to send API requests. |
public VertexAI(String projectId, String location)
projectId - the default project to use when making API callslocation - the default location to use when making API callspublic VertexAI()
Note: SDK infers location from runtime environment first. If there is no location inferred from runtime environment, SDK will default location to `us-central1`.
SDK will infer projectId from runtime environment and GoogleCredentials.
IllegalArgumentException - If there is not projectId inferred from either
runtime environment or GoogleCredentialspublic Transport getTransport()
Transport layer to use to send API requests.Transport layer used when sending API requests.public String getProjectId()
public String getLocation()
public String getApiEndpoint()
public Map<String,String> getHeaders()
public com.google.auth.Credentials getCredentials()
throws IOException
Credentials to use when making API calls.IOException@InternalApi public PredictionServiceClient getPredictionServiceClient()
PredictionServiceClient with GRPC or REST, based on the Transport type. The
client will be instantiated when the first prediction API call is made.PredictionServiceClient that send requests to the backing service through
method calls that map to the API methods.@InternalApi public LlmUtilityServiceClient getLlmUtilityClient()
LlmUtilityServiceClient with GRPC or REST, based on the Transport type. The
client will be instantiated when the first API call is made.LlmUtilityServiceClient that makes calls to the backing service through method
calls that map to the API methods.public void close()
close in interface AutoCloseableCopyright © 2024 Google LLC. All rights reserved.