@ai-sdk/azure 3.0.134 → 3.0.136

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -21,6 +21,254 @@ import {
21
21
  withUserAgentSuffix
22
22
  } from "@ai-sdk/provider-utils";
23
23
 
24
+ // src/azure-image-model-options.ts
25
+ import {
26
+ lazySchema as lazySchema2,
27
+ zodSchema as zodSchema2
28
+ } from "@ai-sdk/provider-utils";
29
+ import { z as z2 } from "zod/v4";
30
+
31
+ // src/azure-mai-image-model-options.ts
32
+ import {
33
+ lazySchema,
34
+ zodSchema
35
+ } from "@ai-sdk/provider-utils";
36
+ import { z } from "zod/v4";
37
+ var azureMaiImageModelOptionsShape = () => ({
38
+ /**
39
+ * Let the model pick the output aspect ratio from the prompt and any
40
+ * reference images. MAI-Image-2.6 models only.
41
+ */
42
+ autoAspectRatio: z.boolean().optional(),
43
+ /**
44
+ * Ground generation in Bing web search results. MAI-Image-2.6 models only.
45
+ */
46
+ webGrounding: z.boolean().optional()
47
+ });
48
+ var azureMaiImageModelOptions = lazySchema(
49
+ () => zodSchema(z.object(azureMaiImageModelOptionsShape()))
50
+ );
51
+
52
+ // src/azure-image-model-options.ts
53
+ var azureImageModelOptions = lazySchema2(
54
+ () => zodSchema2(
55
+ z2.object({
56
+ /**
57
+ * API to use. Defaults to MAI for MAI-Image models, OpenAI otherwise.
58
+ */
59
+ api: z2.enum(["openai", "mai"]).optional(),
60
+ ...azureMaiImageModelOptionsShape()
61
+ })
62
+ )
63
+ );
64
+ var maiImageModels = /* @__PURE__ */ new Set([
65
+ "mai-image-2.5",
66
+ "mai-image-2.5-flash",
67
+ "mai-image-2.5-pro",
68
+ "mai-image-2.6",
69
+ "mai-image-2.6-flash"
70
+ ]);
71
+ function isMAIImageModel(modelId) {
72
+ return maiImageModels.has(modelId.toLowerCase());
73
+ }
74
+
75
+ // src/azure-mai-image-model.ts
76
+ import {
77
+ combineHeaders,
78
+ convertBase64ToUint8Array,
79
+ createJsonErrorResponseHandler,
80
+ createJsonResponseHandler,
81
+ downloadBlob,
82
+ postFormDataToApi,
83
+ postJsonToApi
84
+ } from "@ai-sdk/provider-utils";
85
+ import { z as z3 } from "zod/v4";
86
+ var MIN_SIDE = 768;
87
+ var DEFAULT_PIXELS = 1024 * 1024;
88
+ var AzureMaiImageModel = class {
89
+ constructor(modelId, config) {
90
+ this.modelId = modelId;
91
+ this.config = config;
92
+ this.specificationVersion = "v3";
93
+ this.provider = "azure.image";
94
+ this.maxImagesPerCall = 1;
95
+ }
96
+ async doGenerate({
97
+ prompt,
98
+ n,
99
+ size,
100
+ aspectRatio,
101
+ seed,
102
+ files,
103
+ mask,
104
+ headers,
105
+ abortSignal
106
+ }, { autoAspectRatio, webGrounding } = {}) {
107
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
108
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
109
+ const warnings = [];
110
+ if (seed != null) {
111
+ warnings.push({ type: "unsupported", feature: "seed" });
112
+ }
113
+ if (mask != null) {
114
+ warnings.push({
115
+ type: "unsupported",
116
+ feature: "mask",
117
+ details: "MAI image edits do not support masks."
118
+ });
119
+ }
120
+ let dimensions = parseSize(size);
121
+ if (size != null && aspectRatio != null) {
122
+ warnings.push({
123
+ type: "unsupported",
124
+ feature: "aspectRatio",
125
+ details: "aspectRatio is ignored when size is set."
126
+ });
127
+ } else if (aspectRatio != null) {
128
+ dimensions = dimensionsForAspectRatio(aspectRatio);
129
+ if (dimensions == null) {
130
+ warnings.push({
131
+ type: "unsupported",
132
+ feature: "aspectRatio",
133
+ details: `Invalid aspect ratio: ${aspectRatio}.`
134
+ });
135
+ }
136
+ }
137
+ const fields = {
138
+ model: this.modelId,
139
+ prompt,
140
+ width: dimensions == null ? void 0 : dimensions.width,
141
+ height: dimensions == null ? void 0 : dimensions.height,
142
+ auto_aspect_ratio: autoAspectRatio,
143
+ web_grounding: webGrounding
144
+ };
145
+ const requestOptions = {
146
+ headers: combineHeaders(this.config.headers(), headers),
147
+ failedResponseHandler: maiFailedResponseHandler,
148
+ successfulResponseHandler: createJsonResponseHandler(
149
+ maiImageResponseSchema
150
+ ),
151
+ abortSignal,
152
+ fetch: this.config.fetch
153
+ };
154
+ const images = files != null && files.length > 0 ? await Promise.all(files.map((file) => fileToBlob(file, abortSignal))) : void 0;
155
+ const responses = await Promise.all(
156
+ Array.from(
157
+ { length: Math.max(1, n) },
158
+ () => images != null ? postFormDataToApi({
159
+ ...requestOptions,
160
+ url: this.config.url("/images/edits"),
161
+ formData: toFormData(fields, images)
162
+ }) : postJsonToApi({
163
+ ...requestOptions,
164
+ url: this.config.url("/images/generations"),
165
+ body: fields
166
+ })
167
+ )
168
+ );
169
+ let usage;
170
+ const metadata = [];
171
+ for (const { value: response } of responses) {
172
+ const textTokens = (_e = (_d = response.usage) == null ? void 0 : _d.num_input_text_tokens) != null ? _e : void 0;
173
+ const imageTokens = (_g = (_f = response.usage) == null ? void 0 : _f.num_input_image_tokens) != null ? _g : void 0;
174
+ if (response.usage != null) {
175
+ const inputTokens = addTokens(textTokens, imageTokens);
176
+ const outputTokens = (_h = response.usage.num_output_tokens) != null ? _h : void 0;
177
+ usage = {
178
+ inputTokens: addTokens(usage == null ? void 0 : usage.inputTokens, inputTokens),
179
+ outputTokens: addTokens(usage == null ? void 0 : usage.outputTokens, outputTokens),
180
+ totalTokens: addTokens(
181
+ usage == null ? void 0 : usage.totalTokens,
182
+ addTokens(inputTokens, outputTokens)
183
+ )
184
+ };
185
+ }
186
+ metadata.push(
187
+ ...response.data.map(() => ({
188
+ ...response.created != null ? { created: response.created } : {},
189
+ ...response.size != null ? { size: response.size } : {},
190
+ ...textTokens != null ? { textTokens } : {},
191
+ ...imageTokens != null ? { imageTokens } : {}
192
+ }))
193
+ );
194
+ }
195
+ return {
196
+ images: responses.flatMap(
197
+ ({ value }) => value.data.map((item) => item.b64_json)
198
+ ),
199
+ warnings,
200
+ response: {
201
+ timestamp: currentDate,
202
+ modelId: this.modelId,
203
+ headers: (_i = responses[0]) == null ? void 0 : _i.responseHeaders
204
+ },
205
+ usage,
206
+ providerMetadata: { azure: { images: metadata } }
207
+ };
208
+ }
209
+ };
210
+ function addTokens(a, b) {
211
+ return a == null && b == null ? void 0 : (a != null ? a : 0) + (b != null ? b : 0);
212
+ }
213
+ function parseSize(size) {
214
+ if (size == null) return void 0;
215
+ const [width, height] = size.split("x").map(Number);
216
+ return { width, height };
217
+ }
218
+ function dimensionsForAspectRatio(aspectRatio) {
219
+ const [w, h] = aspectRatio.split(":").map(Number);
220
+ if (!(w > 0 && h > 0)) return void 0;
221
+ const ratio = w / h;
222
+ let width = Math.sqrt(DEFAULT_PIXELS * ratio);
223
+ let height = width / ratio;
224
+ if (Math.min(width, height) < MIN_SIDE) {
225
+ [width, height] = width < height ? [MIN_SIDE, MIN_SIDE / ratio] : [MIN_SIDE * ratio, MIN_SIDE];
226
+ }
227
+ const floor16 = (value) => Math.floor(value / 16 + 1e-9) * 16;
228
+ return {
229
+ width: Math.max(MIN_SIDE, floor16(width)),
230
+ height: Math.max(MIN_SIDE, floor16(height))
231
+ };
232
+ }
233
+ function toFormData(fields, images) {
234
+ const formData = new FormData();
235
+ for (const [key, value] of Object.entries(fields)) {
236
+ if (value != null) formData.append(key, String(value));
237
+ }
238
+ images.forEach((blob, index) => {
239
+ const extension = blob.type === "image/jpeg" ? "jpg" : "png";
240
+ formData.append("image", blob, `image-${index + 1}.${extension}`);
241
+ });
242
+ return formData;
243
+ }
244
+ async function fileToBlob(file, abortSignal) {
245
+ if (file.type === "url") {
246
+ return downloadBlob(file.url, { abortSignal });
247
+ }
248
+ const data = file.data instanceof Uint8Array ? file.data : convertBase64ToUint8Array(file.data);
249
+ return new Blob([data], { type: file.mediaType });
250
+ }
251
+ var maiErrorSchema = z3.object({
252
+ error: z3.object({
253
+ code: z3.union([z3.string(), z3.number()]).nullish(),
254
+ message: z3.string()
255
+ })
256
+ });
257
+ var maiFailedResponseHandler = createJsonErrorResponseHandler({
258
+ errorSchema: maiErrorSchema,
259
+ errorToMessage: (data) => data.error.message
260
+ });
261
+ var maiImageResponseSchema = z3.object({
262
+ created: z3.number().nullish(),
263
+ size: z3.string().nullish(),
264
+ usage: z3.object({
265
+ num_input_text_tokens: z3.number().nullish(),
266
+ num_input_image_tokens: z3.number().nullish(),
267
+ num_output_tokens: z3.number().nullish()
268
+ }).nullish(),
269
+ data: z3.array(z3.object({ b64_json: z3.string() }))
270
+ });
271
+
24
272
  // src/azure-openai-tools.ts
