Skip to content

alexcheng1982/spring-ai-dashscope-client

Repository files navigation

Aliyun Dashscope Spring AI Client

English | 中文

Aliyun Dashscope Client for Spring AI

build

Maven Central Version

An Aliyun Dashscope API key is required. The key is set as environment variable DASHSCOPE_API_KEY.

Quick start

Add Maven dependency:

<dependency>
  <groupId>io.github.alexcheng1982</groupId>
  <artifactId>spring-ai-dashscope-client</artifactId>
  <version>VERSION</version>
</dependency>

Usage:

var client = DashscopeChatClient.createDefault();
var response = client.call("hello");

Features

  • ChatClient
  • StreamingChatClient
  • EmbeddingClient
  • Function calling
  • Multimodal input with images and audios

Spring Boot Starter

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 ChatClient bean and an EmbeddingClient 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.