public class OpenAIWebClient extends java.lang.Object implements IAIWebClient, java.io.Closeable
Build-in lightweight OpenAI web client
| Constructor and Description |
|---|
OpenAIWebClient(java.lang.String model,
java.lang.String apiKey,
java.lang.String organizationId)
Creates instance of OpenAI Web client.
|
OpenAIWebClient(java.lang.String model,
java.lang.String apiKey,
java.lang.String organizationId,
java.net.HttpURLConnection httpClient)
Creates instance of OpenAI Web client.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
callChat(java.lang.String instruction)
Sends a chat instruction to the AI model using an externally managed
|
void |
close()
Releases resources used by this instance.
|
IAIConversation |
createConversation()
Creates a conversation instance.
|
public OpenAIWebClient(java.lang.String model,
java.lang.String apiKey,
java.lang.String organizationId)
Creates instance of OpenAI Web client.
model - OpenAI language model. Possible values:
- gpt-4o
- gpt-4o-mini
- o1
- o1-mini
- o3
- o3-miniapiKey - OpenAI API keyorganizationId - Organization ID (optional)com.aspose.ms.System.ArgumentException - API key value can't be null or emptycom.aspose.ms.System.ArgumentException - Text model value can't be null or emptypublic OpenAIWebClient(java.lang.String model,
java.lang.String apiKey,
java.lang.String organizationId,
java.net.HttpURLConnection httpClient)
Creates instance of OpenAI Web client.
model - OpenAI language model. Possible values:
- gpt-4o
- gpt-4o-mini
- o1
- o1-mini
- o3
- o3-miniapiKey - OpenAI API keyorganizationId - Organization ID (optional)httpClient - An externally managed `HttpURLConnection` instance.com.aspose.ms.System.ArgumentException - API key value can't be null or emptycom.aspose.ms.System.ArgumentException - Text model value can't be null or emptypublic java.lang.String callChat(java.lang.String instruction)
callChat in interface IAIWebClientinstruction - The instruction or message to be processed by the AI modelcom.aspose.ms.System.ArgumentException - Open AI chat instruction can't be null or empty.com.aspose.ms.System.OperationCanceledException - If the current thread was interrupted while waiting.public final IAIConversation createConversation()
Creates a conversation instance. Unlike regular AI calls, conversations retain the entire context.
createConversation in interface IAIWebClientIAIConversation instance.public final void close()
Releases resources used by this instance.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableCopyright © 2004-2025 Aspose Pty Ltd. All Rights Reserved.