ITADN

[Question] 使用ImageModel使用最新的文生图模型报错

#4665Openitalycalibur2019 创建于 2026-05-29
kind/bugarea/core
### Question 我的配置: ```yml server: port: 8174 servlet: encoding: enabled: true force: true charset: UTF-8 spring: application: name: spring-ai-demo-07 ai: dashscope: api-key: ${DASH_SCOPE_API_KEY} image: options: model: wan2.7-image-pro ``` 我的代码: ```java import jakarta.annotation.Resource; import org.springframework.ai.image.ImageModel; import org.springframework.ai.image.ImagePrompt; import org.springframework.ai.image.ImageResponse; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/demo/07") public class ImageController { @Resource private ImageModel imageModel; @RequestMapping("/image/generate") public String doImageGenerate(@RequestParam(name = "question", defaultValue = "一只在草地上玩耍的可爱小猫") String question) { ImagePrompt imagePrompt = new ImagePrompt(question); ImageResponse response = imageModel.call(imagePrompt); String imageUrl = response.getResult().getOutput().getUrl(); return "<img src='" + imageUrl + "' alt='生成的图片'>"; } } ``` 调用报错: org.springframework.ai.retry.NonTransientAiException: HTTP 400 - {"request_id":"fd9f2b2c-6b18-9793-8fb7-b9b9318f57a4","code":"InvalidParameter","message":"url error, please check url! For details, see: https://help.aliyun.com/zh/model-studio/error-code#error-url"} 把模型名去掉后能正常调用,但是就只能使用wanx-v1了,我的项目使用的是spring boot 版本是3.5.14,jdk版本17
2 条评论