openai4j icon indicating copy to clipboard operation
openai4j copied to clipboard

Api key

Open juancadavid opened this issue 2 years ago • 1 comments

Hello, I'm trying to use our Azure OpenAI deployment using openai4j. Problem is, the tenant expects the API key within a header called "Ocp-Apim-Subscription-Key" and not "api-key" as it has been hardcoded in src/main/java/dev/ai4j/openai4j/ApiKeyHeaderInjector.java.

The MS documentation says we can change the headers' name, but it just won't work and always reply 401 to all requests. Only works if the header is called "Ocp-Apim-Subscription-Key": https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions

Any recommended solutions, besides forking the code and making the change in this file :) ? Thanks in advance !

Juan

juancadavid avatar Oct 28 '23 18:10 juancadavid

Hi, have you tried the official [Azure OpenAI client library for Java] from Microsoft? If you need to access both, take a look at langchain4j. It adds an abstraction layer and allows you to choose from a wide range of providers and models.

hkuhn42 avatar Jul 23 '24 18:07 hkuhn42