File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -188,6 +188,30 @@ export class OpenAiService extends BaseAiService implements IAiApiService {
188188 protected showNoTitleInferredNotification ( ) : void {
189189 this . notificationService . showWarning ( "Could not infer title. The file name was not changed." ) ;
190190 }
191+
192+ /**
193+ * Override getApiEndpoint to handle Azure OpenAI URLs
194+ *
195+ * OpenAI (default):
196+ * https://api.openai.com/v1/chat/completions
197+ * Azure OpenAI (example)
198+ * https://<instance id>.openai.azure.com/openai/deployments/<deployment id>/chat/completions?api-version=<version>
199+ */
200+ protected getApiEndpoint ( config : Record < string , any > ) : string {
201+ let endpoint = super . getApiEndpoint ( config ) ;
202+ const isAzure = config . url . includes ( ".openai.azure.com" ) ;
203+
204+ if ( isAzure ) {
205+ endpoint = endpoint . replace ( "/v1" , "" ) ;
206+ }
207+
208+ if ( config . openaiApiVersion ) {
209+ const separator = endpoint . includes ( "?" ) ? "&" : "?" ;
210+ endpoint = `${ endpoint } ${ separator } api-version=${ config . openaiApiVersion } ` ;
211+ }
212+
213+ return endpoint ;
214+ }
191215}
192216
193217export interface OpenAIStreamPayload {
You can’t perform that action at this time.
0 commit comments