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