主题
文生图
代码片段
java
@Autowired
OpenAiImageModel openaiImageModel;
@GetMapping
public String text2Img(@RequestParam(value = "msg",
defaultValue = "为一个介绍AI技能的网站diyai.cn做张logo") String msg){
ImageResponse response = openaiImageModel.call(
new ImagePrompt(msg,
OpenAiImageOptions.builder()
.withModel(OpenAiImageApi.ImageModel.DALL_E_3.getValue())
// .withQuality("hd") // 质量
.withN(1) // The number of images to generate. Must be between 1 and 10. For dall-e-3, only n=1 is supported.
.withHeight(1024) // The height of the generated images. Must be one of 256, 512, or 1024 for dall-e-2.
.withWidth(1024) // The width of the generated images. Must be one of 256, 512, or 1024 for dall-e-2.
.build()));
return response.getResult().getOutput().getUrl();
}