Class OpenAiSdkSetup

java.lang.Object
org.springframework.ai.openaisdk.setup.OpenAiSdkSetup

public final class OpenAiSdkSetup extends Object
Helps configure the OpenAI Java SDK, depending on the platform used. This code is inspired by LangChain4j's `dev.langchain4j.model.openaiofficial.InternalOpenAiOfficialHelper` class, which is coded by the same author (Julien Dubois, from Microsoft).
Author:
Julien Dubois
  • Method Details

    • setupSyncClient

      public static com.openai.client.OpenAIClient setupSyncClient(String baseUrl, String apiKey, com.openai.credential.Credential credential, String azureDeploymentName, com.openai.azure.AzureOpenAIServiceVersion azureOpenAiServiceVersion, String organizationId, boolean isAzure, boolean isGitHubModels, String modelName, Duration timeout, Integer maxRetries, Proxy proxy, Map<String,String> customHeaders)
    • setupAsyncClient

      public static com.openai.client.OpenAIClientAsync setupAsyncClient(String baseUrl, String apiKey, com.openai.credential.Credential credential, String azureDeploymentName, com.openai.azure.AzureOpenAIServiceVersion azureOpenAiServiceVersion, String organizationId, boolean isAzure, boolean isGitHubModels, String modelName, Duration timeout, Integer maxRetries, Proxy proxy, Map<String,String> customHeaders)
      The asynchronous client setup is the same as the synchronous one in the OpenAI Java SDK, but uses a different client implementation.
    • detectModelProvider

      public static OpenAiSdkSetup.ModelProvider detectModelProvider(boolean isAzure, boolean isGitHubModels, String baseUrl, String azureDeploymentName, com.openai.azure.AzureOpenAIServiceVersion azureOpenAIServiceVersion)