OpenAIWebClient

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.slides.IAIWebClient, java.io.Closeable

public class OpenAIWebClient implements IAIWebClient, Closeable

Build-in lightweight OpenAI web client

Constructors

ConstructorDescription
OpenAIWebClient(String model, String apiKey, String organizationId)Creates instance of OpenAI Web client.
OpenAIWebClient(String model, String apiKey, String organizationId, HttpURLConnection httpClient)Creates instance of OpenAI Web client.

Methods

MethodDescription
callChat(String instruction)Sends a chat instruction to the AI model using an externally managed instance and returns response message to the given instruction.
createConversation()Creates a conversation instance.
close()Releases resources used by this instance.

OpenAIWebClient(String model, String apiKey, String organizationId)

public OpenAIWebClient(String model, String apiKey, String organizationId)

Creates instance of OpenAI Web client.

Parameters:

ParameterTypeDescription
modeljava.lang.StringOpenAI language model. Possible values: - gpt-4o - gpt-4o-mini - o1 - o1-mini - o3 - o3-mini
apiKeyjava.lang.StringOpenAI API key
organizationIdjava.lang.StringOrganization ID (optional)

OpenAIWebClient(String model, String apiKey, String organizationId, HttpURLConnection httpClient)

public OpenAIWebClient(String model, String apiKey, String organizationId, HttpURLConnection httpClient)

Creates instance of OpenAI Web client.

Parameters:

ParameterTypeDescription
modeljava.lang.StringOpenAI language model. Possible values: - gpt-4o - gpt-4o-mini - o1 - o1-mini - o3 - o3-mini
apiKeyjava.lang.StringOpenAI API key
organizationIdjava.lang.StringOrganization ID (optional)
httpClientjava.net.HttpURLConnectionAn externally managed HttpURLConnection instance.

callChat(String instruction)

public String callChat(String instruction)

Sends a chat instruction to the AI model using an externally managed instance and returns response message to the given instruction.

Parameters:

ParameterTypeDescription
instructionjava.lang.StringThe instruction or message to be processed by the AI model

Returns: java.lang.String - The message generated by the AI model in response to the given instruction.

createConversation()

public final IAIConversation createConversation()

Creates a conversation instance. Unlike regular AI calls, conversations retain the entire context.

Returns: IAIConversation - An IAIConversation instance.

close()

public final void close()

Releases resources used by this instance.