OpenAI br encoding issue with Spring AI
If you encountered JSON error when using Spring AI to interact with OpenAI, remove br from Accept-Encoding header.
This can be done by configuring RestClient and WebClient used by OpenAiApi, see the code below. Accept-Encoding header is set to gzip, deflate.
OpenAiApi.builder()
.apiKey("<api-key>")
.restClientBuilder(RestClient.builder().defaultHeader(HttpHeaders.ACCEPT_ENCODING, "gzip, deflate"))
.webClientBuilder(WebClient.builder().defaultHeader(HttpHeaders.ACCEPT_ENCODING, "gzip, deflate"))
.build()