At Netflix we have a model abstraction that uses the OpenAi REST API.
Because this is an internal service, we use a different auth mechanism, and adding an Authorization
header to the request is not allowed.
I'm integrating Spring AI with this internal model abstraction and need a way to disable adding the Authorization
header.
I created a simple PR with a possible fix based on the ApiKey
interface, but alternatively, a property would work as well. The PR assumes that a user brings their own beans for the models, overriding the beans from OpenAiAutoConfiguration
.
As a side note, I noticed that while OpenAiApi
uses the ApiKey
interface, both OpenAiAudioApi
and OpenAiImageApi
still use a String
instead of the ApiKey
interface. I didn't want to touch this in the PR because it's an API change, but that's probably worth aligning.
Comment From: ilayaperumalg
@paulbakker Thanks for the PR to fix this.
As a side note, I noticed that while OpenAiApi uses the ApiKey interface, both OpenAiAudioApi and OpenAiImageApi still use a String instead of the ApiKey interface. I didn't want to touch this in the PR because it's an API change, but that's probably worth aligning.
Yes, I will submit a separate PR addressing this and include OpenAiModerationApi as well.
Comment From: ilayaperumalg
Closing this issue as addressed via the changes from b936a9c.This follow-up PR tracks the changes to include ApiKey to other OpenAI APIs: https://github.com/spring-projects/spring-ai/pull/2226