Spring AI currently is fixed on using the official OpenAI URL when working with OpenAI. This makes it impossible to use Spring AI against a locally running OpenAI API such as LocalAI.
This PR exposes a new property (spring.ai.openai.base-url
) that allows for custom configuration of the base URL. It still defaults to the official OpenAI API, though.
For example, to use this with a locally running LocalAI listening on port 8080, the following entry can be added to the application.properties file:
spring.ai.openai.base-url=http://localhost:8080/
Comment From: markpollack
I have merged this, just adding a comment that the underlying library will likely add this support as they have an open issue for it. I also enforced the use of the API KEY only if the baseUrl is pointing to api.openai.com
commit; 02180696133f644a2f1c3136458210e75a4c5a52
Thanks for the contribution.