8
diff --git a/samples/DecisionModelUsage.java b/samples/DecisionModelUsage.java
index 2a289cd..31c14cc 100644
--- a/samples/DecisionModelUsage.java
+++ b/samples/DecisionModelUsage.java
@@ -40,6 +40,9 @@ public static void main(String[] args) throws Exception {
.questions(questions)
.build();
+ // A workspace id is required: pass it here (new DecisionModel("your-workspace-id"))
+ // or set the DASHSCOPE_WORKSPACE environment variable before running.
+ // For a fully custom endpoint, use DecisionModel.withBaseUrl(baseUrl) instead.
DecisionModel decisionModel = new DecisionModel();
DecisionModelResult result = decisionModel.call(param);
System.out.println(JsonUtils.toJson(result));
diff --git a/src/main/java/com/alibaba/dashscope/Version.java b/src/main/java/com/alibaba/dashscope/Version.java
index c94315a..ecb9a44 100644
--- a/src/main/java/com/alibaba/dashscope/Version.java
+++ b/src/main/java/com/alibaba/dashscope/Version.java
@@ -3,5 +3,5 @@
package com.alibaba.dashscope;
public final class Version {
- public static final String version = "2.23.3";
+ public static final String version = "2.23.4";
}
diff --git a/src/main/java/com/alibaba/dashscope/aigc/imagesynthesis/ImageSynthesis.java b/src/main/java/com/alibaba/dashscope/aigc/imagesynthesis/ImageSynthesis.java
index 68256bb..ecdd908 100644
--- a/src/main/java/com/alibaba/dashscope/aigc/imagesynthesis/ImageSynthesis.java
+++ b/src/main/java/com/alibaba/dashscope/aigc/imagesynthesis/ImageSynthesis.java
@@ -33,6 +33,30 @@ public static class Models {
public static final String WANX_2_1_IMAGEEDIT = "wanx2.1-imageedit";
}
+ /**
+ * Model prefixes that are only served on the multimodal-generation endpoint. The legacy
+ * text2image endpoint used by this class rejects them with a 400 "url error", so they must be
+ * called through {@link com.alibaba.dashscope.aigc.imagegeneration.ImageGeneration} instead.
+ */
+ private static final String[] MULTIMODAL_MODEL_PREFIXES = {"wan2.6-t2i", "wan2.6-image"};
+
+ private static void checkMultimodalModel(String model) {
+ if (model == null) {
+ return;
+ }
+ for (String prefix : MULTIMODAL_MODEL_PREFIXES) {
+ if (model.startsWith(prefix)) {
+ throw new IllegalArgumentException(
+ String.format(
+ "Model '%s' is only served on the multimodal-generation endpoint and is not "
+ + "supported by ImageSynthesis. Use "
+ + "com.alibaba.dashscope.aigc.imagegeneration.ImageGeneration "
+ + "(ImageGeneration.call/asyncCall/streamCall) for this model.",
+ model));
+ }
+ }
+ }
+
/** Image edit function */
public static class ImageEditFunction {
public static final String STYLIZATION_ALL = "stylization_all";
@@ -112,6 +136,7 @@ public ImageSynthesis(String task, String baseUrl) {
public ImageSynthesisResult asyncCall(ImageSynthesisParam param)
throws ApiException, NoApiKeyException {
+ checkMultimodalModel(param.getModel());
// add local file support
try {
param.checkAndUpload();
@@ -126,11 +151,15 @@ public ImageSynthesisResult asyncCall(ImageSynthesisParam param)
}
/**
- * Note: This method currently now only supports wan2.2-t2i-flash and wan2.2-t2i-plus. Using other
- * models will result in an error,More raw image models may be added for use later
+ * Synchronously generate images on the legacy text2image endpoint.
+ *
+ * Multimodal-generation models (wan2.6-t2i / wan2.6-image) are not served here; use {@link
+ * com.alibaba.dashscope.aigc.imagegeneration.ImageGeneration#call} for those. Calling this method
+ * with such a model throws {@link IllegalArgumentException}.
*/
public ImageSynthesisResult syncCall(ImageSynthesisParam param)
throws ApiException, NoApiKeyException {
+ checkMultimodalModel(param.getModel());
// add local file support
try {
param.checkAndUpload();
@@ -152,6 +181,7 @@ public ImageSynthesisResult syncCall(ImageSynthesisParam param)
*/
public ImageSynthesisResult call(ImageSynthesisParam param)
throws ApiException, NoApiKeyException {
+ checkMultimodalModel(param.getModel());
// add local file support
try {
param.checkAndUpload();
diff --git a/src/test/java/com/alibaba/dashscope/TestImageSynthesis.java b/src/test/java/com/alibaba/dashscope/TestImageSynthesis.java
index 7741cea..a6d3bfe 100644
--- a/src/test/java/com/alibaba/dashscope/TestImageSynthesis.java
+++ b/src/test/java/com/alibaba/dashscope/TestImageSynthesis.java
@@ -201,4 +201,20 @@ public void testImageSynthesisWithPromptExtendAndWatermark()
assertEquals(true, requestBody.contains("\"prompt_extend\":true"));
assertEquals(true, requestBody.contains("\"watermark\":false"));
}
+
+ @Test
+ public void testSyncCallRejectsMultimodalModel() {
+ int port = server.getPort();
+ Constants.baseHttpApiUrl = String.format("http://127.0.0.1:%s", port);
+ ImageSynthesis is = new ImageSynthesis();
+ ImageSynthesisParam param =
+ ImageSynthesisParam.builder().model("wan2.6-t2i").prompt("a cat").build();
+ IllegalArgumentException ex =
+ org.junit.jupiter.api.Assertions.assertThrows(
+ IllegalArgumentException.class, () -> is.syncCall(param));
+ org.junit.jupiter.api.Assertions.assertTrue(
+ ex.getMessage().contains("ImageGeneration"), ex.getMessage());
+ // no request should have reached the legacy endpoint
+ assertEquals(0, server.getRequestCount());
+ }
}