25
273
  import {
26
274
  codeInterpreter,
@@ -39,40 +287,40 @@ var azureOpenaiTools = {
39
287
 
40
288
  // src/azure-speech-model-options.ts
41
289
  import {
42
- lazySchema as lazySchema2,
43
- zodSchema as zodSchema2
290
+ lazySchema as lazySchema4,
291
+ zodSchema as zodSchema4
44
292
  } from "@ai-sdk/provider-utils";
45
- import { z as z2 } from "zod/v4";
293
+ import { z as z5 } from "zod/v4";
46
294
 
47
295
  // src/azure-speech-speech-model-options.ts
48
296
  import {
49
- lazySchema,
50
- zodSchema
297
+ lazySchema as lazySchema3,
298
+ zodSchema as zodSchema3
51
299
  } from "@ai-sdk/provider-utils";
52
- import { z } from "zod/v4";
300
+ import { z as z4 } from "zod/v4";
53
301
  var azureSpeechSpeechModelOptionsShape = () => ({
54
302
  /**
55
303
  * Speaking style applied with `mstts:express-as`, e.g. `excited` or
56
304
  * `whispering`. Supported styles vary by voice.
57
305
  */
58
- style: z.string().min(1).optional(),
306
+ style: z4.string().min(1).optional(),
59
307
  /**
60
308
  * Intensity of `style`, from 0.01 to 2. Azure defaults to 1.
61
309
  */
62
- styleDegree: z.number().min(0.01).max(2).optional()
310
+ styleDegree: z4.number().min(0.01).max(2).optional()
63
311
  });
64
- var azureSpeechSpeechModelOptions = lazySchema(
65
- () => zodSchema(z.strictObject(azureSpeechSpeechModelOptionsShape()))
312
+ var azureSpeechSpeechModelOptions = lazySchema3(
313
+ () => zodSchema3(z4.strictObject(azureSpeechSpeechModelOptionsShape()))
66
314
  );
67
315
 
68
316
  // src/azure-speech-model-options.ts
69
- var azureSpeechModelOptions = lazySchema2(
70
- () => zodSchema2(
71
- z2.strictObject({
317
+ var azureSpeechModelOptions = lazySchema4(
318
+ () => zodSchema4(
319
+ z5.strictObject({
72
320
  /**
73
321
  * API to use. Defaults to Speech for MAI-Voice models, OpenAI otherwise.
74
322
  */
75
- api: z2.enum(["openai", "speech"]).optional(),
323
+ api: z5.enum(["openai", "speech"]).optional(),
76
324
  ...azureSpeechSpeechModelOptionsShape()
77
325
  })
78
326
  )
@@ -92,13 +340,13 @@ import {
92
340
  APICallError
93
341
  } from "@ai-sdk/provider";
94
342
  import {
95
- combineHeaders,
343
+ combineHeaders as combineHeaders2,
96
344
  createBinaryResponseHandler,
97
345
  extractResponseHeaders,
98
346
  postToApi,
99
347
  safeParseJSON
100
348
  } from "@ai-sdk/provider-utils";
101
- import { z as z3 } from "zod/v4";
349
+ import { z as z6 } from "zod/v4";
102
350
  var DEFAULT_VOICE = "en-US-Harper";
103
351
  var DEFAULT_VOICES = /* @__PURE__ */ new Map([
104
352
  ["de", "de-DE-Mia"],
@@ -192,7 +440,7 @@ var AzureSpeechSpeechModel = class {
192
440
  rawValue
193
441
  } = await postToApi({
194
442
  url: this.config.url(),
195
- headers: combineHeaders(
443
+ headers: combineHeaders2(
196
444
  this.config.headers(),
197
445
  {
198
446
  "Content-Type": "application/ssml+xml",
@@ -270,8 +518,8 @@ function resolveVoice(voice, language) {
270
518
  languageWarning: `The voice ${voice} selects the language. Language "${language}" was ignored.`
271
519
  } : { voice };
272
520
  }
273
- var errorSchema = z3.object({
274
- error: z3.object({ message: z3.string() })
521
+ var errorSchema = z6.object({
522
+ error: z6.object({ message: z6.string() })
275
523
  });
276
524
  var failedResponseHandler = async ({
277
525
  response,
@@ -302,65 +550,65 @@ var failedResponseHandler = async ({
302
550
 
303
551
  // src/azure-speech-transcription-model.ts
304
552
  import {
305
- combineHeaders as combineHeaders2,
306
- convertBase64ToUint8Array,
307
- createJsonErrorResponseHandler,
308
- createJsonResponseHandler,
553
+ combineHeaders as combineHeaders3,
554
+ convertBase64ToUint8Array as convertBase64ToUint8Array2,
555
+ createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
556
+ createJsonResponseHandler as createJsonResponseHandler2,
309
557
  mediaTypeToExtension,
310
- postFormDataToApi
558
+ postFormDataToApi as postFormDataToApi2
311
559
  } from "@ai-sdk/provider-utils";
312
- import { z as z6 } from "zod/v4";
560
+ import { z as z9 } from "zod/v4";
313
561
 
314
562
  // src/azure-transcription-model-options.ts
315
563
  import {
316
- lazySchema as lazySchema4,
317
- zodSchema as zodSchema4
564
+ lazySchema as lazySchema6,
565
+ zodSchema as zodSchema6
318
566
  } from "@ai-sdk/provider-utils";
319
- import { z as z5 } from "zod/v4";
567
+ import { z as z8 } from "zod/v4";
320
568
 
321
569
  // src/azure-speech-transcription-model-options.ts
322
570
  import {
323
- lazySchema as lazySchema3,
324
- zodSchema as zodSchema3
571
+ lazySchema as lazySchema5,
572
+ zodSchema as zodSchema5
325
573
  } from "@ai-sdk/provider-utils";
326
- import { z as z4 } from "zod/v4";
574
+ import { z as z7 } from "zod/v4";
327
575
  var azureSpeechTranscriptionModelOptionsShape = () => ({
328
576
  /**
329
577
  * Timing granularity. Defaults to `segment` so that transcription results
330
578
  * include timed segments (Azure's own default is `none`).
331
579
  */
332
- timestamps: z4.enum(["word", "segment", "none"]).optional(),
580
+ timestamps: z7.enum(["word", "segment", "none"]).optional(),
333
581
  /**
334
582
  * `verbatim` keeps fillers and false starts, `clean` removes them.
335
583
  * Azure defaults to `verbatim`.
336
584
  */
337
- transcribeStyle: z4.enum(["verbatim", "clean"]).optional(),
585
+ transcribeStyle: z7.enum(["verbatim", "clean"]).optional(),
338
586
  /**
339
587
  * Forces a single language, e.g. `['en']`. Omit for automatic language
340
588
  * detection and code switching.
341
589
  */
342
- locales: z4.array(z4.string()).length(1).optional(),
590
+ locales: z7.array(z7.string()).length(1).optional(),
343
591
  /**
344
592
  * Speaker diarization. Speaker IDs are available in provider metadata.
345
593
  */
346
- diarization: z4.strictObject({ enabled: z4.boolean() }).optional(),
594
+ diarization: z7.strictObject({ enabled: z7.boolean() }).optional(),
347
595
  /**
348
596
  * Keyword biasing for names and domain terminology.
349
597
  */
350
- phraseList: z4.strictObject({ phrases: z4.array(z4.string()) }).optional()
598
+ phraseList: z7.strictObject({ phrases: z7.array(z7.string()) }).optional()
351
599
  });
352
- var azureSpeechTranscriptionModelOptions = lazySchema3(
353
- () => zodSchema3(z4.strictObject(azureSpeechTranscriptionModelOptionsShape()))
600
+ var azureSpeechTranscriptionModelOptions = lazySchema5(
601
+ () => zodSchema5(z7.strictObject(azureSpeechTranscriptionModelOptionsShape()))
354
602
  );
355
603
 
356
604
  // src/azure-transcription-model-options.ts
357
- var azureTranscriptionModelOptions = lazySchema4(
358
- () => zodSchema4(
359
- z5.strictObject({
605
+ var azureTranscriptionModelOptions = lazySchema6(
606
+ () => zodSchema6(
607
+ z8.strictObject({
360
608
  /**
361
609
  * API to use. Defaults to Speech for MAI-Transcribe models, OpenAI otherwise.
362
610
  */
363
- api: z5.enum(["openai", "speech"]).optional(),
611
+ api: z8.enum(["openai", "speech"]).optional(),
364
612
  ...azureSpeechTranscriptionModelOptionsShape()
365
613
  })
366
614
  )
@@ -393,7 +641,7 @@ var AzureSpeechTranscriptionModel = class {
393
641
  "audio",
394
642
  new Blob(
395
643
  [
396
- typeof options.audio === "string" ? convertBase64ToUint8Array(options.audio) : options.audio
644
+ typeof options.audio === "string" ? convertBase64ToUint8Array2(options.audio) : options.audio
397
645
  ],
398
646
  { type: options.mediaType }
399
647
  ),
@@ -415,20 +663,20 @@ var AzureSpeechTranscriptionModel = class {
415
663
  phraseList: azureOptions.phraseList
416
664
  })
417
665
  );
418
- const { value, rawValue, responseHeaders } = await postFormDataToApi({
666
+ const { value, rawValue, responseHeaders } = await postFormDataToApi2({
419
667
  url: this.config.url(),
420
- headers: combineHeaders2(this.config.headers(), options.headers),
668
+ headers: combineHeaders3(this.config.headers(), options.headers),
421
669
  formData,
422
670
  abortSignal: options.abortSignal,
423
671
  fetch: this.config.fetch,
424
- failedResponseHandler: createJsonErrorResponseHandler({
425
- errorSchema: z6.union([
426
- z6.object({ error: z6.object({ message: z6.string() }) }),
427
- z6.object({ message: z6.string() })
672
+ failedResponseHandler: createJsonErrorResponseHandler2({
673
+ errorSchema: z9.union([
674
+ z9.object({ error: z9.object({ message: z9.string() }) }),
675
+ z9.object({ message: z9.string() })
428
676
  ]),
429
677
  errorToMessage: (data) => "error" in data ? data.error.message : data.message
430
678
  }),
431
- successfulResponseHandler: createJsonResponseHandler(responseSchema)
679
+ successfulResponseHandler: createJsonResponseHandler2(responseSchema)
432
680
  });
433
681
  const phrases = (_c = value.phrases) != null ? _c : [];
434
682
  const languages = new Set(
@@ -464,22 +712,22 @@ var AzureSpeechTranscriptionModel = class {
464
712
  };
465
713
  }
466
714
  };
467
- var responseSchema = z6.object({
468
- combinedPhrases: z6.array(z6.object({ text: z6.string() })),
469
- durationMilliseconds: z6.number().nullish(),
470
- phrases: z6.array(
471
- z6.object({
472
- text: z6.string(),
473
- offsetMilliseconds: z6.number().nullish(),
474
- durationMilliseconds: z6.number().nullish(),
475
- locale: z6.string().nullish(),
476
- speaker: z6.number().nullish(),
477
- confidence: z6.number().nullish(),
478
- words: z6.array(
479
- z6.object({
480
- text: z6.string(),
481
- offsetMilliseconds: z6.number().nullish(),
482
- durationMilliseconds: z6.number().nullish()
715
+ var responseSchema = z9.object({
716
+ combinedPhrases: z9.array(z9.object({ text: z9.string() })),
717
+ durationMilliseconds: z9.number().nullish(),
718
+ phrases: z9.array(
719
+ z9.object({
720
+ text: z9.string(),
721
+ offsetMilliseconds: z9.number().nullish(),
722
+ durationMilliseconds: z9.number().nullish(),
723
+ locale: z9.string().nullish(),
724
+ speaker: z9.number().nullish(),
725
+ confidence: z9.number().nullish(),
726
+ words: z9.array(
727
+ z9.object({
728
+ text: z9.string(),
729
+ offsetMilliseconds: z9.number().nullish(),
730
+ durationMilliseconds: z9.number().nullish()
483
731
  })
484
732
  ).nullish()
485
733
  })
@@ -487,7 +735,7 @@ var responseSchema = z6.object({
487
735
  });
488
736
 
489
737
  // src/version.ts
490
- var VERSION = true ? "3.0.134" : "0.0.0-test";
738
+ var VERSION = true ? "3.0.136" : "0.0.0-test";
491
739
 
492
740
  // src/azure-openai-provider.ts
493
741
  function getAzureOpenAIBaseURLInfo(baseURL) {
@@ -522,7 +770,7 @@ function createAzure(options = {}) {
522
770
  [api === "speech" ? "Ocp-Apim-Subscription-Key" : "api-key"]: loadApiKey({
523
771
  apiKey: options.apiKey,
524
772
  environmentVariableName: "AZURE_API_KEY",
525
- description: api === "speech" ? "Azure Speech" : "Azure OpenAI"
773
+ description: api === "speech" ? "Azure Speech" : api === "mai" ? "Azure MAI" : "Azure OpenAI"
526
774
  })
527
775
  };
528
776
  return withUserAgentSuffix(
@@ -619,12 +867,24 @@ function createAzure(options = {}) {
619
867
  explicitMessageItemType: isFoundryProject,
620
868
  fileIdPrefixes: ["assistant-"]
621
869
  });
622
- const createImageModel = (modelId) => new OpenAIImageModel(modelId, {
623
- provider: "azure.image",
624
- url,
625
- headers: getHeaders,
626
- fetch
627
- });
870
+ const maiBaseURL = () => {
871
+ var _a2;
872
+ return (_a2 = withoutTrailingSlash(options.maiBaseURL)) != null ? _a2 : `https://${getResourceName()}.services.ai.azure.com/mai/v1`;
873
+ };
874
+ const createImageModel = (modelId) => new AzureImageModel(
875
+ modelId,
876
+ new OpenAIImageModel(modelId, {
877
+ provider: "azure.image",
878
+ url,
879
+ headers: getHeaders,
880
+ fetch
881
+ }),
882
+ new AzureMaiImageModel(modelId, {
883
+ url: (path) => `${maiBaseURL()}${path}`,
884
+ headers: () => getHeaders("mai"),
885
+ fetch
886
+ })
887
+ );
628
888
  const speechBaseURL = () => {
629
889
  var _a2;
630
890
  return (_a2 = withoutTrailingSlash(options.speechBaseURL)) != null ? _a2 : `https://${getResourceName()}.cognitiveservices.azure.com`;
@@ -762,6 +1022,44 @@ var AzureSpeechModel = class {
762
1022
  };
763
1023
  }
764
1024
  };
1025
+ var AzureImageModel = class {
1026
+ constructor(modelId, openai, mai) {
1027
+ this.modelId = modelId;
1028
+ this.openai = openai;
1029
+ this.mai = mai;
1030
+ this.specificationVersion = "v3";
1031
+ this.provider = "azure.image";
1032
+ }
1033
+ // The limit follows the default route; an `api` override is per request.
1034
+ get maxImagesPerCall() {
1035
+ return isMAIImageModel(this.modelId) ? this.mai.maxImagesPerCall : this.openai.maxImagesPerCall;
1036
+ }
1037
+ async doGenerate(options) {
1038
+ var _a;
1039
+ const { api, ...maiOptions } = (_a = await parseProviderOptions({
1040
+ provider: "azure",
1041
+ providerOptions: options.providerOptions,
1042
+ schema: azureImageModelOptions
1043
+ })) != null ? _a : {};
1044
+ if ((api != null ? api : isMAIImageModel(this.modelId) ? "mai" : "openai") === "mai") {
1045
+ return this.mai.doGenerate(options, maiOptions);
1046
+ }
1047
+ const result = await this.openai.doGenerate(options);
1048
+ return {
1049
+ ...result,
1050
+ warnings: [
1051
+ ...result.warnings,
1052
+ ...Object.entries(maiOptions).filter(([, value]) => value !== void 0).map(
1053
+ ([key]) => ({
1054
+ type: "unsupported",
1055
+ feature: `providerOptions.azure.${key}`,
1056
+ details: "This option requires the MAI image API."
1057
+ })
1058
+ )
1059
+ ]
1060
+ };
1061
+ }
1062
+ };
765
1063
  export {
766
1064
  VERSION,
767
1065
  azure,