Path: blob/main/extensions/copilot/src/extension/byok/node/azureOpenAIEndpoint.ts
13399 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/4import { OpenAIEndpoint } from './openAIEndpoint';56/**7* Azure-specific OpenAI endpoint that supports Entra ID authentication.8* Extends OpenAIEndpoint to override header generation for Azure-specific auth methods.9* Note: Authentication token refresh is handled at the provider level (azureProvider.ts).10*/11export class AzureOpenAIEndpoint extends OpenAIEndpoint {12/**13* Override to use Entra ID authentication headers instead of API key.14*/15public override getExtraHeaders(): Record<string, string> {16const headers = super.getExtraHeaders();17headers['Authorization'] = `Bearer ${this._apiKey}`;18// Defensive: Ensure 'api-key' header is never sent for Azure endpoints, even if parent class changes.19delete headers['api-key'];20return headers;21}22}232425