• Consolidate SpeechModel APIs into the spring-ai-core module, make it null-safe and covered by unit tests.
  • Refactor OpenAiSpeechModel APIs to implement the new consolidated APIs.
  • Delete leftover ImageResponseMetadata class in the spring-ai-openai module.

Fixes gh-1496

Comment From: ThomasVitale

Once this PR is merged, I'll have 2 followups PRs: one to update the documentation and one to add observability instrumentation to the OpenAiSpeechModel.

Comment From: markpollack

The biggest concern for me is how portable are the abstractions, we need at least two impls to ensure that we have the correct abstraction before moving into main. Also, most of the changes seem sort of "shallow", e.g. just changing the name of the class and the types, but aside from the name change they have the same functionality as the 'non speach' core api.

Thoughts?

Comment From: ThomasVitale

I also thought about that, so I was conservative with the changes. The main benefit I see in having the Speech APIs in Core is that it's simpler to demonstrate and try out new implementations, or even for users to implement their own custom ones. Mainly for the semantics given by the interfaces and the few conventions they have.

But I don't have strong feeling about it, so I'd be fine parking this for now. I was looking into adding observability for speech models, but we can wait for that (I wouldn't do it inside the OpenAI module so to keep consistency with the rest of the observability implementation).

@habuma do you have any thoughts about this change?