fix(provider-cloud): set apiKey in Azure AI Foundry endpoint (#195)
* fix(providers-cloud): set string-type API key for Azure AI * Check apiKey anyway * Remove the unnecessary null check
This commit is contained in:
1 parent
f26c933037
commit
44961d82d2
1 file changed
+8
-11
@@ -73,18 +73,15 @@ export const createAzure = async (options: CreateAzureOptions) => {
|
||||
// For the extra steps to obtain the bearer token, please refer to the following links:
|
||||
// https://learn.microsoft.com/en-us/azure/api-management/api-management-authenticate-authorize-azure-openai
|
||||
// https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#authentication
|
||||
if (typeof options.apiKey === 'function') {
|
||||
init.headers ??= {}
|
||||
const token = `Bearer ${typeof options.apiKey === 'function' ? await options.apiKey() : options.apiKey}`
|
||||
|
||||
const token = `Bearer ${await options.apiKey()}`
|
||||
|
||||
if (Array.isArray(init.headers))
|
||||
init.headers.push(['Authorization', token])
|
||||
else if (init.headers instanceof Headers)
|
||||
init.headers.append('Authorization', token)
|
||||
else
|
||||
init.headers.Authorization = token
|
||||
}
|
||||
init.headers ??= {}
|
||||
if (Array.isArray(init.headers))
|
||||
init.headers.push(['Authorization', token])
|
||||
else if (init.headers instanceof Headers)
|
||||
init.headers.append('Authorization', token)
|
||||
else
|
||||
init.headers.Authorization = token
|
||||
|
||||
return globalThis.fetch(input, init)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user