{"record":{"id":"352f486e6d1a3e92","repo":"spring-projects/spring-ai","slug":"streaming-is-not-supported","errorCode":null,"errorMessage":"streaming is not supported","messagePattern":"streaming is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spring-ai-model/src/main/java/org/springframework/ai/chat/model/ChatModel.java","lineNumber":65,"sourceCode":"\t/**\n\t * Gets the chat options for this model.\n\t * @return the chat options\n\t * @since 2.0.0\n\t */\n\tdefault ChatOptions getOptions() {\n\t\treturn ChatOptions.builder().build();\n\t}\n\n\t/**\n\t * @deprecated use {@link #getOptions()} instead.\n\t */\n\t@Deprecated(forRemoval = true)\n\tdefault ChatOptions getDefaultOptions() {\n\t\treturn getOptions();\n\t}\n\n\tdefault Flux<ChatResponse> stream(Prompt prompt) {\n\t\tthrow new UnsupportedOperationException(\"streaming is not supported\");\n\t}\n\n}\n","sourceCodeStart":47,"sourceCodeEnd":69,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/spring-ai-model/src/main/java/org/springframework/ai/chat/model/ChatModel.java#L47-L69","documentation":"ChatModel.stream(Prompt) is a default interface method that throws UnsupportedOperationException to signal the model implementation does not support streaming responses. It exists so single-shot models can implement only call() without being forced to provide a streaming API. Calling stream() on such an implementation always fails with this message.","triggerScenarios":"Calling ChatClient (flux stream paths) or directly calling stream(prompt) on a ChatModel whose concrete class does not override stream(), e.g. in tests like whenSimplePromptThenFluxChatClientResponse.","commonSituations":"Developers switch a ChatClient from call() to .stream()/Flux output while the configured model adapter only implements the blocking call() method; occurs after swapping model providers or using custom model wrappers.","solutions":["Implement stream(Prompt) in your ChatModel, e.g. wrapping the blocking call() result: Flux.just(new ChatResponse(List.of(new Generation(...)))) or map the full response to a Flux.","Use the blocking call(Prompt) API instead of streaming if streaming is not needed.","Choose a model/adapters build that supports streaming for the target provider."],"exampleFix":"// before\nFlux<ChatResponse> flux = chatModel.stream(new Prompt(\"hi\"));\n// after\nChatResponse response = chatModel.call(new Prompt(\"hi\"));","handlingStrategy":"type-guard","validationCode":"if (chatModel.getClass().getMethod(\"stream\", Prompt.class).getDeclaringClass() == ChatModel.class) { throw new IllegalStateException(\"model does not support streaming\"); }","typeGuard":"boolean supportsStreaming(ChatModel m) { try { return m.getClass().getMethod(\"stream\", Prompt.class).getDeclaringClass() != ChatModel.class; } catch (NoSuchMethodException e) { return false; } }","tryCatchPattern":"try { return chatModel.stream(prompt); } catch (UnsupportedOperationException e) { return Flux.just(chatModel.call(prompt)); }","preventionTips":["Check whether your model adapter implements stream() before using ChatClient streaming APIs","Write an integration test that calls stream() on every configured model","Prefer blocking call() when streaming is not required"],"tags":["streaming","unsupported-operation","chat-model"],"backgroundTag":"unsupported-operation","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}