Skip to content

Conversation

@paulbakker
Copy link
Contributor

Allow disabling setting the Authorization header in OpenAi models.

Possible fix for #2218

…ing the Authorization header.

Signed-off-by: pbakker <[email protected]>
@ilayaperumalg ilayaperumalg self-assigned this Feb 12, 2025
@ilayaperumalg ilayaperumalg added this to the 1.0.0-M6 milestone Feb 12, 2025
Copy link
Member

@ilayaperumalg ilayaperumalg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, merging. will follow up with a PR to use ApiKey for the other OpenAi APIs.

import org.springframework.ai.model.ChatModelDescription;
import org.springframework.ai.model.ModelOptionsUtils;
import org.springframework.ai.model.SimpleApiKey;
import org.springframework.ai.model.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wildcard import isn't allowed and will fix when merging.

@ilayaperumalg
Copy link
Member

@paulbakker Thanks for the PR!
Rebased, cleaned up java imports, license header and merged as b936a9c. Will have a follow up PR for using ApiKey for image, audio and moderation APIs.

@ilayaperumalg
Copy link
Member

PR to use ApiKey for other OpenAI APIs: #2226

@paulbakker
Copy link
Contributor Author

Thanks for the super quick follow up @ilayaperumalg 🙏

// @formatter:off
Consumer<HttpHeaders> finalHeaders = h -> {
h.setBearerAuth(apiKey.getValue());
if(!(apiKey instanceof NoopApiKey)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of checking for a specific impl, we should check for the return value, if it is empty then don't set header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants