@ai-sdk/azure 3.0.133 → 3.0.135

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.js CHANGED
@@ -30,7 +30,241 @@ module.exports = __toCommonJS(index_exports);
30
30
  var import_internal2 = require("@ai-sdk/openai/internal");
31
31
  var import_internal3 = require("@ai-sdk/deepseek/internal");
32
32
  var import_provider2 = require("@ai-sdk/provider");
33
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
33
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
34
+
35
+ // src/azure-image-model-options.ts
36
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
37
+ var import_v42 = require("zod/v4");
38
+
39
+ // src/azure-mai-image-model-options.ts
40
+ var import_provider_utils = require("@ai-sdk/provider-utils");
41
+ var import_v4 = require("zod/v4");
42
+ var azureMaiImageModelOptionsShape = () => ({
43
+ /**
44
+ * Let the model pick the output aspect ratio from the prompt and any
45
+ * reference images. MAI-Image-2.6 models only.
46
+ */
47
+ autoAspectRatio: import_v4.z.boolean().optional(),
48
+ /**
49
+ * Ground generation in Bing web search results. MAI-Image-2.6 models only.
50
+ */
51
+ webGrounding: import_v4.z.boolean().optional()
52
+ });
53
+ var azureMaiImageModelOptions = (0, import_provider_utils.lazySchema)(
54
+ () => (0, import_provider_utils.zodSchema)(import_v4.z.object(azureMaiImageModelOptionsShape()))
55
+ );
56
+
57
+ // src/azure-image-model-options.ts
58
+ var azureImageModelOptions = (0, import_provider_utils2.lazySchema)(
59
+ () => (0, import_provider_utils2.zodSchema)(
60
+ import_v42.z.object({
61
+ /**
62
+ * API to use. Defaults to MAI for MAI-Image models, OpenAI otherwise.
63
+ */
64
+ api: import_v42.z.enum(["openai", "mai"]).optional(),
65
+ ...azureMaiImageModelOptionsShape()
66
+ })
67
+ )
68
+ );
69
+ var maiImageModels = /* @__PURE__ */ new Set([
70
+ "mai-image-2.5",
71
+ "mai-image-2.5-flash",
72
+ "mai-image-2.5-pro",
73
+ "mai-image-2.6",
74
+ "mai-image-2.6-flash"
75
+ ]);
76
+ function isMAIImageModel(modelId) {
77
+ return maiImageModels.has(modelId.toLowerCase());
78
+ }
79
+
80
+ // src/azure-mai-image-model.ts
81
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
82
+ var import_v43 = require("zod/v4");
83
+ var MIN_SIDE = 768;
84
+ var DEFAULT_PIXELS = 1024 * 1024;
85
+ var AzureMaiImageModel = class {
86
+ constructor(modelId, config) {
87
+ this.modelId = modelId;
88
+ this.config = config;
89
+ this.specificationVersion = "v3";
90
+ this.provider = "azure.image";
91
+ this.maxImagesPerCall = 1;
92
+ }
93
+ async doGenerate({
94
+ prompt,
95
+ n,
96
+ size,
97
+ aspectRatio,
98
+ seed,
99
+ files,
100
+ mask,
101
+ headers,
102
+ abortSignal
103
+ }, { autoAspectRatio, webGrounding } = {}) {
104
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
105
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
106
+ const warnings = [];
107
+ if (seed != null) {
108
+ warnings.push({ type: "unsupported", feature: "seed" });
109
+ }
110
+ if (mask != null) {
111
+ warnings.push({
112
+ type: "unsupported",
113
+ feature: "mask",
114
+ details: "MAI image edits do not support masks."
115
+ });
116
+ }
117
+ let dimensions = parseSize(size);
118
+ if (size != null && aspectRatio != null) {
119
+ warnings.push({
120
+ type: "unsupported",
121
+ feature: "aspectRatio",
122
+ details: "aspectRatio is ignored when size is set."
123
+ });
124
+ } else if (aspectRatio != null) {
125
+ dimensions = dimensionsForAspectRatio(aspectRatio);
126
+ if (dimensions == null) {
127
+ warnings.push({
128
+ type: "unsupported",
129
+ feature: "aspectRatio",
130
+ details: `Invalid aspect ratio: ${aspectRatio}.`
131
+ });
132
+ }
133
+ }
134
+ const fields = {
135
+ model: this.modelId,
136
+ prompt,
137
+ width: dimensions == null ? void 0 : dimensions.width,
138
+ height: dimensions == null ? void 0 : dimensions.height,
139
+ auto_aspect_ratio: autoAspectRatio,
140
+ web_grounding: webGrounding
141
+ };
142
+ const requestOptions = {
143
+ headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), headers),
144
+ failedResponseHandler: maiFailedResponseHandler,
145
+ successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
146
+ maiImageResponseSchema
147
+ ),
148
+ abortSignal,
149
+ fetch: this.config.fetch
150
+ };
151
+ const images = files != null && files.length > 0 ? await Promise.all(files.map((file) => fileToBlob(file, abortSignal))) : void 0;
152
+ const responses = await Promise.all(
153
+ Array.from(
154
+ { length: Math.max(1, n) },
155
+ () => images != null ? (0, import_provider_utils3.postFormDataToApi)({
156
+ ...requestOptions,
157
+ url: this.config.url("/images/edits"),
158
+ formData: toFormData(fields, images)
159
+ }) : (0, import_provider_utils3.postJsonToApi)({
160
+ ...requestOptions,
161
+ url: this.config.url("/images/generations"),
162
+ body: fields
163
+ })
164
+ )
165
+ );
166
+ let usage;
167
+ const metadata = [];
168
+ for (const { value: response } of responses) {
169
+ const textTokens = (_e = (_d = response.usage) == null ? void 0 : _d.num_input_text_tokens) != null ? _e : void 0;
170
+ const imageTokens = (_g = (_f = response.usage) == null ? void 0 : _f.num_input_image_tokens) != null ? _g : void 0;
171
+ if (response.usage != null) {
172
+ const inputTokens = addTokens(textTokens, imageTokens);
173
+ const outputTokens = (_h = response.usage.num_output_tokens) != null ? _h : void 0;
174
+ usage = {
175
+ inputTokens: addTokens(usage == null ? void 0 : usage.inputTokens, inputTokens),
176
+ outputTokens: addTokens(usage == null ? void 0 : usage.outputTokens, outputTokens),
177
+ totalTokens: addTokens(
178
+ usage == null ? void 0 : usage.totalTokens,
179
+ addTokens(inputTokens, outputTokens)
180
+ )
181
+ };
182
+ }
183
+ metadata.push(
184
+ ...response.data.map(() => ({
185
+ ...response.created != null ? { created: response.created } : {},
186
+ ...response.size != null ? { size: response.size } : {},
187
+ ...textTokens != null ? { textTokens } : {},
188
+ ...imageTokens != null ? { imageTokens } : {}
189
+ }))
190
+ );
191
+ }
192
+ return {
193
+ images: responses.flatMap(
194
+ ({ value }) => value.data.map((item) => item.b64_json)
195
+ ),
196
+ warnings,
197
+ response: {
198
+ timestamp: currentDate,
199
+ modelId: this.modelId,
200
+ headers: (_i = responses[0]) == null ? void 0 : _i.responseHeaders
201
+ },
202
+ usage,
203
+ providerMetadata: { azure: { images: metadata } }
204
+ };
205
+ }
206
+ };
207
+ function addTokens(a, b) {
208
+ return a == null && b == null ? void 0 : (a != null ? a : 0) + (b != null ? b : 0);
209
+ }
210
+ function parseSize(size) {
211
+ if (size == null) return void 0;
212
+ const [width, height] = size.split("x").map(Number);
213
+ return { width, height };
214
+ }
215
+ function dimensionsForAspectRatio(aspectRatio) {
216
+ const [w, h] = aspectRatio.split(":").map(Number);
217
+ if (!(w > 0 && h > 0)) return void 0;
218
+ const ratio = w / h;
219
+ let width = Math.sqrt(DEFAULT_PIXELS * ratio);
220
+ let height = width / ratio;
221
+ if (Math.min(width, height) < MIN_SIDE) {
222
+ [width, height] = width < height ? [MIN_SIDE, MIN_SIDE / ratio] : [MIN_SIDE * ratio, MIN_SIDE];
223
+ }
224
+ const floor16 = (value) => Math.floor(value / 16 + 1e-9) * 16;
225
+ return {
226
+ width: Math.max(MIN_SIDE, floor16(width)),
227
+ height: Math.max(MIN_SIDE, floor16(height))
228
+ };
229
+ }
230
+ function toFormData(fields, images) {
231
+ const formData = new FormData();
232
+ for (const [key, value] of Object.entries(fields)) {
233
+ if (value != null) formData.append(key, String(value));
234
+ }
235
+ images.forEach((blob, index) => {
236
+ const extension = blob.type === "image/jpeg" ? "jpg" : "png";
237
+ formData.append("image", blob, `image-${index + 1}.${extension}`);
238
+ });
239
+ return formData;
240
+ }
241
+ async function fileToBlob(file, abortSignal) {
242
+ if (file.type === "url") {
243
+ return (0, import_provider_utils3.downloadBlob)(file.url, { abortSignal });
244
+ }
245
+ const data = file.data instanceof Uint8Array ? file.data : (0, import_provider_utils3.convertBase64ToUint8Array)(file.data);
246
+ return new Blob([data], { type: file.mediaType });
247
+ }
248
+ var maiErrorSchema = import_v43.z.object({
249
+ error: import_v43.z.object({
250
+ code: import_v43.z.union([import_v43.z.string(), import_v43.z.number()]).nullish(),
251
+ message: import_v43.z.string()
252
+ })
253
+ });
254
+ var maiFailedResponseHandler = (0, import_provider_utils3.createJsonErrorResponseHandler)({
255
+ errorSchema: maiErrorSchema,
256
+ errorToMessage: (data) => data.error.message
257
+ });
258
+ var maiImageResponseSchema = import_v43.z.object({
259
+ created: import_v43.z.number().nullish(),
260
+ size: import_v43.z.string().nullish(),
261
+ usage: import_v43.z.object({
262
+ num_input_text_tokens: import_v43.z.number().nullish(),
263
+ num_input_image_tokens: import_v43.z.number().nullish(),
264
+ num_output_tokens: import_v43.z.number().nullish()
265
+ }).nullish(),
266
+ data: import_v43.z.array(import_v43.z.object({ b64_json: import_v43.z.string() }))
267
+ });
34
268
 
