Package com.google.genai
Class Client
java.lang.Object
com.google.genai.Client
- All Implemented Interfaces:
AutoCloseable
Client class for GenAI. This class is thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classAsync class for GenAI.static classBuilder forClient. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Agentsfinal Client.Asyncfinal Tokensfinal Batchesfinal Cachesfinal Chatsfinal Credentialsfinal Decisionsfinal Environmentsfinal Filesfinal FileSearchStoresfinal Interactionsfinal Modelsfinal Operationsfinal Triggersfinal Tuningsfinal Voicesfinal Webhooks -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapiKey()Returns the API key for the Gemini Developer API or the Gemini Enterprise API.static Client.Builderbuilder()Returns aClient.BuilderforClient.voidclose()Closes the Client instance together with its instantiated http client.booleanReturns whether the client is using the Gemini Enterprise API.booleanReturnstrueif no API version was configured viaHttpOptions.apiVersion()or theGOOGLE_GENAI_API_VERSIONenvironment variable, so the client is using the SDK's default API version for its backend.location()Returns the location for the Gemini Enterprise API.project()Returns the project ID for the Gemini Enterprise API.static voidsetDefaultBaseUrls(Optional<String> geminiBaseUrl, Optional<String> vertexBaseUrl) Overrides the base URLs for the Gemini Developer API and/or the Gemini Enterprise API.booleanvertexAI()Returns whether the client is using the Gemini Enterprise API.
-
Field Details
-
models
-
batches
-
caches
-
operations
-
chats
-
files
-
async
-
authTokens
-
tunings
-
fileSearchStores
-
interactions
-
agents
-
webhooks
-
environments
-
triggers
-
credentials
-
voices
-
decisions
-
-
Constructor Details
-
Client
public Client()Constructs a Client instance with environment variables.
-
-
Method Details
-
builder
Returns aClient.BuilderforClient. -
vertexAI
public boolean vertexAI()Returns whether the client is using the Gemini Enterprise API. Preferenterprise(). -
enterprise
public boolean enterprise()Returns whether the client is using the Gemini Enterprise API. -
isDefaultApiVersion
public boolean isDefaultApiVersion()Returnstrueif no API version was configured viaHttpOptions.apiVersion()or theGOOGLE_GENAI_API_VERSIONenvironment variable, so the client is using the SDK's default API version for its backend. -
project
Returns the project ID for the Gemini Enterprise API. -
location
Returns the location for the Gemini Enterprise API. -
apiKey
Returns the API key for the Gemini Developer API or the Gemini Enterprise API. -
close
public void close()Closes the Client instance together with its instantiated http client.- Specified by:
closein interfaceAutoCloseable
-
setDefaultBaseUrls
public static void setDefaultBaseUrls(Optional<String> geminiBaseUrl, Optional<String> vertexBaseUrl) Overrides the base URLs for the Gemini Developer API and/or the Gemini Enterprise API.Note: This function should be called before initializing the SDK. If the base URLs are set after initializing the SDK, the base URLs will not be updated.
Precedence rule for base URL:
1. Base URL set via HttpOptions.
2. Base URL set via the latest call to setDefaultBaseUrls.
3. Base URL set via environment variables GOOGLE_GEMINI_BASE_URL or GOOGLE_VERTEX_BASE_URL.
-