Class OpenAiSetup
java.lang.Object
org.springframework.ai.openai.setup.OpenAiSetup
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenAiSetup.ModelProviderdetectModelProvider(boolean isMicrosoftFoundry, boolean isGitHubModels, @Nullable String baseUrl, @Nullable String azureDeploymentName, @Nullable com.openai.azure.AzureOpenAIServiceVersion azureOpenAIServiceVersion) static com.openai.client.OpenAIClientAsyncsetupAsyncClient(@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.OpenAIClientsetupSyncClient(@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)
-
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)
-