Custom Model api-key header being sent as empty
This was working with previous releases. With the latest release the api-key for authentication is not being sent although it has been added in the configuration I can verify the same key works with cURL and postman requests
Hi, @parijatn I have tried with AI Toolkit v0.16.1 and api key for custom models works as expected.
Are you using models hosted on Azure AI Foundry / Azure OpenAI service or OpenAI? For Azure or OpenAI models, you directly input the API key when configuring custom models. But for any other providers, you need to set the full auth header
For example, set Authorization: Bearer xxx, api-key: xxx or in any other format according to your model provider.
We are proxying models provided by Azure Foundry via Azure APIM
Here is the URL I am providing for the custom connection
After specifying the model and display name for the key screen
I have tried values
api-key: KEYVAL and KEYVAL
(Our auth is key based and api-key is the header required which maps to the apim subscription key) However for both I see auth errors
Also in my APIM logs I see the call was made but the api-key was missing
Please let me know what I am missing. Thanks
Hi @parijatn, thanks for the clarification. By default APIM requires subscription key header, otherwise, it will return 401. So you need 2 headers Ocp-Apim-Subscription-Key: <APIM_SUBSCRIPTION_KEY> and Authorization: Bearer <Foundry_API_KEY> to call the model. But AITK currently only support one auth header.
A workaround is to disable APIM subscription key requirement:
And in AITK, set authorization header when adding custom model with Authorization: Bearer <Foundry_API_KEY>
Thanks @a1exwang, I had forgotten to mention,
- our apim has a managed identity access to foundry hence no auth is required there
- The APIM header names have been changed to use api-key instead of the default key names
Below is an example of the call which works in postman and curl
Please help, thanks
@parijatn Thanks for the clarification. However, I cannot reproduce the issue.
One possible cause might be AITK incorrectly treat the URL as OpenAI URL and use Authorization instead. If so, you can check C:\users\<username>\.aitk\models\my-models.yml file, and find Custom section and for the object of your model name, manually set headers to your format.
For example:
Thank you for the workaround it works now!
We were able to reproduce the same issue for a different developer's VSCode The entries when we enter api-key are showing up as below
We can work with the current workaround which is much appreciated. However please let us know if this is the path forward or will this be resolved on your side. Thanks
Thank you for the workaround it works now!
We were able to reproduce the same issue for a different developer's VSCode The entries when we enter api-key are showing up as below
We can work with the current workaround which is much appreciated. However please let us know if this is the path forward or will this be resolved on your side. Thanks
It's good it works. This is a temporary workaround for now. We will fix this bug and let you directly input API key.
We can work with the current workaround which is much appreciated. However please let us know if this is the path forward or will this be resolved on your side. Thanks