Bug description
According to the Spring AI documentation (https://docs.spring.io/spring-ai/reference/api/chatclient.html#_multiple_openai_compatible_api_endpoints),
we can inject OpenAiApi
and mutate to configure multiple OpenAI compatible ChatClients.
But it seems OpenAiApi object is not registered as a bean via AutoConfiguration.
Environment Spring AI: 1.0.0, 1.1.0-SNAPSHOT.
Steps to reproduce Try to inject OpenAiApi into any Spring bean.
Expected behavior A bean of type OpenAiApi should be injected.
Comment From: sunyuhan1998
Indeed, currently we've only registered the bean related to ChatModel
. Although I'm not sure whether this is an oversight in the documentation, I think it might also be a good idea to automatically register the OpenAiApi
bean.
Additionally, I noticed some inconsistencies in how we register XXApi
beans across different model auto-configuration classes. For certain models, the auto-configuration class explicitly registers the XXApi
as a bean, whereas for others, the corresponding XXApi
is only created inline when registering the ChatModel
bean, without being registered as a standalone bean itself.
@ilayaperumalg what's your opinion on this? If adjustments are needed, I'd be happy to contribute a PR.