AS AgentScopeAPI 手册 / API Reference

DashScopeMultiModalTool

public class DashScopeMultiModalTool
源码Source io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:92–1770

DashScope Multi Modal 工具,封装可被智能体调用的能力。位于 io.agentscope.extensions.model.dashscope.tool 包。核心成员包括 dashscopeTextToImage、dashscopeImageToImage、dashscopeImageToText、dashscopeTextToAudio、dashscopeAudioToText、dashscopeTextToVideo。

DashScope multimodal tool.

Support tools:

  • dashscope_text_to_image: Generate image(s) based on the given text.

  • dashscope_image_to_image: Edit/transform an image based on a text prompt and the input image.

  • dashscope_image_to_text: Generate text based on the given images.

  • dashscope_text_to_audio: Convert the given text to audio.

  • dashscope_audio_to_text: Convert the given audio to text.

  • dashscope_text_to_video: Generate video based on the given text prompt.

  • dashscope_image_to_video: Generate a video from a single input image and an optional text prompt.

  • dashscope_first_and_last_frame_image_to_video: Generate video transitioning from a first frame to a last frame and an optional text prompt.

  • dashscope_video_to_text: Analyze video and generate a text description or answer questions based on the video content.

convert text to images, convert images to text, convert text to audio, and convert audio to text. Please refer to the dashscope documentation for more details.

构造器摘要Constructor Summary

构造器Constructor说明Description
public DashScopeMultiModalTool(String apiKey)
初始化 `DashScopeMultiModalTool` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public Mono<ToolResultBlock> dashscopeTextToImage(String prompt, String model, Integer n, String size, Boolean useBase64)
执行DashScope 文本到图像相关操作。
Generate image(s) based on the given prompt, and return image url(s) or base64 data.
public Mono<ToolResultBlock> dashscopeImageToImage(String imageUrl, String prompt, String model, String size, Boolean useBase64)
执行DashScope 图像到图像相关操作。
Edit or transform an image based on a text prompt and an input image.
public Mono<ToolResultBlock> dashscopeImageToText(List<String> imageUrls, String prompt, String model)
执行DashScope 图像到文本相关操作。
Generate text based on the given images.
public Mono<ToolResultBlock> dashscopeTextToAudio(String text, String model, String voice, String language, Integer sampleRate)
执行DashScope 文本到音频相关操作。
Convert the given text to audio.
public Mono<ToolResultBlock> dashscopeAudioToText(String audioUrl, String model, Integer sampleRate)
执行DashScope 音频到文本相关操作。
Convert the given audio to text.
public Mono<ToolResultBlock> dashscopeTextToVideo(String prompt, String model, String negativePrompt, String audioUrl, String size, Integer duration, String shotType, Boolean promptExtend, Boolean watermark, Integer seed)
执行DashScope 文本到视频相关操作。
Generate video based on the given prompt.
public Mono<ToolResultBlock> dashscopeImageToVideo(String prompt, String model, String imageUrl, String audioUrl, String negativePrompt, String template, String resolution, Integer duration, String shotType, Boolean audio, Boolean promptExtend, Boolean watermark, Integer seed)
执行DashScope 图像到视频相关操作。
Generate a video based on a single input image (first frame) and an optional text prompt.
public Mono<ToolResultBlock> dashscopeFirstAndLastFrameImageToVideo(String prompt, String model, String firstFrameUrl, String lastFrameUrl, String negativePrompt, String template, String resolution, Boolean promptExtend, Boolean watermark, Integer seed)
执行 `dashscopeFirstAndLastFrameImageToVideo` 方法。
Generate video transitioning from a first frame to a last frame and an optional text prompt.
public Mono<ToolResultBlock> dashscopeVideoToText(String videoUrl, String prompt, String model, Double fps)
执行DashScope 视频到文本相关操作。
Analyze video and generate a text description or answer questions based on the video content.

构造器详情Constructor Detail

DashScopeMultiModalTool

public DashScopeMultiModalTool(String apiKey)

初始化 DashScopeMultiModalTool 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
apiKeyStringAPI 键(类型 `String`)。The api key.
源码Source io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:117–122

方法详情Method Detail

dashscopeTextToImage

public Mono<ToolResultBlock> dashscopeTextToImage(String prompt, String model, Integer n, String size, Boolean useBase64)

执行DashScope 文本到图像相关操作。

Generate image(s) based on the given prompt, and return image url(s) or base64 data.

参数Parameters
名称Name类型Type说明Description
promptString提示词(类型 `String`)。The text prompt to generate image
modelString模型实例(类型 `String`)。The model to use, e.g., 'wanx-v1', 'qwen-image', 'wan2.2-t2i-flash', etc.
nIntegern(类型 `Integer`)。The number of images to generate
sizeString大小(类型 `String`)。Size of the image, e.g., '1024*1024', '1280*1280', '800*1200', etc.
useBase64Boolean使用基类 64(类型 `Boolean`)。Whether to use base64 data for images
返回Returns Mono<ToolResultBlock>
返回Mono。A ToolResultBlock containing the generated image url, base64 data, or error message.
源码Source io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:134–253