35
269
  // src/azure-openai-tools.ts
36
270
  var import_internal = require("@ai-sdk/openai/internal");
@@ -43,35 +277,35 @@ var azureOpenaiTools = {
43
277
  };
44
278
 
45
279
  // src/azure-speech-model-options.ts
46
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
47
- var import_v42 = require("zod/v4");
280
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
281
+ var import_v45 = require("zod/v4");
48
282
 
49
283
  // src/azure-speech-speech-model-options.ts
50
- var import_provider_utils = require("@ai-sdk/provider-utils");
51
- var import_v4 = require("zod/v4");
284
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
285
+ var import_v44 = require("zod/v4");
52
286
  var azureSpeechSpeechModelOptionsShape = () => ({
53
287
  /**
54
288
  * Speaking style applied with `mstts:express-as`, e.g. `excited` or
55
289
  * `whispering`. Supported styles vary by voice.
56
290
  */
57
- style: import_v4.z.string().min(1).optional(),
291
+ style: import_v44.z.string().min(1).optional(),
58
292
  /**
59
293
  * Intensity of `style`, from 0.01 to 2. Azure defaults to 1.
60
294
  */
61
- styleDegree: import_v4.z.number().min(0.01).max(2).optional()
295
+ styleDegree: import_v44.z.number().min(0.01).max(2).optional()
62
296
  });
