Aliyun Dashscope Model for Spring AI
| Client/Model version | Spring AI version |
|---|---|
1.1.x |
0.8.1 |
>= 1.3.x |
1.0.0 |
An Aliyun Dashscope API key is required. The key is set as environment variable
DASHSCOPE_API_KEY.
Add Maven dependency:
<dependency> <groupId>io.github.alexcheng1982</groupId> <artifactId>spring-ai-dashscope-client</artifactId> <version>VERSION</version> </dependency>
Usage:
var model = DashscopeChatModel.createDefault(); var response = model.call("hello");
ChatModelStreamingChatModelEmbeddingModel- Function calling
- Multimodal input with images and audios
Add Spring Boot starter:
<dependency> <groupId>io.github.alexcheng1982</groupId> <artifactId>spring-ai-dashscope-spring-boot-starter</artifactId> <version>VERSION</version> </dependency>
This will create a ChatModel bean and an EmbeddingModel bean.
Default ChatOptions can be configured
with the configuration key spring.ai.dashscope.chat.options.
Default EmbeddingOptions can be configured with the configuration
key spring.ai.dashscope.embedding.options.
spring: ai: dashscope: chat: options: model: qwen-plus temperature: 0.2 embedding: options: model: text-embedding-v2
See example for reference.