OpenAIWebClient
Contents
[
Hide
]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
| Constructor | Description |
|---|---|
| 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
| Method | Description |
|---|---|
| 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:
| Parameter | Type | Description |
|---|---|---|
| model | java.lang.String | OpenAI language model. Possible values: - gpt-4o - gpt-4o-mini - o1 - o1-mini - o3 - o3-mini |
| apiKey | java.lang.String | OpenAI API key |
| organizationId | java.lang.String | Organization 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:
| Parameter | Type | Description |
|---|---|---|
| model | java.lang.String | OpenAI language model. Possible values: - gpt-4o - gpt-4o-mini - o1 - o1-mini - o3 - o3-mini |
| apiKey | java.lang.String | OpenAI API key |
| organizationId | java.lang.String | Organization ID (optional) |
| httpClient | java.net.HttpURLConnection | An 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:
| Parameter | Type | Description |
|---|---|---|
| instruction | java.lang.String | The 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.