When I use Spring AI ChatClient with
ChatResponse chatResponse = chatClient.prompt(prompt).call().chatResponse();
to call the LLM and compare it with calling the LLM directly, the prompt token count for the direct call is only around 1k, while using ChatClient results in over 20k tokens.
I confirm that I am not using the memory mechanism, and I have set the default system message to "You are a helpful assistant".
My input prompt includes an image in Base64 string format.
When using the same prompt: Spring AI: inputTokens = 21137, outputTokens = 78, totalTokens = 21215 SDK: inputTokens = 881, outputTokens = 80, totalTokens = 961
My env: jdk21, springboot3.3.9, spring-ai-bom1.0.1, spring-ai-starter-model-openai I use spring-ai-starter-model-openai and modify the baseUrl to call other large language models.
Comment From: leto-hub
And I printed the debug logs to check the SimpleLoggerAdvisor request log, but didn’t find anything unusual.