HttpApiClient

@InternalApi()
public class HttpApiClient extends ApiClient

Base client for the HTTP APIs. This is for internal use only.

Constructors

Link copied to clipboard
public void HttpApiClient(Optional<String> apiKey, Optional<HttpOptions> httpOptions, Optional<ClientOptions> clientOptions)
Constructs an ApiClient for Google AI APIs.
public void HttpApiClient(Optional<String> apiKey, Optional<String> project, Optional<String> location, Optional<GoogleCredentials> credentials, Optional<HttpOptions> httpOptions, Optional<ClientOptions> clientOptions)
Constructs an ApiClient for Vertex AI APIs.

Functions

Link copied to clipboard
@Nullable()
public @Nullable() String apiKey()
Returns the API key for Google AI APIs.
Link copied to clipboard
public CompletableFuture<ApiResponse> asyncRequest(String httpMethod, String url, Array<byte> requestBytes, Optional<HttpOptions> requestHttpOptions)
Sends an asynchronous Http request given the http method, path, request bytes, and http options.
public CompletableFuture<ApiResponse> asyncRequest(String httpMethod, String path, String requestJson, Optional<HttpOptions> requestHttpOptions)
Sends an asynchronous Http request given the http method, path, request json string, and http options.
Link copied to clipboard
public void close()
public abstract 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 HttpApiResponse request(String httpMethod, String url, Array<byte> requestBytes, Optional<HttpOptions> requestHttpOptions)
Sends a Http request given the http method, path, request bytes, and http options.
public HttpApiResponse request(String httpMethod, String path, String requestJson, Optional<HttpOptions> requestHttpOptions)
Sends a Http request given the http method, path, request json string, and http options.
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.