dashscopeImageToImage

public Mono<ToolResultBlock> dashscopeImageToImage(String imageUrl, String prompt, String model, String size, Boolean useBase64)

执行DashScope 图像到图像相关操作。

Edit or transform an image based on a text prompt and an input image.

参数Parameters
名称Name类型Type说明Description
imageUrlString图像 URL(类型 `String`)。The public URL, oss:// URL, local file path, or Base64 data URL of the input image to edit.
promptString提示词(类型 `String`)。The text prompt describing the desired edit or transformation.
modelString模型实例(类型 `String`)。The image-edit model to use, e.g., 'qwen-image-edit'.
sizeString大小(类型 `String`)。Size of the output image, e.g., '1024*1024'. Supported by the numbered generations (2.0 and later) and by the first-generation 'plus' and 'max' tiers.
useBase64Boolean使用基类 64(类型 `Boolean`)。Whether to return image as base64 data instead of URL.
返回Returns Mono<ToolResultBlock>
返回Mono。A ToolResultBlock containing the generated image url/base64 or error message.
源码Source io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:272–461

dashscopeImageToText

public Mono<ToolResultBlock> dashscopeImageToText(List<String> imageUrls, String prompt, String model)

执行DashScope 图像到文本相关操作。

Generate text based on the given images.

参数Parameters
名称Name类型Type说明Description
imageUrlsList<String>图像 Urls(类型 `List`)。The URL(s) of image(s) to be converted into text.
promptString文本提示词。The text prompt.
modelString模型实例(类型 `String`)。The model to use, e.g., 'qwen3-vl-plus', qwen-vl-plus' 'qvq-plus', etc.
返回Returns Mono<ToolResultBlock>
返回Mono。A ToolResultBlock containing the generated text or error message.
源码Source io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:588–685

dashscopeTextToAudio

public Mono<ToolResultBlock> dashscopeTextToAudio(String text, String model, String voice, String language, Integer sampleRate)

执行DashScope 文本到音频相关操作。

Convert the given text to audio.

参数Parameters
名称Name类型Type说明Description
textString文本(类型 `String`)。The text to be converted into audio.
modelString模型实例(类型 `String`)。The TTS model to use. For Qwen TTS: 'qwen3-tts-flash', 'qwen-tts'. For Sambert: 'sambert-zhinan-v1', 'sambert-zhiqi-v1', 'sambert-zhichu-v1', etc.
voiceString语音(类型 `String`)。Voice name for Qwen TTS models, e.g., 'Cherry', 'Serena'. Ignored for Sambert models.
languageStringlanguage(类型 `String`)。Language type for Qwen TTS, e.g., 'Chinese', 'English'. Ignored for Sambert models.
sampleRateIntegersample 速率(类型 `Integer`)。Sample rate of the audio (e.g., 16000, 24000, 48000).
返回Returns Mono<ToolResultBlock>
返回Mono。A ToolResultBlock containing the base64 data of audio or error message.
源码Source io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:704–760

dashscopeAudioToText

public Mono<ToolResultBlock> dashscopeAudioToText(String audioUrl, String model, Integer sampleRate)

执行DashScope 音频到文本相关操作。

Convert the given audio to text.

参数Parameters
名称Name类型Type说明Description
audioUrlString音频 URL(类型 `String`)。The file path or URL of audio to be converted into text.
modelString模型实例(类型 `String`)。The speech recognition model to use, e.g., 'paraformer-realtime-v1', 'paraformer-realtime-8k-v1', 'paraformer-realtime-v2', 'paraformer-realtime-8k-v2'.
sampleRateIntegersample 速率(类型 `Integer`)。Sample rate of the audio (e.g., 8000, 16000).
返回Returns Mono<ToolResultBlock>
返回Mono。A ToolResultBlock containing the recognition text or error message.
源码Source io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:970–1076

dashscopeTextToVideo

public Mono<ToolResultBlock> dashscopeTextToVideo(String prompt, String model, String negativePrompt, String audioUrl, String size, Integer duration, String shotType, Boolean promptExtend, Boolean watermark, Integer seed)

执行DashScope 文本到视频相关操作。

Generate video based on the given prompt.

参数Parameters
名称Name类型Type说明Description
promptString提示词(类型 `String`)。The text prompt to generate video.
modelString模型实例(类型 `String`)。The model to use, e.g., 'wan2.6-t2v', 'wan2.5-t2v-preview', etc.
negativePromptStringnegative 提示词(类型 `String`)。The negative prompt to avoid certain elements.
audioUrlString音频 URL(类型 `String`)。The URL for background audio.
sizeString大小(类型 `String`)。Size of the video, e.g., '1920*1080', '1280*720', etc.
durationInteger时长(类型 `Integer`)。Duration of the video in seconds, e.g., '5', '10', etc.
shotTypeStringshot 类型(类型 `String`)。Specify the shot type that generates the video. single: default value, output single shot video; multi: output multi-lens video.
promptExtendBoolean提示词 Extend(类型 `Boolean`)。Whether to extend the prompt automatically (default true)
watermarkBooleanwatermark(类型 `Boolean`)。Whether to include watermark (default false)
seedInteger预置(类型 `Integer`)。The seed for reproducibility
返回Returns Mono<ToolResultBlock>
返回Mono。A ToolResultBlock containing the generated video url or error message.
源码Source io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:1133–1273

