Chat Client APIs and Streaming
Chat Client APIs and Streaming call(). content() (Most Common) Returns only the generated text. @GetMapping ( "/content" ) public String content ( @RequestParam String question) { return chatClient.prompt() .user(question) .call() .content() ; } Flow: User │ ▼ ChatClient │ ▼ LLM │ ▼ String Use when you only need the answer. call().chatResponse() Returns the complete response object, not just the text. @GetMapping ( "/response" ) public ChatResponse response ( @RequestParam String question) { return chatClient.prompt() .user(question) .call() .chatResponse() ; } Chat Response contains much more than the content. http://localhost:8080/api/response?question=Explain Kafka output are in json format . Streaming Instead of waiting for the complete answer, stream it token by token. @GetMapping (value= "/stream" , produces = MediaType. TEXT_EVENT_STREAM_VALUE ...