in genai-function-calling/spring-ai/src/main/java/example/Main.java [53:67]
static void run(Class<?> source, String[] args, String... defaultProperties) {
// Choose between Azure OpenAI and OpenAI based on the presence of the official SDK
// environment variable AZURE_OPENAI_API_KEY. Otherwise, we'd create two beans.
String azureApiKey = System.getenv("AZURE_OPENAI_API_KEY");
String chatModel = azureApiKey != null && !azureApiKey.trim().isEmpty()
? SpringAIModels.AZURE_OPENAI
: SpringAIModels.OPENAI;
String[] properties = Arrays.copyOf(defaultProperties, defaultProperties.length + 1);
properties[defaultProperties.length] = SpringAIModelProperties.CHAT_MODEL + "=" + chatModel;
new SpringApplicationBuilder(source)
.properties(properties)
.run(args);
}