Class ApiClient

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    @InternalApi() 
    public abstract class ApiClient
     implements AutoCloseable
                        

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

    • Constructor Detail

    • Method Detail

      • vertexAI

         boolean vertexAI()

        Returns whether the client is using Vertex AI APIs.

      • project

        @Nullable() String project()

        Returns the project ID for Vertex AI APIs.

      • location

        @Nullable() String location()

        Returns the location for Vertex AI APIs.

      • apiKey

        @Nullable() String apiKey()

        Returns the API key for Google AI APIs.

      • httpClient

         OkHttpClient httpClient()

        Returns the HttpClient for API calls.

      • credentials

        @Nullable() GoogleCredentials credentials()

        Returns the GoogleCredentials for Vertex AI APIs.

      • defaultEnvironmentVariables

         static ImmutableMap<String, String> defaultEnvironmentVariables()

        Returns the default environment variables for the client. Supported environment variables:

        • googleApiKey -> GOOGLE_API_KEY environment variable.
        • geminiApiKey -> GEMINI_API_KEY environment variable.
        • project -> GOOGLE_CLOUD_PROJECT: Project ID for Vertex AI APIs.
        • location -> GOOGLE_CLOUD_LOCATION: Location for Vertex AI APIs.
        • vertexAI -> GOOGLE_GENAI_USE_VERTEXAI: Whether to use Vertex AI APIs(true or false).
        • geminiBaseUrl -> GOOGLE_GEMINI_BASE_URL: Base URL for Gemini APIs.
        • vertexBaseUrl -> GOOGLE_VERTEX_BASE_URL: Base URL for Vertex AI APIs.