ApiClient

@InternalApi()
public abstract class ApiClient implements AutoCloseable

Interface for an API client which issues HTTP requests to the GenAI APIs.

Inheritors

Functions

Link copied to clipboard
@Nullable()
public @Nullable() String apiKey()
Returns the API key for Google AI APIs.
Link copied to clipboard
public abstract CompletableFuture<ApiResponse> asyncRequest(String httpMethod, String path, Array<byte> requestBytes, Optional<HttpOptions> httpOptions)
Sends an asynchronous Http request given the http method, path, request bytes, and http options.
public abstract CompletableFuture<ApiResponse> asyncRequest(String httpMethod, String path, String requestJson, Optional<HttpOptions> httpOptions)
Sends an asynchronous Http request given the http method, path, request json string, and http options.
Link copied to clipboard
public void close()
Link copied to clipboard
@Nullable()
public @Nullable() GoogleCredentials credentials()
Returns the GoogleCredentials for Vertex AI APIs.
Link copied to clipboard
@Nullable()
public @Nullable() String customBaseUrl()
Returns the custom base URL if provided.
Link copied to clipboard
public static ImmutableMap<String, String> defaultEnvironmentVariables()
Returns the default environment variables for the client.
Link copied to clipboard
public OkHttpClient httpClient()
Returns the HttpClient for API calls.
Link copied to clipboard
Returns the HTTP options for API calls.
Link copied to clipboard
@Nullable()
public @Nullable() String location()
Returns the location for Vertex AI APIs.
Link copied to clipboard
@Nullable()
public @Nullable() String project()
Returns the project ID for Vertex AI APIs.
Link copied to clipboard
public abstract ApiResponse request(String httpMethod, String path, Array<byte> requestBytes, Optional<HttpOptions> httpOptions)
Sends a Http request given the http method, path, and request bytes.
public abstract ApiResponse request(String httpMethod, String path, String requestJson, Optional<HttpOptions> httpOptions)
Sends a Http request given the http method, path, and request json string.
Link copied to clipboard
public static void setDefaultBaseUrls(Optional<String> geminiBaseUrl, Optional<String> vertexBaseUrl)
Overrides the base URLs for the Gemini API and/or Vertex AI API.
Link copied to clipboard
public boolean vertexAI()
Returns whether the client is using Vertex AI APIs.