Fix/OpenAI sdk api key azure - #5603
Conversation
3c0c435 to
76b11dc
Compare
|
I've add a look at your comment on ticket #3368 and I believe you are correct, when a key is provided. @Test
void setupSyncClient_usesApiKeyHeader_notBearerToken_forMicrosoftFoundry() throws Exception {
OpenAIClient client = OpenAiSdkSetup.setupSyncClient("https://my-resource.openai.azure.com/", "my-foundry-key",
null, null, null, null, true, false, null, Duration.ofSeconds(30), 2, null, null);
Field field = client.getClass().getDeclaredField("clientOptions");
field.setAccessible(true);
ClientOptions options = (ClientOptions) field.get(client);
assertInstanceOf(AzureApiKeyCredential.class, options.credential());
assertThat(options.headers().values("api-key")).containsExactly("my-foundry-key");
assertThat(options.headers().values("Authorization")).isEmpty();
} |
Thanks for the review and suggestion. I've updated the PR to include the test. |
- Update the Azure SDK to its latest version, to have the latest version of the Azure Identity library. - Updated to the latest version of the OpenAi Java SDK - Modify the algorithm in `OpenAiOfficialSetup` for Microsoft Foundry, to have a similar implementation as spring-projects/spring-ai#5603 in Spring AI
d17c6fc to
9f42a78
Compare
@ilayaperumalg oops don't know how that happened, my bad. I've squashed my commits into one. |
Signed-off-by: Dylan Weijgertze <dylanwprivate@gmail.com>
9f42a78 to
bdbebac
Compare
- Update the Azure SDK to its latest version, to have the latest version of the Azure Identity library. - Updated to the latest version of the OpenAi Java SDK - Modify the algorithm in `OpenAiOfficialSetup` for Microsoft Foundry, to have a similar implementation as spring-projects/spring-ai#5603 in Spring AI
Hey Spring Team!
I've been using the Open AI SDK for a bit and I noticed that the wrong credentials are used for Azure during auto-configuration. When doing the following in my project:
The key is set within the Authorization header but Azure expects it to be set within the
api-keyheader when using an API key and not passwordless auth.I suggest that when Azure is used and an API key is set we add the AzureApiKeyCredential.