{"record":{"id":"4e27cbbe9a70523d","repo":"spring-projects/spring-ai","slug":"streaming-chat-completion-is-not-supported-for-thi","errorCode":null,"errorMessage":"Streaming chat completion is not supported for this model: ","messagePattern":"Streaming chat completion is not supported for this model: ","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/api/AbstractBedrockApi.java","lineNumber":216,"sourceCode":"\n\t/**\n\t * Chat completion invocation.\n\t *\n\t * @param request The chat completion request.\n\t * @return The chat completion response.\n\t */\n\tprotected O chatCompletion(I request) {\n\t\tthrow new UnsupportedOperationException(\"Chat completion is not supported for this model: \" + this.modelId);\n\t}\n\n\t/**\n\t * Chat completion invocation with streaming response.\n\t *\n\t * @param request The chat completion request.\n\t * @return The chat completion response stream.\n\t */\n\tprotected Flux<SO> chatCompletionStream(I request) {\n\t\tthrow new UnsupportedOperationException(\n\t\t\t\t\"Streaming chat completion is not supported for this model: \" + this.modelId);\n\t}\n\n\t/**\n\t * Internal method to invoke the model and return the response.\n\t * https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html\n\t * https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html\n\t * https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/bedrockruntime/BedrockRuntimeClient.html#invokeModel\n\t *\n\t * @param request Model invocation request.\n\t * @param clazz The response class type\n\t * @return The model invocation response.\n\t *\n\t */\n\tprotected O internalInvocation(I request, Class<O> clazz) {\n\n\t\tSdkBytes body;\n\t\ttry {","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/models/spring-ai-bedrock/src/main/java/org/springframework/ai/bedrock/api/AbstractBedrockApi.java#L198-L234","documentation":"AbstractBedrockApi's default chatCompletionStream(I) throws UnsupportedOperationException. Streaming chat completion is an optional capability: subclasses whose Bedrock model does not support streaming responses (or does not implement the override) reject streaming calls, so requesting a Flux-based streaming invocation on such a client fails immediately.","triggerScenarios":"Calling chatCompletionStream(request) — directly or via ChatModel.stream() — on a Bedrock API subclass that did not override the streaming method, e.g. embedding-only or non-streaming chat models.","commonSituations":"Using .stream() on a Bedrock chat model whose backing model/API does not implement streaming; generic code that always streams regardless of model capabilities.","solutions":["Use a Bedrock model/client that overrides chatCompletionStream (e.g. Anthropic, Cohere streaming implementations)","Fall back to the blocking chatCompletion() call when streaming is unavailable","Check the concrete API class documentation for streaming support before calling stream()"],"exampleFix":"// before\nFlux<ChatResponse> flux = model.stream(new Prompt(\"hi\")); // throws for non-streaming model\n// after\nChatResponse response = model.call(new Prompt(\"hi\")); // blocking fallback","handlingStrategy":"fallback","validationCode":"boolean streamingKnown = Set.of(\"anthropic\",\"cohere\",\"llama\",\"titan\").stream().anyMatch(modelId::contains);","typeGuard":null,"tryCatchPattern":"try { return model.stream(prompt); } catch (UnsupportedOperationException e) { return Flux.just(model.call(prompt)); }","preventionTips":["Confirm the model/client supports streaming before calling stream()","Implement a blocking-call fallback path in streaming abstractions","Check AbstractBedrockApi subclass for chatCompletionStream overrides"],"tags":["bedrock","streaming","unsupported-operation"],"backgroundTag":"method-not-implemented","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"}