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)

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.
close()

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 (gpt-4o, gpt-4o-mini, etc.)
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)

Parameters:

ParameterTypeDescription
modeljava.lang.String
apiKeyjava.lang.String
organizationIdjava.lang.String
httpClientjava.net.HttpURLConnection

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.

close()

public void close()