63
- var azureSpeechSpeechModelOptions = (0, import_provider_utils.lazySchema)(
64
- () => (0, import_provider_utils.zodSchema)(import_v4.z.strictObject(azureSpeechSpeechModelOptionsShape()))
297
+ var azureSpeechSpeechModelOptions = (0, import_provider_utils4.lazySchema)(
298
+ () => (0, import_provider_utils4.zodSchema)(import_v44.z.strictObject(azureSpeechSpeechModelOptionsShape()))
65
299
  );
66
300
 
67
301
  // src/azure-speech-model-options.ts
68
- var azureSpeechModelOptions = (0, import_provider_utils2.lazySchema)(
69
- () => (0, import_provider_utils2.zodSchema)(
70
- import_v42.z.strictObject({
302
+ var azureSpeechModelOptions = (0, import_provider_utils5.lazySchema)(
303
+ () => (0, import_provider_utils5.zodSchema)(
304
+ import_v45.z.strictObject({
71
305
  /**
72
306
  * API to use. Defaults to Speech for MAI-Voice models, OpenAI otherwise.
73
307
  */
74
- api: import_v42.z.enum(["openai", "speech"]).optional(),
308
+ api: import_v45.z.enum(["openai", "speech"]).optional(),
75
309
  ...azureSpeechSpeechModelOptionsShape()
76
310
  })
77
311
  )
@@ -88,8 +322,8 @@ function getMAIVoiceModel(modelId) {
88
322
 
89
323
  // src/azure-speech-speech-model.ts
90
324
  var import_provider = require("@ai-sdk/provider");
91
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
92
- var import_v43 = require("zod/v4");
325
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
326
+ var import_v46 = require("zod/v4");
93
327
  var DEFAULT_VOICE = "en-US-Harper";
94
328
  var DEFAULT_VOICES = /* @__PURE__ */ new Map([
95
329
  ["de", "de-DE-Mia"],
@@ -181,9 +415,9 @@ var AzureSpeechSpeechModel = class {
181
415
  value: audio,
182
416
  responseHeaders,
183
417
  rawValue
184
- } = await (0, import_provider_utils3.postToApi)({
418
+ } = await (0, import_provider_utils6.postToApi)({
185
419
  url: this.config.url(),
186
- headers: (0, import_provider_utils3.combineHeaders)(
420
+ headers: (0, import_provider_utils6.combineHeaders)(
187
421
  this.config.headers(),
188
422
  {
189
423
  "Content-Type": "application/ssml+xml",
@@ -193,7 +427,7 @@ var AzureSpeechSpeechModel = class {
193
427
  ),
194
428
  body: { content: ssml, values: ssml },
195
429
  failedResponseHandler,
196
- successfulResponseHandler: (0, import_provider_utils3.createBinaryResponseHandler)(),
430
+ successfulResponseHandler: (0, import_provider_utils6.createBinaryResponseHandler)(),
197
431
  abortSignal: options.abortSignal,
198
432
  fetch: this.config.fetch
199
433
  });
@@ -261,17 +495,17 @@ function resolveVoice(voice, language) {
261
495
  languageWarning: `The voice ${voice} selects the language. Language "${language}" was ignored.`
262
496
  } : { voice };
263
497
  }
264
- var errorSchema = import_v43.z.object({
265
- error: import_v43.z.object({ message: import_v43.z.string() })
498
+ var errorSchema = import_v46.z.object({
499
+ error: import_v46.z.object({ message: import_v46.z.string() })
266
500
  });
267
501
  var failedResponseHandler = async ({
268
502
  response,
269
503
  url,
270
504
  requestBodyValues
271
505
  }) => {
272
- const responseHeaders = (0, import_provider_utils3.extractResponseHeaders)(response);
506
+ const responseHeaders = (0, import_provider_utils6.extractResponseHeaders)(response);
273
507
  const responseBody = await response.text();
274
- const parsed = await (0, import_provider_utils3.safeParseJSON)({
508
+ const parsed = await (0, import_provider_utils6.safeParseJSON)({
275
509
  text: responseBody,
276
510
  schema: errorSchema
277
511
  });
@@ -283,7 +517,7 @@ var failedResponseHandler = async ({
283
517
  message,
284
518
  url,
285
519
  requestBodyValues,
286
- statusCode: response.status,
520
+ statusCode: isVoiceReset ? 400 : response.status,
287
521
  responseHeaders,
288
522
  responseBody,
289
523
  isRetryable: isVoiceReset ? false : void 0
@@ -292,53 +526,53 @@ var failedResponseHandler = async ({
292
526
  };
293
527
 
294
528
  // src/azure-speech-transcription-model.ts
295
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
296
- var import_v46 = require("zod/v4");
529
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
530
+ var import_v49 = require("zod/v4");
297
531
 
298
532
  // src/azure-transcription-model-options.ts
299
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
300
- var import_v45 = require("zod/v4");
533
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
534
+ var import_v48 = require("zod/v4");
301
535
 
302
536
  // src/azure-speech-transcription-model-options.ts
303
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
304
- var import_v44 = require("zod/v4");
537
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
538
+ var import_v47 = require("zod/v4");
305
539
  var azureSpeechTranscriptionModelOptionsShape = () => ({
306
540
  /**
307
541
  * Timing granularity. Defaults to `segment` so that transcription results
308
542
  * include timed segments (Azure's own default is `none`).
309
543
  */
310
- timestamps: import_v44.z.enum(["word", "segment", "none"]).optional(),
544
+ timestamps: import_v47.z.enum(["word", "segment", "none"]).optional(),
311
545
  /**
312
546
  * `verbatim` keeps fillers and false starts, `clean` removes them.
313
547
  * Azure defaults to `verbatim`.
314
548
  */
315
- transcribeStyle: import_v44.z.enum(["verbatim", "clean"]).optional(),
549
+ transcribeStyle: import_v47.z.enum(["verbatim", "clean"]).optional(),
316
550
  /**
317
551
  * Forces a single language, e.g. `['en']`. Omit for automatic language
318
552
  * detection and code switching.
319
553
  */
320
- locales: import_v44.z.array(import_v44.z.string()).length(1).optional(),
554
+ locales: import_v47.z.array(import_v47.z.string()).length(1).optional(),
321
555
  /**
322
556
  * Speaker diarization. Speaker IDs are available in provider metadata.
323
557
  */
324
- diarization: import_v44.z.strictObject({ enabled: import_v44.z.boolean() }).optional(),
558
+ diarization: import_v47.z.strictObject({ enabled: import_v47.z.boolean() }).optional(),
325
559
  /**
326
560
  * Keyword biasing for names and domain terminology.
327
561
  */
328
- phraseList: import_v44.z.strictObject({ phrases: import_v44.z.array(import_v44.z.string()) }).optional()
562
+ phraseList: import_v47.z.strictObject({ phrases: import_v47.z.array(import_v47.z.string()) }).optional()
329
563
  });
330
- var azureSpeechTranscriptionModelOptions = (0, import_provider_utils4.lazySchema)(
331
- () => (0, import_provider_utils4.zodSchema)(import_v44.z.strictObject(azureSpeechTranscriptionModelOptionsShape()))
564
+ var azureSpeechTranscriptionModelOptions = (0, import_provider_utils7.lazySchema)(
565
+ () => (0, import_provider_utils7.zodSchema)(import_v47.z.strictObject(azureSpeechTranscriptionModelOptionsShape()))
332
566
  );
333
567
 
334
568
  // src/azure-transcription-model-options.ts
335
- var azureTranscriptionModelOptions = (0, import_provider_utils5.lazySchema)(
336
- () => (0, import_provider_utils5.zodSchema)(
337
- import_v45.z.strictObject({
569
+ var azureTranscriptionModelOptions = (0, import_provider_utils8.lazySchema)(
570
+ () => (0, import_provider_utils8.zodSchema)(
571
+ import_v48.z.strictObject({
338
572
  /**
339
573
  * API to use. Defaults to Speech for MAI-Transcribe models, OpenAI otherwise.
340
574
  */
341
- api: import_v45.z.enum(["openai", "speech"]).optional(),
575
+ api: import_v48.z.enum(["openai", "speech"]).optional(),
342
576
  ...azureSpeechTranscriptionModelOptionsShape()
343
577
  })
344
578
  )
@@ -371,11 +605,11 @@ var AzureSpeechTranscriptionModel = class {
371
605
  "audio",
372
606
  new Blob(
373
607
  [
374
- typeof options.audio === "string" ? (0, import_provider_utils6.convertBase64ToUint8Array)(options.audio) : options.audio
608
+ typeof options.audio === "string" ? (0, import_provider_utils9.convertBase64ToUint8Array)(options.audio) : options.audio
375
609
  ],
376
610
  { type: options.mediaType }
377
611
  ),
378
- `audio.${(0, import_provider_utils6.mediaTypeToExtension)(options.mediaType)}`
612
+ `audio.${(0, import_provider_utils9.mediaTypeToExtension)(options.mediaType)}`
379
613
  );
380
614
  formData.append(
381
615
  "definition",
@@ -393,20 +627,20 @@ var AzureSpeechTranscriptionModel = class {
393
627
  phraseList: azureOptions.phraseList
394
628
  })
395
629
  );
396
- const { value, rawValue, responseHeaders } = await (0, import_provider_utils6.postFormDataToApi)({
630
+ const { value, rawValue, responseHeaders } = await (0, import_provider_utils9.postFormDataToApi)({
397
631
  url: this.config.url(),
398
- headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), options.headers),
632
+ headers: (0, import_provider_utils9.combineHeaders)(this.config.headers(), options.headers),
399
633
  formData,
400
634
  abortSignal: options.abortSignal,
401
635
  fetch: this.config.fetch,
402
- failedResponseHandler: (0, import_provider_utils6.createJsonErrorResponseHandler)({
403
- errorSchema: import_v46.z.union([
404
- import_v46.z.object({ error: import_v46.z.object({ message: import_v46.z.string() }) }),
405
- import_v46.z.object({ message: import_v46.z.string() })
636
+ failedResponseHandler: (0, import_provider_utils9.createJsonErrorResponseHandler)({
637
+ errorSchema: import_v49.z.union([
638
+ import_v49.z.object({ error: import_v49.z.object({ message: import_v49.z.string() }) }),
639
+ import_v49.z.object({ message: import_v49.z.string() })
406
640
  ]),
407
641
  errorToMessage: (data) => "error" in data ? data.error.message : data.message
408
642
  }),
409
- successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(responseSchema)
643
+ successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(responseSchema)
410
644
  });
411
645
  const phrases = (_c = value.phrases) != null ? _c : [];
412
646
  const languages = new Set(
@@ -442,22 +676,22 @@ var AzureSpeechTranscriptionModel = class {
442
676
  };
443
677
  }
444
678
  };
445
- var responseSchema = import_v46.z.object({
446
- combinedPhrases: import_v46.z.array(import_v46.z.object({ text: import_v46.z.string() })),
447
- durationMilliseconds: import_v46.z.number().nullish(),
448
- phrases: import_v46.z.array(
449
- import_v46.z.object({
450
- text: import_v46.z.string(),
451
- offsetMilliseconds: import_v46.z.number().nullish(),
452
- durationMilliseconds: import_v46.z.number().nullish(),
453
- locale: import_v46.z.string().nullish(),
454
- speaker: import_v46.z.number().nullish(),
455
- confidence: import_v46.z.number().nullish(),
456
- words: import_v46.z.array(
457
- import_v46.z.object({
458
- text: import_v46.z.string(),
459
- offsetMilliseconds: import_v46.z.number().nullish(),
460
- durationMilliseconds: import_v46.z.number().nullish()
679
+ var responseSchema = import_v49.z.object({
680
+ combinedPhrases: import_v49.z.array(import_v49.z.object({ text: import_v49.z.string() })),
681
+ durationMilliseconds: import_v49.z.number().nullish(),
682
+ phrases: import_v49.z.array(
683
+ import_v49.z.object({
684
+ text: import_v49.z.string(),
685
+ offsetMilliseconds: import_v49.z.number().nullish(),
686
+ durationMilliseconds: import_v49.z.number().nullish(),
687
+ locale: import_v49.z.string().nullish(),
688
+ speaker: import_v49.z.number().nullish(),
689
+ confidence: import_v49.z.number().nullish(),
690
+ words: import_v49.z.array(
691
+ import_v49.z.object({
692
+ text: import_v49.z.string(),
693
+ offsetMilliseconds: import_v49.z.number().nullish(),
694
+ durationMilliseconds: import_v49.z.number().nullish()
461
695
  })
462
696
  ).nullish()
463
697
  })
@@ -465,7 +699,7 @@ var responseSchema = import_v46.z.object({
465
699
  });
466
700
 
467
701
  // src/version.ts
468
- var VERSION = true ? "3.0.133" : "0.0.0-test";
702
+ var VERSION = true ? "3.0.135" : "0.0.0-test";
469
703
 
470
704
  // src/azure-openai-provider.ts
471
705
  function getAzureOpenAIBaseURLInfo(baseURL) {
@@ -497,13 +731,13 @@ function createAzure(options = {}) {
497
731
  }
498
732
  const getHeaders = (api = "openai") => {
499
733
  const authHeaders = tokenProvider ? {} : {
500
- [api === "speech" ? "Ocp-Apim-Subscription-Key" : "api-key"]: (0, import_provider_utils7.loadApiKey)({
734
+ [api === "speech" ? "Ocp-Apim-Subscription-Key" : "api-key"]: (0, import_provider_utils10.loadApiKey)({
501
735
  apiKey: options.apiKey,
502
736
  environmentVariableName: "AZURE_API_KEY",
503
- description: api === "speech" ? "Azure Speech" : "Azure OpenAI"
737
+ description: api === "speech" ? "Azure Speech" : api === "mai" ? "Azure MAI" : "Azure OpenAI"
504
738
  })
505
739
  };
506
- return (0, import_provider_utils7.withUserAgentSuffix)(
740
+ return (0, import_provider_utils10.withUserAgentSuffix)(
507
741
  {
508
742
  ...authHeaders,
509
743
  ...options.headers
@@ -513,7 +747,7 @@ function createAzure(options = {}) {
513
747
  };
514
748
  const fetch = tokenProvider ? async (input, init) => {
515
749
  var _a2;
516
- const headers = (0, import_provider_utils7.normalizeHeaders)(init == null ? void 0 : init.headers);
750
+ const headers = (0, import_provider_utils10.normalizeHeaders)(init == null ? void 0 : init.headers);
517
751
  if (headers.authorization == null) {
518
752
  headers.authorization = `Bearer ${await tokenProvider()}`;
519
753
  }
@@ -523,7 +757,7 @@ function createAzure(options = {}) {
523
757
  });
524
758
  } : options.fetch;
525
759
  const getResourceName = () => {
526
- const resourceName = (0, import_provider_utils7.loadSetting)({
760
+ const resourceName = (0, import_provider_utils10.loadSetting)({
527
761
  settingValue: options.resourceName,
528
762
  settingName: "resourceName",
529
763
  environmentVariableName: "AZURE_RESOURCE_NAME",
@@ -545,7 +779,7 @@ function createAzure(options = {}) {
545
779
  } = getAzureOpenAIBaseURLInfo(options.baseURL);
546
780
  const url = ({ path, modelId }) => {
547
781
  var _a2;
548
- const baseUrlPrefix = (0, import_provider_utils7.withoutTrailingSlash)(
782
+ const baseUrlPrefix = (0, import_provider_utils10.withoutTrailingSlash)(
549
783
  (_a2 = options.baseURL) != null ? _a2 : `https://${getResourceName()}.openai.azure.com/openai`
550
784
  );
551
785
  let fullUrl;
@@ -597,15 +831,27 @@ function createAzure(options = {}) {
597
831
  explicitMessageItemType: isFoundryProject,
598
832
  fileIdPrefixes: ["assistant-"]
599
833
  });
600
- const createImageModel = (modelId) => new import_internal2.OpenAIImageModel(modelId, {
601
- provider: "azure.image",
602
- url,
603
- headers: getHeaders,
604
- fetch
605
- });
834
+ const maiBaseURL = () => {
835
+ var _a2;
836
+ return (_a2 = (0, import_provider_utils10.withoutTrailingSlash)(options.maiBaseURL)) != null ? _a2 : `https://${getResourceName()}.services.ai.azure.com/mai/v1`;
837
+ };
838
+ const createImageModel = (modelId) => new AzureImageModel(
839
+ modelId,
840
+ new import_internal2.OpenAIImageModel(modelId, {
841
+ provider: "azure.image",
842
+ url,
843
+ headers: getHeaders,
844
+ fetch
845
+ }),
846
+ new AzureMaiImageModel(modelId, {
847
+ url: (path) => `${maiBaseURL()}${path}`,
848
+ headers: () => getHeaders("mai"),
849
+ fetch
850
+ })
851
+ );
606
852
  const speechBaseURL = () => {
607
853
  var _a2;
608
- return (_a2 = (0, import_provider_utils7.withoutTrailingSlash)(options.speechBaseURL)) != null ? _a2 : `https://${getResourceName()}.cognitiveservices.azure.com`;
854
+ return (_a2 = (0, import_provider_utils10.withoutTrailingSlash)(options.speechBaseURL)) != null ? _a2 : `https://${getResourceName()}.cognitiveservices.azure.com`;
609
855
  };
610
856
  const createTranscriptionModel = (modelId) => new AzureTranscriptionModel(
611
857
  modelId,
@@ -695,7 +941,7 @@ var AzureTranscriptionModel = class {
695
941
  }
696
942
  async getOptions(providerOptions) {
697
943
  var _a;
698
- const options = await (0, import_provider_utils7.parseProviderOptions)({
944
+ const options = await (0, import_provider_utils10.parseProviderOptions)({
699
945
  provider: "azure",
700
946
  providerOptions,
701
947
  schema: azureTranscriptionModelOptions
@@ -716,7 +962,7 @@ var AzureSpeechModel = class {
716
962
  }
717
963
  async doGenerate(options) {
718
964
  var _a;
719
- const { api, ...speechOptions } = (_a = await (0, import_provider_utils7.parseProviderOptions)({
965
+ const { api, ...speechOptions } = (_a = await (0, import_provider_utils10.parseProviderOptions)({
720
966
  provider: "azure",
721
967
  providerOptions: options.providerOptions,
722
968
  schema: azureSpeechModelOptions
@@ -740,6 +986,44 @@ var AzureSpeechModel = class {
740
986
  };
741
987
  }
742
988
  };
989
+ var AzureImageModel = class {
990
+ constructor(modelId, openai, mai) {
991
+ this.modelId = modelId;
992
+ this.openai = openai;
993
+ this.mai = mai;
994
+ this.specificationVersion = "v3";
995
+ this.provider = "azure.image";
996
+ }
997
+ // The limit follows the default route; an `api` override is per request.
998
+ get maxImagesPerCall() {
999
+ return isMAIImageModel(this.modelId) ? this.mai.maxImagesPerCall : this.openai.maxImagesPerCall;
1000
+ }
1001
+ async doGenerate(options) {
1002
+ var _a;
1003
+ const { api, ...maiOptions } = (_a = await (0, import_provider_utils10.parseProviderOptions)({
1004
+ provider: "azure",
1005
+ providerOptions: options.providerOptions,
1006
+ schema: azureImageModelOptions
1007
+ })) != null ? _a : {};
1008
+ if ((api != null ? api : isMAIImageModel(this.modelId) ? "mai" : "openai") === "mai") {
1009
+ return this.mai.doGenerate(options, maiOptions);
1010
+ }
1011
+ const result = await this.openai.doGenerate(options);
1012
+ return {
1013
+ ...result,
1014
+ warnings: [
1015
+ ...result.warnings,
1016
+ ...Object.entries(maiOptions).filter(([, value]) => value !== void 0).map(
1017
+ ([key]) => ({
1018
+ type: "unsupported",
1019
+ feature: `providerOptions.azure.${key}`,
1020
+ details: "This option requires the MAI image API."
1021
+ })
1022
+ )
1023
+ ]
1024
+ };
1025
+ }
1026
+ };
743
1027
  // Annotate the CommonJS export names for ESM import in node:
744
1028
  0 && (module.exports = {
745
1029
  VERSION,