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 060c8f305da..7222d6b9fec 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 @@ -353,7 +353,11 @@ public Flux internalStream(Prompt prompt, ChatResponse previousCha || chatCompletions.getUsage() != null) .map(chatCompletions -> { if (!chatCompletions.getChoices().isEmpty()) { - final var toolCalls = chatCompletions.getChoices().get(0).getDelta().getToolCalls(); + ChatChoice chatChoice = chatCompletions.getChoices().get(0); + List toolCalls = null; + if (chatChoice.getDelta() != null) { + toolCalls = chatChoice.getDelta().getToolCalls(); + } isFunctionCall.set(toolCalls != null && !toolCalls.isEmpty()); } return chatCompletions;