Open
Description
Bug description
When only an ImageModel
bean is needed, while configuring the OpenAI API key via the below property:
spring:
ai:
openai:
image:
api-key: ${OPENAI_API_KEY}
I got the below error:
Caused by: java.lang.IllegalArgumentException: OpenAI API key must be set. Use the connection property: spring.ai.openai.api-key or spring.ai.openai.chat.api-key property.
The error persisted when I tried disabling the chat client autoconfiguration using:
spring:
ai:
chat:
client:
enabled: false
Ended up using the spring.ai.openai.api-key
property to resolve the startup exception but the former key should've worked as well.
Environment
Using the Spring AI version : 1.0.0-M4 with Java 23
Expected behavior
The expectation of having the API key recognized when configured through the property spring.ai.openai.image.api-key
was not met.
Steps to reproduce and Minimal Complete Reproducible example
Reproducible example can be found here. Execute the below command to get the exception:
OPENAI_API_KEY="api-key-goes-here" mvn test -Dtest=ImageGeneratorLiveTest