Class OpenAiSetup

java.lang.Object
org.springframework.ai.openai.setup.OpenAiSetup

public final class OpenAiSetup 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
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    detectModelProvider(boolean isMicrosoftFoundry, boolean isGitHubModels, @Nullable String baseUrl, @Nullable String azureDeploymentName, @Nullable com.openai.azure.AzureOpenAIServiceVersion azureOpenAIServiceVersion)
     
    static com.openai.client.OpenAIClientAsync
    setupAsyncClient(@Nullable String baseUrl, @Nullable String apiKey, @Nullable com.openai.credential.Credential credential, @Nullable String azureDeploymentName, @Nullable com.openai.azure.AzureOpenAIServiceVersion azureOpenAiServiceVersion, @Nullable String organizationId, boolean isAzure, boolean isGitHubModels, @Nullable String modelName, Duration timeout, int maxRetries, @Nullable Proxy proxy, @Nullable 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.
    static com.openai.client.OpenAIClient
    setupSyncClient(@Nullable String baseUrl, @Nullable String apiKey, @Nullable com.openai.credential.Credential credential, @Nullable String azureDeploymentName, @Nullable com.openai.azure.AzureOpenAIServiceVersion azureOpenAiServiceVersion, @Nullable String organizationId, boolean isAzure, boolean isGitHubModels, @Nullable String modelName, Duration timeout, int maxRetries, @Nullable Proxy proxy, @Nullable Map<String,String> customHeaders)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • setupSyncClient

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

      public static com.openai.client.OpenAIClientAsync setupAsyncClient(@Nullable String baseUrl, @Nullable String apiKey, @Nullable com.openai.credential.Credential credential, @Nullable String azureDeploymentName, @Nullable com.openai.azure.AzureOpenAIServiceVersion azureOpenAiServiceVersion, @Nullable String organizationId, boolean isAzure, boolean isGitHubModels, @Nullable String modelName, Duration timeout, int maxRetries, @Nullable Proxy proxy, @Nullable 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 OpenAiSetup.ModelProvider detectModelProvider(boolean isMicrosoftFoundry, boolean isGitHubModels, @Nullable String baseUrl, @Nullable String azureDeploymentName, @Nullable com.openai.azure.AzureOpenAIServiceVersion azureOpenAIServiceVersion)