Package com.google.genai
Class Client
-
- All Implemented Interfaces:
-
java.lang.AutoCloseable
public final class Client implements AutoCloseable
Client class for GenAI. This class is thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classClient.AsyncAsync class for GenAI.
public classClient.BuilderBuilder for Client.
-
Field Summary
Fields Modifier and Type Field Description public final Modelsmodelspublic final Batchesbatchespublic final Cachescachespublic final Operationsoperationspublic final Chatschatspublic final Filesfilespublic final Client.Asyncasyncpublic final TokensauthTokenspublic final Tuningstuningspublic final FileSearchStoresfileSearchStorespublic final InteractionServiceinteractions
-
Constructor Summary
Constructors Constructor Description Client()Constructs a Client instance with environment variables.
-
Method Summary
Modifier and Type Method Description static Client.Builderbuilder()Returns a Builder for Client. booleanenterprise()Returns whether the client is using Gemini Enterprise Agent Platform. booleanvertexAI()Returns whether the client is using Vertex AI APIs. Stringproject()Returns the project ID for Vertex AI APIs. Stringlocation()Returns the location for Vertex AI APIs. StringapiKey()Returns the API key for Gemini API. voidclose()Closes the Client instance together with its instantiated http client. static voidsetDefaultBaseUrls(Optional<String> geminiBaseUrl, Optional<String> vertexBaseUrl)Overrides the base URLs for the Gemini API and/or Vertex AI API. -
-
Method Detail
-
builder
static Client.Builder builder()
-
enterprise
boolean enterprise()
Returns whether the client is using Gemini Enterprise Agent Platform.
-
vertexAI
boolean vertexAI()
Returns whether the client is using Vertex AI APIs.
-
close
void close()
Closes the Client instance together with its instantiated http client.
-
setDefaultBaseUrls
static void setDefaultBaseUrls(Optional<String> geminiBaseUrl, Optional<String> vertexBaseUrl)
Overrides the base URLs for the Gemini API and/or Vertex AI 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.
-
-
-
-