Class ClientOptions

  • All Implemented Interfaces:

    
    public final class ClientOptions
    
                        

    A class representing the SDK client configuration.

    • Constructor Detail

    • Method Detail

      • httpClient

         final HttpClient httpClient()

        The HTTP client to use in the SDK.

        Use the one published in openai-java-client-okhttp or implement your own.

      • checkJacksonVersionCompatibility

         final Boolean checkJacksonVersionCompatibility()

        Whether to throw an exception if any of the Jackson versions detected at runtime are incompatible with the SDK's minimum supported Jackson version (2.13.4).

        Defaults to true. Use extreme caution when disabling this option. There is no guarantee that the SDK will work correctly when using an incompatible Jackson version.

      • jsonMapper

         final JsonMapper jsonMapper()

        The Jackson JSON mapper to use for serializing and deserializing JSON.

        Defaults to com.openai.core.jsonMapper. The default is usually sufficient and rarely needs to be overridden.

      • clock

         final Clock clock()

        The clock to use for operations that require timing, like retries.

        This is primarily useful for using a fake clock in tests.

        Defaults to Clock.systemUTC.

      • responseValidation

         final Boolean responseValidation()

        Whether to call validate on every response before returning it.

        Defaults to false, which means the shape of the response will not be validated upfront. Instead, validation will only occur for the parts of the response that are accessed.

      • timeout

         final Timeout timeout()

        Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding retries.

        Defaults to Timeout.default.

      • maxRetries

         final Integer maxRetries()

        The maximum number of times to retry failed requests, with a short exponential backoff between requests.

        Only the following error types are retried:

        • Connection errors (for example, due to a network connectivity problem)

        • 408 Request Timeout

        • 409 Conflict

        • 429 Rate Limit

        • 5xx Internal

        The API may also explicitly instruct the SDK to retry or not retry a request.

        Defaults to 2.

      • baseUrl

         final String baseUrl()

        The base URL to use for every request.

        Defaults to the production environment: https://api.openai.com/v1.

      • fromEnv

         final static ClientOptions fromEnv()

        Returns options configured using system properties and environment variables.