I always get his error “‘image’ is a required property” even tho I’m providing the image in the request. Here is the config of the feign:
@Configuration
@Slf4j
public class OpenAiClientConfig {
@Value("${spring.ai.openai.image.base-url}")
String openAiBaseUrl;
@Autowired
private ObjectFactory<HttpMessageConverters> converters;
@Bean
@Primary
@Scope("prototype")
public Encoder encoder() {
return new SpringFormEncoder(new SpringEncoder(converters));
}
@Bean
public RequestInterceptor requestInterceptor() {
return requestTemplate -> {
String requestUrl = openAiBaseUrl + "/v1/images/edits";
requestTemplate.target(requestUrl);
log.info("Request intercepted: {} with method: {}", requestTemplate.url(), requestTemplate.method());
};
}
}
here is the client:
@FeignClient(name = "dalleeditor", configuration = OpenAiClientConfig.class)
public interface OpenAiApiClient {
@PostMapping()
ImageResponseBody getEditedImage(@RequestHeader("Authorization") String bearerToken,
@RequestHeader("Content-Type") String contentType,
@RequestParam(name = "image") final MultipartFile image,
@RequestParam(name = "prompt") final String prompt,
@RequestParam(name = "model", required = false) final String model,
@RequestParam(name = "n", required = false) final Integer n,
@RequestParam(name = "response_format", required = false) final String responseFormat,
@RequestParam(name = "size", required = false) final String size,
@RequestParam(name = "user", required = false) String user
);
}
and here is where i call it:
String authorization = "bearer " + openAiKey;
String contentType = "multipart/form-data; boundary=${boundary}";
log.info("sending request to openai");
ImageResponseBody response = openAiApiClient.getEditedImage(
authorization, contentType, imageRequestBody.getImage(), imageRequestBody.getPrompt(),
imageRequestBody.getModel(),
imageRequestBody.getN(), imageRequestBody.getResponseFormat(), imageRequestBody.getSize(), null);
Please help because I m giving up here.