A partire dal 29 aprile 2025, i modelli Gemini 1.5 Pro e Gemini 1.5 Flash non sono disponibili nei progetti che non li hanno mai utilizzati, inclusi i nuovi progetti. Per maggiori dettagli, vedi Versioni e ciclo di vita dei modelli.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
public class VertexAI implements AutoCloseable
Questa classe contiene le impostazioni e le credenziali predefinite per effettuare chiamate API Vertex AI.
Nota: l'istanza Vertex AI avvierร un client di servizio quando viene effettuata la prima chiamata API. Chiudi l'istanza Vertex AI dopo aver effettuato chiamate API, in modo che anche i client vengano chiusi.
try (VertexAI vertexAi = new VertexAI("my-project", "us-central1"); ) {
GenerativeModel model = new GenerativeModel("gemini-pro", vertexAi)
// Do something with the model.
}
public LlmUtilityServiceClient getLlmUtilityClient()
Restituisce LlmUtilityServiceClient con GRPC o REST, in base al tipo di trasporto. Verrร creata un'istanza del client quando viene effettuata la prima chiamata API.
public PredictionServiceClient getPredictionServiceClient()
Restituisce PredictionServiceClient con GRPC o REST, in base al tipo di trasporto. Verrร creata un'istanza del client quando viene effettuata la prima chiamata all'API di previsione.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema รจ stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2024-05-17 UTC."],[],[],null,["# Class VertexAI (1.32.0)\n\n public class VertexAI implements AutoCloseable\n\nThis class holds default settings and credentials to make Vertex AI API calls.\n\n**Note:** The VertexAI instance will start a service client when the first API call is\nmade. Please close the VertexAI instance after making any API calls so that clients get closed as\nwell. \n\n\n try (VertexAI vertexAi = new VertexAI(\"my-project\", \"us-central1\"); ) {\n GenerativeModel model = new GenerativeModel(\"gemini-pro\", vertexAi)\n // Do something with the model.\n }\n \nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e VertexAI \n\nImplements\n----------\n\n[AutoCloseable](https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html) \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nConstructors\n------------\n\n### VertexAI()\n\n public VertexAI()\n\nConstructs a VertexAI instance.\n\n**Note:** SDK infers location from runtime environment first. If there is no location\ninferred from runtime environment, SDK will default location to `us-central1`.\n\nSDK will infer projectId from runtime environment and GoogleCredentials.\n\n### VertexAI(String projectId, String location)\n\n public VertexAI(String projectId, String location)\n\nConstructs a VertexAI instance.\n\nMethods\n-------\n\n### close()\n\n public void close()\n\nCloses the VertexAI instance together with all its instantiated clients.\n\n### getApiEndpoint()\n\n public String getApiEndpoint()\n\nReturns the default endpoint to use when making API calls.\n\n### getCredentials()\n\n public Credentials getCredentials()\n\nReturns the default credentials to use when making API calls.\n\n### getHeaders()\n\n public Map\u003cString,String\u003e getHeaders()\n\nReturns the headers to use when making API calls.\n\n### getLlmUtilityClient()\n\n public LlmUtilityServiceClient getLlmUtilityClient()\n\n| **Internal Only**: This feature is not stable for application use.\n\nReturns the [LlmUtilityServiceClient](/vertex-ai/generative-ai/docs/reference/java/latest/com.google.cloud.vertexai.api.LlmUtilityServiceClient) with GRPC or REST, based on the Transport type. The\nclient will be instantiated when the first API call is made.\n\n### getLocation()\n\n public String getLocation()\n\nReturns the default location to use when making API calls.\n\n### getPredictionServiceClient()\n\n public PredictionServiceClient getPredictionServiceClient()\n\n| **Internal Only**: This feature is not stable for application use.\n\nReturns the [PredictionServiceClient](/vertex-ai/generative-ai/docs/reference/java/latest/com.google.cloud.vertexai.api.PredictionServiceClient) with GRPC or REST, based on the Transport type. The\nclient will be instantiated when the first prediction API call is made.\n\n### getProjectId()\n\n public String getProjectId()\n\nReturns the default project to use when making API calls.\n\n### getTransport()\n\n public Transport getTransport()\n\nReturns the default [Transport](/vertex-ai/generative-ai/docs/reference/java/latest/com.google.cloud.vertexai.Transport) layer to use to send API requests."]]