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

Comment From: emredmrcan

@markpollack can I check and contribute to this issue?

Comment From: hungrytech

@markpollack @emredmrcan Is it still unresolved? If so, can I contribute to solving it?

Comment From: emredmrcan

@markpollack @emredmrcan Is it still unresolved? If so, can I contribute to solving it?

Hello @hungrytech , I haven't received a reply yet so If they approve your contribution request, please feel free to go

Comment From: thelightway24

Hello @emredmrcan , @hungrytech It seems there hasn’t been an update on this issue for a while.
Has this been resolved? If not and no one’s working on it, I'd be happy to work on it.