Browse Source

Fixes #2940 changes auth for Azure

main
Eric Amodio 1 year ago
parent
commit
130c3468fb
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      src/ai/openaiProvider.ts

+ 4
- 2
src/ai/openaiProvider.ts View File

@ -143,11 +143,13 @@ export class OpenAIProvider implements AIProvider {
}
private fetch(apiKey: string, request: OpenAIChatCompletionRequest) {
return fetch(this.url, {
const url = this.url;
const isAzure = url.includes('.azure.com');
return fetch(url, {
headers: {
Accept: 'application/json',
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
...(isAzure ? { 'api-key': apiKey } : { Authorization: `Bearer ${apiKey}` }),
},
method: 'POST',
body: JSON.stringify(request),

Loading…
Cancel
Save