dashscopeImageToVideo

public Mono<ToolResultBlock> dashscopeImageToVideo(String prompt, String model, String imageUrl, String audioUrl, String negativePrompt, String template, String resolution, Integer duration, String shotType, Boolean audio, Boolean promptExtend, Boolean watermark, Integer seed)

执行DashScope 图像到视频相关操作。

Generate a video based on a single input image (first frame) and an optional text prompt.

参数Parameters
名称Name类型Type说明Description
promptString提示词(类型 `String`)。The text prompt describing the video content and motion.
modelString模型实例(类型 `String`)。The model to use, e.g., 'wan2.6-i2v-flash', 'wan2.1-i2v-turbo'.
imageUrlString图像 URL(类型 `String`)。The URL, local file path, or Base64 data of the input image (first frame).
audioUrlString音频 URL(类型 `String`)。URL of the audio file that the model will use to generate video.
negativePromptStringnegative 提示词(类型 `String`)。The negative prompt to avoid certain elements.
templateString模板(类型 `String`)。Name of video effect template, e.g., 'squish', 'rotation', etc
resolutionStringresolution(类型 `String`)。Resolution of the video, e.g., '720P', '1080P'.
durationInteger时长(类型 `Integer`)。Duration of the video in seconds (e.g., 5, 10, 15). Default depends on model.
shotTypeStringshot 类型(类型 `String`)。Specify the shot type that generates the video. single: default value, output single shot video; multi: output multi-lens video.
audioBoolean音频(类型 `Boolean`)。Whether to generate audio video (default true).
promptExtendBoolean提示词 Extend(类型 `Boolean`)。Whether to automatically extend the prompt (default true).
watermarkBooleanwatermark(类型 `Boolean`)。Whether to include watermark (default false).
seedInteger预置(类型 `Integer`)。Optional seed for reproducibility.
返回Returns Mono<ToolResultBlock>
返回Mono。A ToolResultBlock containing the generated video url or error message.
源码Source io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:1294–1470

dashscopeFirstAndLastFrameImageToVideo

public Mono<ToolResultBlock> dashscopeFirstAndLastFrameImageToVideo(String prompt, String model, String firstFrameUrl, String lastFrameUrl, String negativePrompt, String template, String resolution, Boolean promptExtend, Boolean watermark, Integer seed)

执行 dashscopeFirstAndLastFrameImageToVideo 方法。

Generate video transitioning from a first frame to a last frame and an optional text prompt.

参数Parameters
名称Name类型Type说明Description
promptString提示词(类型 `String`)。The text prompt describing the video content and camera movement.
modelString模型实例(类型 `String`)。The model to use, e.g., 'wan2.2-kf2v-flash', 'wanx2.1-kf2v-plus'.
firstFrameUrlString第一个 Frame URL(类型 `String`)。The URL or Base64 data of the first frame image.
lastFrameUrlString最后 Frame URL(类型 `String`)。The URL or Base64 data of the last frame image.
negativePromptStringnegative 提示词(类型 `String`)。The negative prompt to avoid certain elements.
templateString模板(类型 `String`)。Name of video effect template, e.g., 'hanfu-1', 'solaron', etc.
resolutionStringresolution(类型 `String`)。Resolution of the video, e.g., '480P', '720P', '1080P'.
promptExtendBoolean提示词 Extend(类型 `Boolean`)。Whether to automatically extend the prompt (default true).
watermarkBooleanwatermark(类型 `Boolean`)。Whether to include watermark (default false).
seedInteger预置(类型 `Integer`)。Optional seed for reproducibility.
返回Returns Mono<ToolResultBlock>
返回Mono。A ToolResultBlock containing the generated video url or error message.
源码Source io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:1487–1640

dashscopeVideoToText

public Mono<ToolResultBlock> dashscopeVideoToText(String videoUrl, String prompt, String model, Double fps)

执行DashScope 视频到文本相关操作。

Analyze video and generate a text description or answer questions based on the video content.

参数Parameters
名称Name类型Type说明Description
videoUrlString视频 URL(类型 `String`)。The URL or local path of the video to analyze.
promptString提示词(类型 `String`)。The text prompt or question regarding the video content.
modelString模型实例(类型 `String`)。The vision model to use, e.g., 'qwen3.5-plus', 'qwen3.5-flash', 'qwen3-vl-plus', 'qwen3-vl-flash', etc.
fpsDoublefps(类型 `Double`)。Frames per second to sample from the video (e.g., 1, 2, 4). Default is 2.
返回Returns Mono<ToolResultBlock>
返回Mono。A ToolResultBlock containing the generated text analysis or error message.
源码Source io/agentscope/extensions/model/dashscope/tool/DashScopeMultiModalTool.java:1651–1769
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.