Closed ThomasVitale closed 2 weeks ago
@ThomasVitale is this still an issue in more recent versions of Spring AI?
It's still an issue
Related to #1416
Hi @ThomasVitale, I am trying to reproduce the error from the latest snapshot, I hit the org.springframework.ai.retry.NonTransientAiException: 400. Could you check your demo sample?
@ilayaperumalg thanks for looking into this! I have update the example now.
We have a separate issue for having more customisation possibilities for the HTTP clients used in Spring AI: https://github.com/spring-projects/spring-ai/issues/512
After some further thought, this issue might actually be something to fix in Spring Boot rather in Spring AI, so I wonder if we should close this. When Spring Boot auto configures a RestClient.Builder
using one of the supported libraries, I would expect the timeouts to be the same no matter the implementation. But for OkHttpClient is different than all the other implementations. And I don't know how much we can do in Spring AI without addressing https://github.com/spring-projects/spring-ai/issues/512 first.
What do you think?
@ThomasVitale Thanks for fixing the sample. I could replicate the issue and agree that the configuration support for the timeout should come from Spring Boot. Closing this issue here and we can continue the related discussion at #512.
Bug description The
OpenAiImageModel
fails with a timeout error when Spring Boot provides an auto configuredRestClient
based onOkHttpClient
. That happens whenever the okhttp3 dependency is in the classpath, which is the case when using Micrometer Tracing with OpenTelemetry Exporter (see: https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/ClientHttpRequestFactories.java#L100).The error seems to be related to a different default timeout configuration used by okhttp3 compared to other implementations supported by
RestClient
(I tested Simple, JDK, and Apache). Having the possibility of configuring timeouts via Spring AI (see https://github.com/spring-projects/spring-ai/issues/512) could help mitigating this problem.Environment Spring AI: 1.0.0-SNAPSHOT Java: 22
Expected behavior The outcome of the operations performed via the
OpenAiImageModel
should lead to the same results independently from which low-level HTTP client is used byRestClient
under the hood, without requiring any customizations.Minimal Complete Reproducible example This demo application shows the error. Follow the instructions in the README.md file to run the application and call the
/image
endpoint.Error Stacktrace