OpenAICompatibleWebClient

OpenAICompatibleWebClient class

A built-in IAIWebClient implementation that connects to an OpenAI-compatible LLM provider at a specified base URL.

OpenAICompatibleWebClient

NameDescription
OpenAICompatibleWebClient(String, String, String)Creates an instance of the OpenAI-compatible web client.

Parameters:

NameTypeDescription
modelStringModel name supported by the LLM provider.
apiKeyStringAPI key (token).
baseUrlStringBase URL of the OpenAI-compatible LLM. using (OpenAICompatibleWebClient aiClient = new OpenAICompatibleWebClient(“model-name”, apiKey, “https://api.llm-provider.com/v1")) { SlidesAIAgent aiAgent = new SlidesAIAgent(aiClient); using (Presentation presentation = new Presentation(“Presentation.pptx”)) { await aiAgent.TranslateAsync(presentation, “spanish”); presentation.Save(“translated.pptx”, SaveFormat.Pptx); } }

Returns: OpenAICompatibleWebClient

Error

ErrorCondition
ArgumentExceptionBase URL value can’t be null or empty.

OpenAICompatibleWebClient

NameDescription
OpenAICompatibleWebClient(String, String, String, HttpURLConnection)Creates an instance of the OpenAI-compatible web client that uses an externally managed HttpClient. The provided HttpClient is not disposed by this instance and remains owned by the caller.

Parameters:

NameTypeDescription
modelStringModel name supported by the LLM provider.
apiKeyStringAPI key (token).
baseUrlStringBase URL of the OpenAI-compatible LLM.
httpClientHttpURLConnectionAn externally managed {@code HttpClient} instance. using (HttpClient httpClient = new HttpClient()) { OpenAICompatibleWebClient aiClient = new OpenAICompatibleWebClient(“model-name”, apiKey, “https://api.llm-provider.com/v1", httpClient); SlidesAIAgent aiAgent = new SlidesAIAgent(aiClient); using (Presentation presentation = new Presentation(“Presentation.pptx”)) { await aiAgent.TranslateAsync(presentation, “spanish”); presentation.Save(“translated.pptx”, SaveFormat.Pptx); } }

Returns: OpenAICompatibleWebClient

Error

ErrorCondition
ArgumentNullExceptionHttpClient can’t be null.

callChat

NameDescription
callChat (String)

Returns: String


createConversation

NameDescription
createConversation ()Creates a conversation instance. Unlike regular AI calls, conversations retain the entire context.

Returns: OpenAIConversation


dispose

NameDescription
dispose ()Releases resources used by this instance.