Class ClientOptions
-
- All Implemented Interfaces:
public final class ClientOptions
A class representing the SDK client configuration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final class
ClientOptions.Builder
A builder for ClientOptions.
-
Field Summary
Fields Modifier and Type Field Description public final static String
PRODUCTION_URL
private final HttpClient
httpClient
private final Boolean
checkJacksonVersionCompatibility
private final JsonMapper
jsonMapper
private final Executor
streamHandlerExecutor
private final Clock
clock
private final Headers
headers
private final QueryParams
queryParams
private final Boolean
responseValidation
private final Timeout
timeout
private final Integer
maxRetries
private final Credential
credential
private final AzureOpenAIServiceVersion
azureServiceVersion
-
Method Summary
Modifier and Type Method Description final HttpClient
httpClient()
The HTTP client to use in the SDK. 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). final JsonMapper
jsonMapper()
The Jackson JSON mapper to use for serializing and deserializing JSON. final Executor
streamHandlerExecutor()
The executor to use for running AsyncStreamResponse.Handler callbacks. final Clock
clock()
The clock to use for operations that require timing, like retries. final Headers
headers()
Headers to send with the request. final QueryParams
queryParams()
Query params to send with the request. final Boolean
responseValidation()
Whether to call validate
on every response before returning it.final Timeout
timeout()
Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding retries. final Integer
maxRetries()
The maximum number of times to retry failed requests, with a short exponential backoff between requests. final Credential
credential()
final AzureOpenAIServiceVersion
azureServiceVersion()
final String
baseUrl()
The base URL to use for every request. final Optional<String>
organization()
final Optional<String>
project()
final Optional<String>
webhookSecret()
final ClientOptions.Builder
toBuilder()
final static ClientOptions.Builder
builder()
Returns a mutable builder for constructing an instance of ClientOptions. final static ClientOptions
fromEnv()
Returns options configured using system properties and environment variables. -
-
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.
-
streamHandlerExecutor
final Executor streamHandlerExecutor()
The executor to use for running AsyncStreamResponse.Handler callbacks.
Defaults to a dedicated cached thread pool.
-
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.
-
queryParams
final QueryParams queryParams()
Query params to send with the request.
-
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.
-
credential
final Credential credential()
-
azureServiceVersion
final AzureOpenAIServiceVersion azureServiceVersion()
-
baseUrl
final String baseUrl()
The base URL to use for every request.
Defaults to the production environment:
https://api.openai.com/v1
.
-
organization
final Optional<String> organization()
-
webhookSecret
final Optional<String> webhookSecret()
-
toBuilder
final ClientOptions.Builder toBuilder()
-
builder
final static ClientOptions.Builder builder()
Returns a mutable builder for constructing an instance of ClientOptions.
The following fields are required:
.httpClient() .apiKey()
-
fromEnv
final static ClientOptions fromEnv()
Returns options configured using system properties and environment variables.
-
-
-
-