List<ActorsFilms> actorsFilms = ChatClient.create(chatModel).prompt()
.user("Generate the filmography of 5 movies for Tom Hanks and Bill Murray.")
.call()
.entity(new ParameterizedTypeReference<List<ActorsFilms>>() {});
this example will throw ResourceAccessException
2025-09-30 09:09:11 [http-nio-9000-exec-10] WARN o.s.a.r.a.SpringAiRetryAutoConfiguration - Retry error. Retry count: 1, Exception: I/O error on POST request for "https://api.deepseek.com/chat/completions": Connect timed out
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://api.deepseek.com/chat/completions": Connect timed out
at org.springframework.web.client.DefaultRestClient$DefaultRequestBodyUriSpec.createResourceAccessException(DefaultRestClient.java:697)
at org.springframework.web.client.DefaultRestClient$DefaultRequestBodyUriSpec.exchangeInternal(DefaultRestClient.java:582)
at org.springframework.web.client.DefaultRestClient$DefaultRequestBodyUriSpec.exchange(DefaultRestClient.java:533)
at org.springframework.web.client.RestClient$RequestHeadersSpec.exchange(RestClient.java:680)
when I analyze the log, I find two reason below :
- [ ] .entity
will call https://api.deepseek.com/chat/completions
.But it's not the right api to call
- [ ] when you want to ask deepseek answer in json format. You mast add parameter response_format: { "type": "json_object" }
in the request. But I can't find the definition of this most important field in DeepSeekChatOptions. I don't know whether SpringAI add the parameter to the request.
Due to these two reason, the example of ActorsFilms can't work. How can I fix it ?
Comment From: pengjian5720
I found another way to call :
private final DeepSeekChatProperties deepSeekChatProperties;
public Flux<String> handleBillStructured(String param, Long userId, Long sessionId) {
List<Message> messages = buildStructuredMessages(param, userId);
return client.prompt(new Prompt(messages))
.tools(billService)
.advisors(a -> a.param(ChatMemory.CONVERSATION_ID, sessionId))
.options(deepSeekChatProperties.getOptions())
.stream()
.content();
}