The error "No CallAdvisors available to execute" was occurring when calling OpenAI API endpoints because the ChatClient.Builder was being used without configuring the underlying chat model.
When creating a ChatClient from ChatClient.Builder, the builder needs to have access to the actual chat model (like OpenAiChatModel) to execute the API calls. The advisor chain requires a model at the end of the chain to make the actual call to OpenAI.
Changed all controllers to use ChatClient.builder(openAiChatModel) instead of injecting ChatClient.Builder without a model.
-
ChatController.java
- Changed constructor from
ChatClient.Builder chatClientBuildertoOpenAiChatModel openAiChatModel - Updated to use
ChatClient.builder(openAiChatModel).build()
- Changed constructor from
-
AdvisorsChatController.java
- Changed constructor from
ChatClient.Builder chatClientBuildertoOpenAiChatModel openAiChatModel - Updated to use
ChatClient.builder(openAiChatModel).build()
- Changed constructor from
-
PromptController.java
- Changed constructor from
ChatClient.Builder chatClientBuildertoOpenAiChatModel openAiChatModel - Added import for
OpenAiChatModel - Updated to use
ChatClient.builder(openAiChatModel).build()
- Changed constructor from
-
StreamController.java
- Changed constructor from
ChatClient.Builder buildertoOpenAiChatModel openAiChatModel - Added import for
OpenAiChatModel - Updated to use
ChatClient.builder(openAiChatModel).build()
- Changed constructor from
-
TravelAssistantController.java
- Changed constructor from
ChatClient.Builder chatClientBuildertoOpenAiChatModel openAiChatModel - Added import for
OpenAiChatModel - Updated to use
ChatClient.builder(openAiChatModel).build()
- Changed constructor from
-
PromptTypesController.java
- Changed constructor from
ChatClient.Builder chatClientBuildertoOpenAiChatModel openAiChatModel - Added import for
OpenAiChatModel - Updated to use
ChatClient.builder(openAiChatModel).build()
- Changed constructor from
-
PromptInjectionController.java
- Changed constructor from
ChatClient.Builder chatClientBuildertoOpenAiChatModel openAiChatModel - Added import for
OpenAiChatModel - Updated to use
ChatClient.builder(openAiChatModel).build()
- Changed constructor from
-
StructuredOutputsController.java
- Changed constructor from
ChatClient.Builder chatClientBuildertoOpenAiChatModel openAiChatModel - Added import for
OpenAiChatModel - Updated to use
ChatClient.builder(openAiChatModel).build()
- Changed constructor from
-
ToolCallingController.java
- Changed constructor to remove
ChatClient.Builder builderparameter - Updated to use
ChatClient.builder(openAiChatModel).build()
- Changed constructor to remove
- Restart your Spring Boot application
- Call any of the OpenAI endpoints (e.g.,
/springai/v1/chats,/springai/v1/advisors) - The "No CallAdvisors available to execute" error should no longer appear
- You should receive proper responses from the OpenAI API
When creating new controllers that use ChatClient, always inject the model directly:
@RestController
public class MyController {
private final ChatClient chatClient;
public MyController(OpenAiChatModel openAiChatModel) {
this.chatClient = ChatClient.create(openAiChatModel);
}
}Do NOT use:
// ❌ INCORRECT - Will cause "No CallAdvisors available to execute" error
public MyController(ChatClient.Builder chatClientBuilder) {
this.chatClient = chatClientBuilder.build();
}