#7007·spring-ai

Response fails mid-stream when using Azure OpenAI endpoint due to asynchronous content filter

Author: simon-meerCreated Sep 17, 2026Updated Sep 17, 2026
Labelsstatus: waiting-for-triage

Bug description When using an OpenAiChatModel (spring-ai-openai) with an Azure OpenAI endpoint that has an asynchronous content filter, the response fails mid-stream because of an invalid chunk:

Caused by: com.openai.errors.OpenAIInvalidDataException: `delta` is not set
	at com.openai.core.JsonField.getRequired$openai_java_core(Values.kt:174)
	at com.openai.models.chat.completions.ChatCompletionChunk$Choice.delta(ChatCompletionChunk.kt:617)
	at org.springframework.ai.openai.OpenAiChatModel$ChunkMerger.hasToolCall(OpenAiChatModel.java:1183)
	at org.springframework.ai.openai.OpenAiChatModel.lambda$internalStream$6(OpenAiChatModel.java:319)
	at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:836)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:887)
	at reactor.core.publisher.FluxCreate$BufferAsyncSink.next(FluxCreate.java:812)
	at reactor.core.publisher.FluxCreate$SerializedFluxSink.next(FluxCreate.java:164)
        ...

This is because Azure for some reason chooses to ignore the spec in this case and sends a chunk with no delta.

Mildly related: https://github.com/spring-projects/spring-ai/issues/2691

Related change in the Python SDK: https://github.com/openai/openai-python/pull/2255

Example chunk: https://learn.microsoft.com/en-us/azure/foundry/openai/concepts/content-streaming?view=foundry-classic#annotation-message

I honestly was unsure whether to create the issue here or with the official Java SDK, but I opted here because the Java SDK has APIs to determine the validity of a chunk, and thus seems to explicitly tolerate invalid objects. Ideally, Azure would fix it, of course.

Environment Spring AI 2.0.1

Steps to reproduce Use the ChatModel with Azure OpenAI and an asynchronouse filter and the streaming API, and prompt it for a response that is long enough for the error to surface. (A few paragraphs in)

Expected behavior Stream should not fail.

Source: spring-projects/spring-ai