diff --git a/yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/TongYiImagesModelTests.java b/yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/TongYiImagesModelTests.java new file mode 100644 index 000000000..c927a0d57 --- /dev/null +++ b/yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/image/TongYiImagesModelTests.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.framework.ai.image; + +import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesis; +import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam; +import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisResult; +import com.alibaba.dashscope.exception.NoApiKeyException; +import com.alibaba.dashscope.utils.Constants; +import com.alibaba.fastjson.JSON; +import org.junit.jupiter.api.Test; + +import java.util.Map; + +/** + * 通义万象 - 测试 + */ +public class TongYiImagesModelTests { + + @Test + public void imageCallTest() throws NoApiKeyException { + // 设置 api key + Constants.apiKey="sk-Zsd81gZYg7"; + ImageSynthesisParam param = + ImageSynthesisParam.builder() + .model(ImageSynthesis.Models.WANX_V1) + .n(4) + .size("1024*1024") + .prompt("雄鹰自由自在的在蓝天白云下飞翔") + .build(); + // 创建 ImageSynthesis + ImageSynthesis is = new ImageSynthesis(); + // 调用 call 生成 image + ImageSynthesisResult call = is.call(param); + System.err.println(JSON.toJSON(call)); + for (Map result : call.getOutput().getResults()) { + System.err.println("地址: " + result.get("url")); + } + } +}