Bug description

With the following controller class

@RestController
@RequestMapping("/api/deepseek")
public class DeepSeekController {

    private final DeepSeekChatModel chatModel;


    public DeepSeekController(DeepSeekChatModel chatModel) {
        this.chatModel = chatModel;
    }

    @GetMapping("/ai/generate")
    public Map generate(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
        return Map.of("generation", chatModel.call(message));
    }
}

, I got a compilation error:

Parameter 0 of constructor in com.example.deepseekapi.DeepSeekController required a bean of type 'org.springframework.ai.deepseek.DeepSeekChatModel' that could not be found.

Environment Here is the build.gradle file:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.5.4'
    id 'io.spring.dependency-management' version '1.1.7'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(24)
    }
}

repositories {
    mavenCentral()
    maven { url 'https://repo.spring.io/milestone' }
    maven { url 'https://repo.spring.io/snapshot' }
    maven {
        name = 'Central Portal Snapshots'
        url = 'https://central.sonatype.com/repository/maven-snapshots/'
    }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
//  implementation 'org.springframework.ai:spring-ai-starter-model-deepseek' <-- not available 
    implementation platform("org.springframework.ai:spring-ai-bom:1.0.0-SNAPSHOT")
//  // Replace the following with the starter dependencies of specific modules you wish to use
    implementation 'org.springframework.ai:spring-ai-deepseek'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
    useJUnitPlatform()
}

And here is the application.yml file

spring:
  ai:
    deepseek:
      api-key: <api-key>
      chat:
        option:
          model: deepseek-chat
          temperature: 0.7

Steps to reproduce Following online document we can find, we set up a short project with Spring AI DeepSeek client. The documents we use are stated on this stackoverflow post.

Comment From: sobychacko

Why are you commenting out this line?

//  implementation 'org.springframework.ai:spring-ai-starter-model-deepseek' <-- not available 

That is the starter module that brings the auto-configuration for deepseek. Without that, you don't have a bean for DeepSeekChatModel.

Comment From: vw98075

I already stated the reason in the original post, "not available". With the line up and other Spring AI dependencies commented out, there isn't any Spring AI dependencies in the external libraries panel of Intellji Idea.

Comment From: wilocu

Hi, i think this might be the issue try it this way:

Quick Fix - Update Your Dependencies

Replace this: // implementation 'org.springframework.ai:spring-ai-starter-model-deepseek' <-- not available implementation 'org.springframework.ai:spring-ai-deepseek'

With this: repositories { mavenCentral() maven { url 'https://repo.spring.io/snapshot' } }

dependencies { implementation platform("org.springframework.ai:spring-ai-bom:1.1.0-SNAPSHOT") implementation 'org.springframework.ai:spring-ai-starter-model-deepseek' }

The starter does exist - it's just only available in Spring's snapshot repository right now.

Alternative: If You Have Multiple AI Providers

If you're still getting bean conflicts with multiple providers, try adding this to your application.yml:

spring: ai: model: chat: deepseek deepseek: api-key: ${DEEPSEEK_API_KEY} base-url: https://api.deepseek.com

Why This might Works

The spring-ai-deepseek dependency only contains the model classes - you need spring-ai-starter-model-deepseek to get the Spring Boot auto-configuration
that creates the bean.

Give this a try and let me know if your DeepSeekChatModel injection starts working!

Comment From: YunKuiLu

I quickly set up a project using the code you provided. I circled the different parts with red boxes. It can run normally on my side.

By the way, Spring AI has released version 1.0.1. You can update your dependencies.

Image

Comment From: vw98075

@YunKuiLu Thanks for the info. To my reading, the dependency org.springframework.ai:spring-ai-bom:1.0.0-SNAPSHOT is used to pair up with org.springframework.ai:spring-ai-deepseek. I missed that org.springframework.ai:spring-ai-starter-model-deepseek also needs to pair with org.springframework.ai:spring-ai-starter-model-deepseek.

I also have some observations on the Spring bean auto creation. The bean certainly needs a correct API configuration. What will happen if the configuration is incorrect. I have seen two different configurations in the document.

spring:
  ai:
    deepseek:
      api-key: <api-key>
      chat:
        model: deepseek-chat
        temperature: 0.7

and

spring:
  ai:
    deepseek:
      api-key: <api-key>    
      option:
          model: deepseek-chat
          temperature: 0.7

Both seem to be fine for my brief test. Are both correct?

Comment From: YunKuiLu

@vw98075 According to the DeepSeekChatProperties class the correct configuration for the Deepseek model is spring.ai.deepseek.chat.options.model. The options you mentioned spring.ai.deepseek.chat.model and spring.ai.deepseek.options.model are not valid.
It may look like it's working because the default value of spring.ai.deepseek.chat.options.model is deepseek-chat.

If you are familiar with SpringBoot's Auto Configuration mechanism, you can find relevant information about deepseek auto configuration in org.springframework.ai.model.deepseek.autoconfigure.DeepSeekChatAutoConfiguration.

Regarding the docs mistake you mentioned, if you're willing and have time feel free to open a PR to fix it. If you don't have time it's okay too I will find a time to fix it.

Comment From: vw98075

@YunKuiLu Thanks for your follow-up. I will let you create a pull request as I am very new to the project and don't have much knowledge about it.

Comment From: YunKuiLu

What will happen if the configuration is incorrect. I have seen two different configurations in the document.

spring: ai: deepseek: api-key: <api-key> chat: model: deepseek-chat temperature: 0.7

and

spring: ai: deepseek: api-key: <api-key> option: model: deepseek-chat temperature: 0.7

Both seem to be fine for my brief test. Are both correct?

@vw98075 Would you mind sharing the documentation link? I couldn’t find the misconfiguration you mentioned.

Comment From: vw98075

@YunKuiLu If my memory serves me correctly. I saw the following configuration from a Spring AI demo code in the Spring AI project repository on github, but not a document. I can't find the code at this moment.

spring:
  ai:
    deepseek:
      api-key: <api-key>
      base-url: https://api.deepseek.com
      model: deepseek-chat
      temperature: 0.7

Comment From: YunKuiLu

@vw98075 Maybe what you saw was a demo project using the Milestone version before Spring AI 1.0.0 was released. You can check the latest documentation on DeepSeek configuration: https://docs.spring.io/spring-ai/reference/api/chat/deepseek-chat.html#_auto_configuration

Comment From: vw98075

That likely is the case. Thanks. BTW, which property is for web search? Our usage might need an LLM do some web search.

Comment From: YunKuiLu

DeepSeek’s API doesn’t include web search functionality, so you’ll probably want to implement it yourself: 1. Rewrite the user's input to make it suitable for search engine queries (you can use Deepseek to do the rewriting) 2. Call a search engine API to get results 3. Add those results to your prompt before sending it to the DeepSeek

Comment From: vw98075

I see. Thanks.