diff --git a/models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiChatModel.java b/models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiChatModel.java index 9ac782f6c..f1d2a06c0 100644 --- a/models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiChatModel.java +++ b/models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiChatModel.java @@ -143,8 +143,7 @@ public class AzureOpenAiChatModel ChatCompletions chatCompletions = this.callWithFunctionSupport(options); logger.trace("Azure ChatCompletions: {}", chatCompletions); - List generations = chatCompletions.getChoices() - .stream() + List generations = nullSafeList(chatCompletions.getChoices()).stream() .map(choice -> new Generation(choice.getMessage().getContent()) .withGenerationMetadata(generateChoiceMetadata(choice))) .toList();