public abstract static class OpenAiClient.Builder<T extends OpenAiClient,B extends OpenAiClient.Builder<T,B>> extends Object
| Modifier and Type | Field and Description |
|---|---|
String |
apiVersion |
String |
azureApiKey |
String |
baseUrl |
Duration |
callTimeout |
Duration |
connectTimeout |
Map<String,String> |
customHeaders |
LogLevel |
logLevel |
boolean |
logRequests |
boolean |
logResponses |
boolean |
logStreamingResponses |
String |
openAiApiKey |
String |
organizationId |
Path |
persistTo |
Proxy |
proxy |
Duration |
readTimeout |
String |
userAgent |
Duration |
writeTimeout |
| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
B |
apiVersion(String apiVersion) |
B |
azureApiKey(String azureApiKey) |
B |
baseUrl(String baseUrl) |
abstract T |
build() |
B |
callTimeout(Duration callTimeout) |
B |
connectTimeout(Duration connectTimeout) |
B |
customHeaders(Map<String,String> customHeaders)
Custom headers to be added to each HTTP request.
|
B |
logLevel(LogLevel logLevel) |
B |
logRequests() |
B |
logRequests(Boolean logRequests) |
B |
logResponses() |
B |
logResponses(Boolean logResponses) |
B |
logStreamingResponses() |
B |
logStreamingResponses(Boolean logStreamingResponses) |
B |
openAiApiKey(String openAiApiKey) |
B |
organizationId(String organizationId) |
B |
persistTo(Path persistTo)
Generated response will be persisted under provided path.
|
B |
proxy(Proxy.Type type,
String ip,
int port) |
B |
proxy(Proxy proxy) |
B |
readTimeout(Duration readTimeout) |
B |
userAgent(String userAgent) |
B |
withPersisting()
Generated response will be persisted under
java.io.tmpdir. |
B |
writeTimeout(Duration writeTimeout) |
public String baseUrl
public String organizationId
public String apiVersion
public String openAiApiKey
public String azureApiKey
public Duration callTimeout
public Duration connectTimeout
public Duration readTimeout
public Duration writeTimeout
public Proxy proxy
public String userAgent
public boolean logRequests
public boolean logResponses
public LogLevel logLevel
public boolean logStreamingResponses
public Path persistTo
public abstract T build()
public B baseUrl(String baseUrl)
baseUrl - Base URL of OpenAI API.
For OpenAI (default): "https://api.openai.com/v1/"
For Azure OpenAI: "https://{resource-name}.openai.azure.com/openai/deployments/{deployment-id}/"public B organizationId(String organizationId)
organizationId - The organizationId for OpenAI: https://platform.openai.com/docs/api-reference/organization-optionalpublic B apiVersion(String apiVersion)
apiVersion - Version of the API in the YYYY-MM-DD format. Applicable only for Azure OpenAI.public B openAiApiKey(String openAiApiKey)
openAiApiKey - OpenAI API key.
Will be injected in HTTP headers like this: "Authorization: Bearer ${openAiApiKey}"public B azureApiKey(String azureApiKey)
azureApiKey - Azure API key.
Will be injected in HTTP headers like this: "api-key: ${azureApiKey}"public B proxy(Proxy.Type type, String ip, int port)
public B logRequests()
public B logResponses()
public B logStreamingResponses()
public B withPersisting()
java.io.tmpdir. Used with images generation for the moment only.
The URL within dev.ai4j.openai4j.image.GenerateImagesResponse will contain the URL to local images then.public B persistTo(Path persistTo)
dev.ai4j.openai4j.image.GenerateImagesResponse will contain the URL to local images then.persistTo - pathCopyright © 2024. All rights reserved.