@ai-sdk/azure 4.0.126 → 4.0.128
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/CHANGELOG.md +21 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -17
- package/dist/index.js.map +1 -1
- package/docs/04-azure.mdx +31 -6
- package/package.json +6 -6
- package/src/azure-image-model-options.ts +6 -0
- package/src/azure-mai-image-model-options.ts +9 -2
- package/src/azure-mai-image-model.ts +6 -1
- package/src/azure-model-catalog.ts +18 -7
- package/src/azure-openai-provider.ts +19 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @ai-sdk/azure
|
|
2
2
|
|
|
3
|
+
## 4.0.128
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [ed981f8]
|
|
8
|
+
- @ai-sdk/openai@4.0.120
|
|
9
|
+
|
|
10
|
+
## 4.0.127
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 3a48c5d: Add the MAI-Image-2.7 and MAI-Image-2.7-Flash image models and the `background` provider option (`'transparent'` or `'opaque'`) for MAI image generations and edits. On the MAI image API, `background: 'auto'` is not sent and produces a warning; OpenAI image deployments keep accepting it.
|
|
15
|
+
- Updated dependencies [5aa836f]
|
|
16
|
+
- Updated dependencies [10ff0b1]
|
|
17
|
+
- Updated dependencies [e878ab3]
|
|
18
|
+
- Updated dependencies [d99098a]
|
|
19
|
+
- @ai-sdk/openai@4.0.119
|
|
20
|
+
- @ai-sdk/provider@4.0.39
|
|
21
|
+
- @ai-sdk/provider-utils@5.0.82
|
|
22
|
+
- @ai-sdk/deepseek@3.0.88
|
|
23
|
+
|
|
3
24
|
## 4.0.126
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -202,6 +202,7 @@ export declare const VERSION: string;
|
|
|
202
202
|
//#endregion
|
|
203
203
|
//#region src/azure-image-model-options.d.ts
|
|
204
204
|
declare const azureImageModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
205
|
+
background?: "transparent" | "opaque" | "auto" | undefined;
|
|
205
206
|
autoAspectRatio?: boolean | undefined;
|
|
206
207
|
webGrounding?: boolean | undefined;
|
|
207
208
|
api?: "openai" | "mai" | undefined;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/azure-openai-tools.ts","../src/azure-openai-provider.ts","../src/azure-openai-provider-metadata.ts","../src/version.ts","../src/azure-image-model-options.ts","../src/azure-speech-model-options.ts","../src/azure-transcription-model-options.ts","../src/azure-transcription-provider-metadata.ts","../src/index.ts"],"mappings":";;;;;;cAYa;EACX,mBAAmB;EACnB,wBAAwB;EACxB,mBAAmB;EACnB,mBAAmB;EACnB,wBAAwB;EACxB,cAAc;EACd,mBAAmB;EACnB,kBAAkB;;;;EAIlB,yBAAyB;;;;UCwCV;;;;;EAKf;;UAGe,4BAA4B;;;;;GAMzC,sBACA,WAAW,mCACV;;;;;EAMH,cACE,sBACA,WAAW,mCACV;;;;;EAMH,KACE,sBACA,WAAW,mCACV;;;;EAKH,SAAS,uBAAuB;;;;;EAMhC,UACE,sBACA,WAAW,mCACV;;;;;EAMH,WACE,sBACA,WAAW,mCACV;;;;EAKH,UAAU,uBAAuB;;;;EAKjC,eAAe,uBAAuB;;;;EAKtC,cAAc,uBAAuB;;;;EAKrC,mBAAmB,uBAAuB;;;;;EAM1C,MAAM,uBAAuB;;;;EAK7B,WAAW,uBAAuB;;;;;;EAOlC,cAAc,uBAAuB;;;;EAKrC,mBAAmB,uBAAuB;;;;;EAM1C,OAAO,uBAAuB;;;;EAK9B,YAAY,uBAAuB;;;;EAKnC,cAAc;;UAGC;;;;;;;EAOf;;;;;;;;;EAUA;;;;EAKA,SAAS;;;;;;EAOT,uBAAuB;;;;EAKvB,UAAU;;;;;EAMV,QAAQ;;;;;EAMR;;;;;;EAOA;;;;;;;;EASA;;;;;EAMA;;;;;;;EAQA,YAAY;;;;;wBAgCE,YACd,UAAS,8BACR;;;;qBAgSU,OAAK;;;KC9jBN;EACV,OAAO;;KAGG;EACV,OAAO;;KAGG;EACV,OAAO;;KAGG;EACV,OAAO;;;;qBClBI;;;cCOA,yDAAsB
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/azure-openai-tools.ts","../src/azure-openai-provider.ts","../src/azure-openai-provider-metadata.ts","../src/version.ts","../src/azure-image-model-options.ts","../src/azure-speech-model-options.ts","../src/azure-transcription-model-options.ts","../src/azure-transcription-provider-metadata.ts","../src/index.ts"],"mappings":";;;;;;cAYa;EACX,mBAAmB;EACnB,wBAAwB;EACxB,mBAAmB;EACnB,mBAAmB;EACnB,wBAAwB;EACxB,cAAc;EACd,mBAAmB;EACnB,kBAAkB;;;;EAIlB,yBAAyB;;;;UCwCV;;;;;EAKf;;UAGe,4BAA4B;;;;;GAMzC,sBACA,WAAW,mCACV;;;;;EAMH,cACE,sBACA,WAAW,mCACV;;;;;EAMH,KACE,sBACA,WAAW,mCACV;;;;EAKH,SAAS,uBAAuB;;;;;EAMhC,UACE,sBACA,WAAW,mCACV;;;;;EAMH,WACE,sBACA,WAAW,mCACV;;;;EAKH,UAAU,uBAAuB;;;;EAKjC,eAAe,uBAAuB;;;;EAKtC,cAAc,uBAAuB;;;;EAKrC,mBAAmB,uBAAuB;;;;;EAM1C,MAAM,uBAAuB;;;;EAK7B,WAAW,uBAAuB;;;;;;EAOlC,cAAc,uBAAuB;;;;EAKrC,mBAAmB,uBAAuB;;;;;EAM1C,OAAO,uBAAuB;;;;EAK9B,YAAY,uBAAuB;;;;EAKnC,cAAc;;UAGC;;;;;;;EAOf;;;;;;;;;EAUA;;;;EAKA,SAAS;;;;;;EAOT,uBAAuB;;;;EAKvB,UAAU;;;;;EAMV,QAAQ;;;;;EAMR;;;;;;EAOA;;;;;;;;EASA;;;;;EAMA;;;;;;;EAQA,YAAY;;;;;wBAgCE,YACd,UAAS,8BACR;;;;qBAgSU,OAAK;;;KC9jBN;EACV,OAAO;;KAGG;EACV,OAAO;;KAGG;EACV,OAAO;;KAGG;EACV,OAAO;;;;qBClBI;;;cCOA,yDAAsB;;;;;;KAkBvB,yBAAyB,mBAAmB;;;cCjB3C,0DAAuB;;;;;;;KAcxB,0BAA0B,mBAC7B;;;cCdI,iEAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiB/B,iCAAiC,mBACpC;;;KC7BG;EACV;IACE,SAAS;MACP;MACA;MACA;MACA;MACA;MACA;MACA,QAAQ;QACN;QACA;QACA;;;;;;;YCVI,oCAAoC,KAC9C;;YAIU,2BAA2B"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { APICallError, InvalidArgumentError, UnsupportedFunctionalityError } fro
|
|
|
4
4
|
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertBase64ToUint8Array, convertToBase64, createBinaryResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, downloadBlob, extractResponseHeaders, isValidHostnamePart, lazySchema, loadApiKey, loadSetting, mediaTypeToExtension, normalizeHeaders, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, resolve, resolveWith, safeParseJSON, serializeModelOptions, toWebSocketUrl, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
//#region src/azure-model-catalog.ts
|
|
7
|
-
function imageEntry(webGrounding) {
|
|
7
|
+
function imageEntry({ webGrounding = false, background = false } = {}) {
|
|
8
8
|
return {
|
|
9
9
|
capabilities: { image: {
|
|
10
10
|
sizes: { description: "Sides must be multiples of 16 and at least 768 pixels." },
|
|
@@ -15,7 +15,8 @@ function imageEntry(webGrounding) {
|
|
|
15
15
|
providerOptions: { image: {
|
|
16
16
|
api: true,
|
|
17
17
|
autoAspectRatio: webGrounding,
|
|
18
|
-
webGrounding
|
|
18
|
+
webGrounding,
|
|
19
|
+
background
|
|
19
20
|
} },
|
|
20
21
|
requestConfig: { image: { api: "mai" } }
|
|
21
22
|
};
|
|
@@ -64,11 +65,19 @@ function transcriptionEntry(name, supportsTimestamps) {
|
|
|
64
65
|
* catalogs; arbitrary deployment names do not declare model-family support.
|
|
65
66
|
*/
|
|
66
67
|
const azureModelCatalog = {
|
|
67
|
-
"mai-image-2.5": imageEntry(
|
|
68
|
-
"mai-image-2.5-flash": imageEntry(
|
|
69
|
-
"mai-image-2.5-pro": imageEntry(
|
|
70
|
-
"mai-image-2.6": imageEntry(true),
|
|
71
|
-
"mai-image-2.6-flash": imageEntry(true),
|
|
68
|
+
"mai-image-2.5": imageEntry(),
|
|
69
|
+
"mai-image-2.5-flash": imageEntry(),
|
|
70
|
+
"mai-image-2.5-pro": imageEntry(),
|
|
71
|
+
"mai-image-2.6": imageEntry({ webGrounding: true }),
|
|
72
|
+
"mai-image-2.6-flash": imageEntry({ webGrounding: true }),
|
|
73
|
+
"mai-image-2.7": imageEntry({
|
|
74
|
+
webGrounding: true,
|
|
75
|
+
background: true
|
|
76
|
+
}),
|
|
77
|
+
"mai-image-2.7-flash": imageEntry({
|
|
78
|
+
webGrounding: true,
|
|
79
|
+
background: true
|
|
80
|
+
}),
|
|
72
81
|
"mai-voice-2.1-flash": speechEntry("MAI-Voice-2.1-Flash"),
|
|
73
82
|
"mai-voice-2.1": speechEntry("MAI-Voice-2.1"),
|
|
74
83
|
"mai-voice-2-flash": speechEntry("MAI-Voice-2-Flash"),
|
|
@@ -104,13 +113,19 @@ function getAzureModelEntry(modelId) {
|
|
|
104
113
|
const azureMaiImageModelOptionsShape = () => ({
|
|
105
114
|
/**
|
|
106
115
|
* Let the model pick the output aspect ratio from the prompt and any
|
|
107
|
-
* reference images. MAI-Image-2.6 models only.
|
|
116
|
+
* reference images. MAI-Image-2.6 and MAI-Image-2.7 models only.
|
|
108
117
|
*/
|
|
109
118
|
autoAspectRatio: z.boolean().optional(),
|
|
110
119
|
/**
|
|
111
|
-
* Ground generation in Bing web search results. MAI-Image-2.6
|
|
120
|
+
* Ground generation in Bing web search results. MAI-Image-2.6 and
|
|
121
|
+
* MAI-Image-2.7 models only.
|
|
112
122
|
*/
|
|
113
|
-
webGrounding: z.boolean().optional()
|
|
123
|
+
webGrounding: z.boolean().optional(),
|
|
124
|
+
/**
|
|
125
|
+
* Image background. `transparent` returns a PNG with an alpha channel;
|
|
126
|
+
* the API defaults to `opaque`. MAI-Image-2.7 models only.
|
|
127
|
+
*/
|
|
128
|
+
background: z.enum(["transparent", "opaque"]).optional()
|
|
114
129
|
});
|
|
115
130
|
lazySchema(() => zodSchema(z.object(azureMaiImageModelOptionsShape())));
|
|
116
131
|
//#endregion
|
|
@@ -120,7 +135,16 @@ const azureImageModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
120
135
|
* API to use. Defaults to MAI for MAI-Image models, OpenAI otherwise.
|
|
121
136
|
*/
|
|
122
137
|
api: z.enum(["openai", "mai"]).optional(),
|
|
123
|
-
...azureMaiImageModelOptionsShape()
|
|
138
|
+
...azureMaiImageModelOptionsShape(),
|
|
139
|
+
/**
|
|
140
|
+
* Image background. The MAI image API (MAI-Image-2.7 models) supports
|
|
141
|
+
* `transparent` and `opaque`; OpenAI image deployments also accept `auto`.
|
|
142
|
+
*/
|
|
143
|
+
background: z.enum([
|
|
144
|
+
"transparent",
|
|
145
|
+
"opaque",
|
|
146
|
+
"auto"
|
|
147
|
+
]).optional()
|
|
124
148
|
})));
|
|
125
149
|
function isMAIImageModel(modelId) {
|
|
126
150
|
return getAzureModelEntry(modelId)?.requestConfig?.image?.api === "mai";
|
|
@@ -143,7 +167,7 @@ var AzureMaiImageModel = class {
|
|
|
143
167
|
this.supportsFileInputs = true;
|
|
144
168
|
this.supportsMaskInputs = false;
|
|
145
169
|
}
|
|
146
|
-
async doGenerate({ prompt, n, size, aspectRatio, seed, files, mask, headers, abortSignal }, { autoAspectRatio, webGrounding } = {}) {
|
|
170
|
+
async doGenerate({ prompt, n, size, aspectRatio, seed, files, mask, headers, abortSignal }, { autoAspectRatio, webGrounding, background } = {}) {
|
|
147
171
|
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
148
172
|
const warnings = [];
|
|
149
173
|
if (seed != null) warnings.push({
|
|
@@ -175,7 +199,8 @@ var AzureMaiImageModel = class {
|
|
|
175
199
|
width: dimensions?.width,
|
|
176
200
|
height: dimensions?.height,
|
|
177
201
|
auto_aspect_ratio: autoAspectRatio,
|
|
178
|
-
web_grounding: webGrounding
|
|
202
|
+
web_grounding: webGrounding,
|
|
203
|
+
background
|
|
179
204
|
};
|
|
180
205
|
const requestOptions = {
|
|
181
206
|
headers: combineHeaders(await resolve(this.config.headers), headers),
|
|
@@ -898,7 +923,7 @@ const responseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
898
923
|
})));
|
|
899
924
|
//#endregion
|
|
900
925
|
//#region src/version.ts
|
|
901
|
-
const VERSION = "4.0.
|
|
926
|
+
const VERSION = "4.0.128";
|
|
902
927
|
//#endregion
|
|
903
928
|
//#region src/azure-openai-provider.ts
|
|
904
929
|
function getAzureOpenAIBaseURLInfo(baseURL) {
|
|
@@ -1210,16 +1235,30 @@ var AzureImageModel = class {
|
|
|
1210
1235
|
return createAzure(options.config).image(options.modelId);
|
|
1211
1236
|
}
|
|
1212
1237
|
async doGenerate(options) {
|
|
1213
|
-
const { api, ...
|
|
1238
|
+
const { api, background, ...maiOnlyOptions } = await parseProviderOptions({
|
|
1214
1239
|
provider: "azure",
|
|
1215
1240
|
providerOptions: options.providerOptions,
|
|
1216
1241
|
schema: azureImageModelOptions
|
|
1217
1242
|
}) ?? {};
|
|
1218
|
-
if ((api ?? (isMAIImageModel(this.modelId) ? "mai" : "openai")) === "mai")
|
|
1243
|
+
if ((api ?? (isMAIImageModel(this.modelId) ? "mai" : "openai")) === "mai") {
|
|
1244
|
+
if (background !== "auto") return this.mai.doGenerate(options, {
|
|
1245
|
+
...maiOnlyOptions,
|
|
1246
|
+
background
|
|
1247
|
+
});
|
|
1248
|
+
const result = await this.mai.doGenerate(options, maiOnlyOptions);
|
|
1249
|
+
return {
|
|
1250
|
+
...result,
|
|
1251
|
+
warnings: [...result.warnings, {
|
|
1252
|
+
type: "unsupported",
|
|
1253
|
+
feature: "providerOptions.azure.background",
|
|
1254
|
+
details: "The MAI image API supports 'transparent' and 'opaque' backgrounds."
|
|
1255
|
+
}]
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1219
1258
|
const result = await this.openai.doGenerate(withAzureOptionsForOpenAI(options, pickAzureOptions(options.providerOptions, options.files != null ? openaiImageModelEditOptionsShape() : openaiImageModelGenerationOptionsShape())));
|
|
1220
1259
|
return {
|
|
1221
1260
|
...result,
|
|
1222
|
-
warnings: [...result.warnings, ...unsupportedOptionWarnings(
|
|
1261
|
+
warnings: [...result.warnings, ...unsupportedOptionWarnings(maiOnlyOptions, "This option requires the MAI image API.")]
|
|
1223
1262
|
};
|
|
1224
1263
|
}
|
|
1225
1264
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/azure-model-catalog.ts","../src/azure-mai-image-model-options.ts","../src/azure-image-model-options.ts","../src/azure-mai-image-model.ts","../src/azure-mai-transcription-model.ts","../src/azure-openai-tools.ts","../src/azure-speech-speech-model-options.ts","../src/azure-speech-model-options.ts","../src/azure-speech-speech-model.ts","../src/azure-mai-transcription-model-options.ts","../src/azure-speech-transcription-model-options.ts","../src/azure-transcription-model-options.ts","../src/azure-speech-transcription-model.ts","../src/version.ts","../src/azure-openai-provider.ts"],"sourcesContent":["import type {\n ModelEntry,\n ProviderOptionDefinition,\n ProviderOptionDefinitions,\n} from '@ai-sdk/provider';\nimport type { AzureImageModelOptions } from './azure-image-model-options';\nimport type { AzureTranscriptionModelMaiOptions } from './azure-mai-transcription-model-options';\nimport type { AzureSpeechModelOptions } from './azure-speech-model-options';\nimport type { AzureSpeechModelSpeechOptions } from './azure-speech-speech-model-options';\nimport type { AzureTranscriptionModelSpeechOptions } from './azure-speech-transcription-model-options';\nimport type { AzureTranscriptionModelOptions } from './azure-transcription-model-options';\n\n/**\n * Azure-specific options; OpenAI-backed operations retain OpenAI's options,\n * which they also accept under `azure`.\n */\nexport const azureProviderOptions = {\n image: {\n api: { description: 'Select the OpenAI or MAI image API.' },\n autoAspectRatio: { description: 'Choose the aspect ratio automatically.' },\n webGrounding: { description: 'Ground image generation in web search.' },\n } satisfies Record<keyof AzureImageModelOptions, ProviderOptionDefinition>,\n speech: {\n api: { description: 'Select the OpenAI or Azure Speech API.' },\n style: { description: 'Speaking style supported by the selected voice.' },\n styleDegree: { description: 'Intensity of the speaking style.' },\n } satisfies Record<\n | ('api' & keyof AzureSpeechModelOptions)\n | keyof AzureSpeechModelSpeechOptions,\n ProviderOptionDefinition\n >,\n transcription: {\n api: { description: 'Select the OpenAI, Azure Speech, or MAI API.' },\n language: { description: 'Language hint for MAI streaming transcription.' },\n timestamps: { description: 'Word, segment, or no timestamps.' },\n transcribeStyle: { description: 'Verbatim or cleaned transcription.' },\n locales: { description: 'Language to use for transcription.' },\n diarization: { description: 'Enable speaker diarization.' },\n phraseList: { description: 'Phrases to bias transcription toward.' },\n } satisfies Record<\n | ('api' & keyof AzureTranscriptionModelOptions)\n | keyof AzureTranscriptionModelSpeechOptions\n | keyof AzureTranscriptionModelMaiOptions,\n ProviderOptionDefinition\n >,\n} as const satisfies ProviderOptionDefinitions;\n\ntype AzureRequestConfig = {\n image?: { api: 'mai' };\n speech?: { api: 'speech'; voiceModel: string };\n transcription?:\n | { api: 'speech'; name: string; supportsTimestamps: boolean }\n | { api: 'mai' };\n};\n\ntype AzureModelEntry = ModelEntry<AzureRequestConfig>;\n\nfunction imageEntry(webGrounding: boolean): AzureModelEntry {\n return {\n capabilities: {\n image: {\n sizes: {\n description: 'Sides must be multiples of 16 and at least 768 pixels.',\n },\n fileInput: true,\n maskInput: false,\n maxImagesPerCall: 1,\n },\n },\n providerOptions: {\n image: { api: true, autoAspectRatio: webGrounding, webGrounding },\n },\n requestConfig: { image: { api: 'mai' } },\n };\n}\n\nfunction speechEntry(voiceModel: string): AzureModelEntry {\n return {\n capabilities: { speech: { instructions: false } },\n providerOptions: {\n speech: {\n api: true,\n style: {\n condition: 'Supported styles depend on the selected voice and model.',\n },\n styleDegree: { condition: 'Requires a supported speaking style.' },\n },\n },\n requestConfig: { speech: { api: 'speech', voiceModel } },\n };\n}\n\nfunction transcriptionEntry(\n name: string,\n supportsTimestamps: boolean,\n): AzureModelEntry {\n return {\n capabilities: {\n transcription: {\n transcription: true,\n streaming: false,\n duration: true,\n segments: supportsTimestamps,\n language: true,\n },\n },\n providerOptions: {\n transcription: {\n api: true,\n language: { condition: 'Requires the MAI streaming API override.' },\n timestamps: supportsTimestamps\n ? true\n : { condition: 'Only none is supported.' },\n transcribeStyle: supportsTimestamps\n ? true\n : { condition: 'Only verbatim is supported.' },\n locales: true,\n diarization: supportsTimestamps,\n phraseList: true,\n },\n },\n requestConfig: {\n transcription: { api: 'speech', name, supportsTimestamps },\n },\n };\n}\n\n/**\n * Azure-owned models. OpenAI and DeepSeek deployments use their adapters' model\n * catalogs; arbitrary deployment names do not declare model-family support.\n */\nexport const azureModelCatalog: Readonly<Record<string, AzureModelEntry>> = {\n 'mai-image-2.5': imageEntry(false),\n 'mai-image-2.5-flash': imageEntry(false),\n 'mai-image-2.5-pro': imageEntry(false),\n 'mai-image-2.6': imageEntry(true),\n 'mai-image-2.6-flash': imageEntry(true),\n 'mai-voice-2.1-flash': speechEntry('MAI-Voice-2.1-Flash'),\n 'mai-voice-2.1': speechEntry('MAI-Voice-2.1'),\n 'mai-voice-2-flash': speechEntry('MAI-Voice-2-Flash'),\n 'mai-voice-2': speechEntry('MAI-Voice-2'),\n 'mai-transcribe-2': transcriptionEntry('MAI-Transcribe-2', true),\n 'mai-transcribe-1.5': transcriptionEntry('MAI-Transcribe-1.5', false),\n 'mai-transcribe-2-streaming': {\n capabilities: {\n transcription: {\n transcription: false,\n streaming: true,\n duration: {\n condition: 'Requires an audio format with a known byte rate.',\n },\n segments: false,\n language: { condition: 'Reports the configured language hint.' },\n },\n },\n providerOptions: {\n transcription: {\n api: true,\n language: true,\n timestamps: false,\n transcribeStyle: false,\n locales: false,\n diarization: false,\n phraseList: false,\n },\n },\n requestConfig: { transcription: { api: 'mai' } },\n },\n};\n\nexport function getAzureModelEntry(\n modelId: string,\n): AzureModelEntry | undefined {\n const id = modelId.toLowerCase();\n return Object.prototype.hasOwnProperty.call(azureModelCatalog, id)\n ? azureModelCatalog[id]\n : undefined;\n}\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const azureMaiImageModelOptionsShape = () => ({\n /**\n * Let the model pick the output aspect ratio from the prompt and any\n * reference images. MAI-Image-2.6 models only.\n */\n autoAspectRatio: z.boolean().optional(),\n\n /**\n * Ground generation in Bing web search results. MAI-Image-2.6 models only.\n */\n webGrounding: z.boolean().optional(),\n});\n\nexport const azureMaiImageModelOptions = lazySchema(() =>\n zodSchema(z.object(azureMaiImageModelOptionsShape())),\n);\n\nexport type AzureImageModelMaiOptions = InferSchema<\n typeof azureMaiImageModelOptions\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { getAzureModelEntry } from './azure-model-catalog';\nimport { azureMaiImageModelOptionsShape } from './azure-mai-image-model-options';\n\nexport const azureImageModelOptions = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * API to use. Defaults to MAI for MAI-Image models, OpenAI otherwise.\n */\n api: z.enum(['openai', 'mai']).optional(),\n ...azureMaiImageModelOptionsShape(),\n }),\n ),\n);\n\nexport type AzureImageModelOptions = InferSchema<typeof azureImageModelOptions>;\n\nexport function isMAIImageModel(modelId: string) {\n return getAzureModelEntry(modelId)?.requestConfig?.image?.api === 'mai';\n}\n","import type {\n ImageModelV4,\n ImageModelV4File,\n ImageModelV4Usage,\n SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n convertBase64ToUint8Array,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n downloadBlob,\n postFormDataToApi,\n postJsonToApi,\n resolve,\n type Resolvable,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { AzureImageModelMaiOptions } from './azure-mai-image-model-options';\n\n// MAI rejects either side below 768px; 1024x1024 is its default output.\nconst MIN_SIDE = 768;\nconst DEFAULT_PIXELS = 1024 * 1024;\n\n/**\n * MAI image generations and edits (`/mai/v1/images/*`) on Azure AI Foundry.\n * The API returns one PNG per request and takes `width`/`height`, not `size`.\n */\nexport class AzureMaiImageModel implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.image';\n readonly maxImagesPerCall = 1;\n readonly supportsFileInputs = true;\n readonly supportsMaskInputs = false;\n\n constructor(\n readonly modelId: string,\n private readonly config: {\n url: (path: string) => string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n /** Transport for untrusted file URLs, without provider authentication. */\n downloadFetch?: FetchFunction;\n _internal?: { currentDate?: () => Date };\n },\n ) {}\n\n async doGenerate(\n {\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n files,\n mask,\n headers,\n abortSignal,\n }: Parameters<ImageModelV4['doGenerate']>[0],\n { autoAspectRatio, webGrounding }: AzureImageModelMaiOptions = {},\n ): Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const warnings: SharedV4Warning[] = [];\n\n if (seed != null) {\n warnings.push({ type: 'unsupported', feature: 'seed' });\n }\n if (mask != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'mask',\n details: 'MAI image edits do not support masks.',\n });\n }\n\n let dimensions = parseSize(size);\n if (size != null && aspectRatio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: 'aspectRatio is ignored when size is set.',\n });\n } else if (aspectRatio != null) {\n dimensions = dimensionsForAspectRatio(aspectRatio);\n if (dimensions == null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: `Invalid aspect ratio: ${aspectRatio}.`,\n });\n }\n }\n\n const fields = {\n model: this.modelId,\n prompt,\n width: dimensions?.width,\n height: dimensions?.height,\n auto_aspect_ratio: autoAspectRatio,\n web_grounding: webGrounding,\n };\n const requestOptions = {\n headers: combineHeaders(await resolve(this.config.headers), headers),\n failedResponseHandler: maiFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n maiImageResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n };\n const images =\n files != null && files.length > 0\n ? await Promise.all(\n files.map(file =>\n fileToBlob(\n file,\n abortSignal,\n this.config.downloadFetch ?? this.config.fetch,\n ),\n ),\n )\n : undefined;\n\n // The API ignores `n`, so a call reached with n > 1 (e.g. through an\n // `api: 'mai'` override) sends one request per image.\n const responses = await Promise.all(\n Array.from({ length: Math.max(1, n) }, () =>\n images != null\n ? postFormDataToApi({\n ...requestOptions,\n url: this.config.url('/images/edits'),\n formData: toFormData(fields, images),\n })\n : postJsonToApi({\n ...requestOptions,\n url: this.config.url('/images/generations'),\n body: fields,\n }),\n ),\n );\n\n let usage: ImageModelV4Usage | undefined;\n const metadata: Array<Record<string, number | string>> = [];\n for (const { value: response } of responses) {\n const textTokens = response.usage?.num_input_text_tokens ?? undefined;\n const imageTokens = response.usage?.num_input_image_tokens ?? undefined;\n if (response.usage != null) {\n const inputTokens = addTokens(textTokens, imageTokens);\n const outputTokens = response.usage.num_output_tokens ?? undefined;\n usage = {\n inputTokens: addTokens(usage?.inputTokens, inputTokens),\n outputTokens: addTokens(usage?.outputTokens, outputTokens),\n totalTokens: addTokens(\n usage?.totalTokens,\n addTokens(inputTokens, outputTokens),\n ),\n };\n }\n metadata.push(\n ...response.data.map(() => ({\n ...(response.created != null ? { created: response.created } : {}),\n ...(response.size != null ? { size: response.size } : {}),\n ...(textTokens != null ? { textTokens } : {}),\n ...(imageTokens != null ? { imageTokens } : {}),\n })),\n );\n }\n\n return {\n images: responses.flatMap(({ value }) =>\n value.data.map(item => item.b64_json),\n ),\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responses[0]?.responseHeaders,\n },\n usage,\n providerMetadata: { azure: { images: metadata } },\n };\n }\n}\n\nfunction addTokens(a: number | undefined, b: number | undefined) {\n return a == null && b == null ? undefined : (a ?? 0) + (b ?? 0);\n}\n\nfunction parseSize(size: `${number}x${number}` | undefined) {\n if (size == null) return undefined;\n const [width, height] = size.split('x').map(Number);\n return { width, height };\n}\n\n// Keeps the default 1024x1024 pixel budget, raising the short side to 768.\nexport function dimensionsForAspectRatio(aspectRatio: string) {\n const [w, h] = aspectRatio.split(':').map(Number);\n if (!(w > 0 && h > 0)) return undefined;\n\n const ratio = w / h;\n let width = Math.sqrt(DEFAULT_PIXELS * ratio);\n let height = width / ratio;\n if (Math.min(width, height) < MIN_SIDE) {\n [width, height] =\n width < height\n ? [MIN_SIDE, MIN_SIDE / ratio]\n : [MIN_SIDE * ratio, MIN_SIDE];\n }\n\n const floor16 = (value: number) => Math.floor(value / 16 + 1e-9) * 16;\n return {\n width: Math.max(MIN_SIDE, floor16(width)),\n height: Math.max(MIN_SIDE, floor16(height)),\n };\n}\n\nfunction toFormData(\n fields: Record<string, string | number | boolean | undefined>,\n images: Blob[],\n) {\n const formData = new FormData();\n for (const [key, value] of Object.entries(fields)) {\n if (value != null) formData.append(key, String(value));\n }\n\n images.forEach((blob, index) => {\n const extension = blob.type === 'image/jpeg' ? 'jpg' : 'png';\n formData.append('image', blob, `image-${index + 1}.${extension}`);\n });\n return formData;\n}\n\nasync function fileToBlob(\n file: ImageModelV4File,\n abortSignal: AbortSignal | undefined,\n fetch: FetchFunction | undefined,\n): Promise<Blob> {\n if (file.type === 'url') {\n return downloadBlob(file.url, { abortSignal, fetch });\n }\n\n const data =\n file.data instanceof Uint8Array\n ? file.data\n : convertBase64ToUint8Array(file.data);\n return new Blob([data as BlobPart], { type: file.mediaType });\n}\n\nconst maiErrorSchema = lazySchema(() =>\n zodSchema(\n z.object({\n error: z.object({\n code: z.union([z.string(), z.number()]).nullish(),\n message: z.string(),\n }),\n }),\n ),\n);\n\nconst maiFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: maiErrorSchema,\n errorToMessage: data => data.error.message,\n});\n\n// Only the fields used here, to tolerate API additions.\nconst maiImageResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n created: z.number().nullish(),\n size: z.string().nullish(),\n usage: z\n .object({\n num_input_text_tokens: z.number().nullish(),\n num_input_image_tokens: z.number().nullish(),\n num_output_tokens: z.number().nullish(),\n })\n .nullish(),\n data: z.array(z.object({ b64_json: z.string() })),\n }),\n ),\n);\n","import {\n InvalidArgumentError,\n UnsupportedFunctionalityError,\n type Experimental_TranscriptionModelV4StreamPart as TranscriptionModelV4StreamPart,\n type SharedV4Warning,\n type TranscriptionModelV4,\n} from '@ai-sdk/provider';\nimport {\n connectToWebSocket,\n convertToBase64,\n safeParseJSON,\n toWebSocketUrl,\n waitForWebSocketBufferDrain,\n type WebSocketConnection,\n type WebSocketConstructor,\n type WebSocketLike,\n} from '@ai-sdk/provider-utils';\nimport type { AzureTranscriptionModelMaiOptions } from './azure-mai-transcription-model-options';\n\ntype StreamOptions = Parameters<\n NonNullable<TranscriptionModelV4['doStream']>\n>[0];\n\nconst SUPPORTED_SAMPLE_RATES = [16000, 24000];\nconst DEFAULT_SAMPLE_RATE = 24000;\n\n/**\n * MAI streaming transcription over the OpenAI Realtime-compatible\n * `/mai/v1/realtime` WebSocket. The model ID is the Foundry deployment name.\n */\nexport class AzureMaiTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.transcription';\n\n constructor(\n readonly modelId: string,\n private readonly config: {\n url: () => string;\n headers: () =>\n | Record<string, string | undefined>\n | PromiseLike<Record<string, string | undefined>>;\n webSocket?: WebSocketConstructor;\n _internal?: { currentDate?: () => Date };\n },\n ) {}\n\n async doGenerate(): Promise<\n Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>\n > {\n throw new UnsupportedFunctionalityError({\n functionality: `file transcription with ${this.modelId} (use streaming transcription)`,\n });\n }\n\n async doStream(\n options: StreamOptions,\n maiOptions: AzureTranscriptionModelMaiOptions = {},\n warnings: SharedV4Warning[] = [],\n ): Promise<\n Awaited<ReturnType<NonNullable<TranscriptionModelV4['doStream']>>>\n > {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { type, rate = DEFAULT_SAMPLE_RATE } = options.inputAudioFormat;\n if (type !== 'audio/pcm' || !SUPPORTED_SAMPLE_RATES.includes(rate)) {\n throw new InvalidArgumentError({\n argument: 'inputAudioFormat',\n message: `MAI streaming transcription requires 16-bit mono PCM (audio/pcm) at 16000 or 24000 Hz, got ${type}${options.inputAudioFormat.rate != null ? ` at ${rate} Hz` : ''}.`,\n });\n }\n\n const sessionUpdate = {\n type: 'session.update',\n session: {\n type: 'transcription',\n audio: {\n input: {\n format: { type: 'audio/pcm', rate },\n transcription: {\n model: this.modelId,\n ...(maiOptions.language != null\n ? { language: maiOptions.language }\n : {}),\n },\n // MAI supports neither server VAD nor noise reduction; the stream\n // commits once when the input audio ends.\n turn_detection: null,\n noise_reduction: null,\n },\n },\n },\n };\n\n const headers = {\n ...(await this.config.headers()),\n ...options.headers,\n };\n // Native WebSocket constructors drop headers, so bearer auth would be lost.\n if (\n this.config.webSocket == null &&\n Object.entries(headers).some(\n ([key, value]) =>\n key.toLowerCase() === 'authorization' && value != null,\n )\n ) {\n throw new InvalidArgumentError({\n argument: 'webSocket',\n message:\n 'MAI streaming transcription with Microsoft Entra ID (tokenProvider) or an Authorization header requires a custom webSocket implementation such as `ws`, because the native WebSocket cannot send headers.',\n });\n }\n\n return {\n request: { body: sessionUpdate },\n response: { timestamp: currentDate, modelId: this.modelId },\n stream: createMaiTranscriptionStream({\n ...getConnection({\n url: toWebSocketUrl(this.config.url()),\n headers,\n supportsHeaders: this.config.webSocket != null,\n }),\n webSocket: this.config.webSocket,\n sessionUpdate,\n bytesPerSecond: rate * 2,\n language: maiOptions.language,\n warnings,\n audio: options.audio,\n abortSignal: options.abortSignal,\n includeRawChunks: options.includeRawChunks,\n }),\n };\n }\n}\n\n// Native WebSocket constructors cannot send headers, so the key moves to the\n// `api-key` query parameter that MAI also accepts.\nfunction getConnection({\n url,\n headers,\n supportsHeaders,\n}: {\n url: URL;\n headers: Record<string, string | undefined>;\n supportsHeaders: boolean;\n}) {\n if (supportsHeaders) {\n return { url, headers };\n }\n const remaining: Record<string, string | undefined> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === 'api-key') {\n if (value != null) url.searchParams.set('api-key', value);\n } else {\n remaining[key] = value;\n }\n }\n return { url, headers: remaining };\n}\n\ntype MaiRealtimeEvent = {\n type?: string;\n item_id?: string;\n delta?: string;\n intermediate?: string;\n transcript?: string;\n error?: { message?: string; code?: string };\n};\n\nfunction createMaiTranscriptionStream({\n url,\n headers,\n webSocket,\n sessionUpdate,\n bytesPerSecond,\n language,\n warnings,\n audio,\n abortSignal,\n includeRawChunks,\n}: {\n url: URL;\n headers: Record<string, string | undefined>;\n webSocket: WebSocketConstructor | undefined;\n sessionUpdate: unknown;\n bytesPerSecond: number;\n language: string | undefined;\n warnings: SharedV4Warning[];\n audio: ReadableStream<Uint8Array | string>;\n abortSignal: AbortSignal | undefined;\n includeRawChunks: boolean | undefined;\n}) {\n let finished = false;\n let cleanup: (closeCode?: number) => void = () => {};\n\n return new ReadableStream<TranscriptionModelV4StreamPart>({\n start: controller => {\n let audioReader:\n | ReadableStreamDefaultReader<Uint8Array | string>\n | undefined;\n let connection: WebSocketConnection | undefined;\n let audioStarted = false;\n let committed = false;\n let audioBytes = 0;\n let deltas = '';\n\n cleanup = (closeCode?: number) => {\n if (audioReader != null) {\n void audioReader.cancel().catch(() => {});\n } else {\n void audio.cancel().catch(() => {});\n }\n connection?.close(closeCode);\n };\n\n const finishWithError = (error: unknown) => {\n if (finished) return;\n finished = true;\n cleanup();\n controller.error(error);\n };\n\n const finish = (text: string) => {\n if (finished) return;\n finished = true;\n controller.enqueue({\n type: 'finish',\n text,\n segments: [],\n language,\n ...(audioBytes > 0\n ? { durationInSeconds: audioBytes / bytesPerSecond }\n : {}),\n });\n controller.close();\n cleanup(1000);\n };\n\n const sendAudio = async (socket: WebSocketLike) => {\n audioReader = audio.getReader();\n try {\n while (true) {\n const { done, value } = await audioReader.read();\n if (done || finished) break;\n const base64 = convertToBase64(value);\n if (base64.length === 0) continue;\n audioBytes +=\n typeof value === 'string'\n ? base64ByteLength(base64)\n : value.byteLength;\n socket.send(\n JSON.stringify({\n type: 'input_audio_buffer.append',\n audio: base64,\n }),\n );\n await waitForWebSocketBufferDrain(socket);\n }\n } finally {\n audioReader.releaseLock();\n audioReader = undefined;\n }\n if (finished) return;\n if (audioBytes === 0) {\n finish('');\n return;\n }\n committed = true;\n socket.send(JSON.stringify({ type: 'input_audio_buffer.commit' }));\n };\n\n connection = connectToWebSocket({\n url,\n headers,\n webSocket,\n abortSignal,\n onAbort: finishWithError,\n onProcessingError: finishWithError,\n onOpen: () => {\n controller.enqueue({ type: 'stream-start', warnings });\n },\n onMessageText: async text => {\n const parsed = await safeParseJSON({ text });\n if (!parsed.success) return;\n const event = parsed.value as MaiRealtimeEvent;\n const socket = connection?.socket;\n\n if (includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: event });\n }\n\n switch (event.type) {\n case 'session.created': {\n socket?.send(JSON.stringify(sessionUpdate));\n break;\n }\n\n // Settings are locked after the first append, so audio waits for\n // the server to acknowledge the session configuration.\n case 'session.updated': {\n if (audioStarted || socket == null) break;\n audioStarted = true;\n void sendAudio(socket).catch(finishWithError);\n break;\n }\n\n case 'conversation.item.input_audio_transcription.delta': {\n deltas += event.delta ?? '';\n controller.enqueue({\n type: 'transcript-delta',\n id: event.item_id,\n delta: event.delta ?? '',\n });\n break;\n }\n\n // MAI-specific: the provisional text after the latest delta.\n case 'conversation.item.input_audio_transcription.intermediate': {\n controller.enqueue({\n type: 'transcript-partial',\n id: event.item_id,\n text: event.intermediate ?? '',\n });\n break;\n }\n\n case 'conversation.item.input_audio_transcription.completed': {\n const transcript = event.transcript ?? deltas;\n controller.enqueue({\n type: 'transcript-final',\n id: event.item_id,\n text: transcript,\n });\n if (committed) finish(transcript);\n break;\n }\n\n case 'conversation.item.input_audio_transcription.failed':\n case 'error': {\n finishWithError(\n new Error(\n `Azure MAI transcription error${event.error?.code != null ? ` (${event.error.code})` : ''}: ${event.error?.message ?? 'unknown error'}`,\n ),\n );\n break;\n }\n }\n },\n onSocketError: () => {\n finishWithError(new Error('Azure MAI transcription WebSocket error'));\n },\n onClose: ({ code, reason }) => {\n finishWithError(\n new Error(\n `Azure MAI transcription connection closed before the transcript completed${code != null ? ` (code ${code}${reason ? `: ${reason}` : ''})` : ''}`,\n ),\n );\n },\n });\n },\n\n cancel: () => {\n if (finished) return;\n finished = true;\n cleanup();\n },\n });\n}\n\nfunction base64ByteLength(base64: string) {\n const padding = base64.endsWith('==') ? 2 : base64.endsWith('=') ? 1 : 0;\n return (base64.length * 3) / 4 - padding;\n}\n","import {\n applyPatch,\n codeInterpreter,\n customTool,\n fileSearch,\n imageGeneration,\n shell,\n toolSearch,\n webSearch,\n webSearchPreview,\n} from '@ai-sdk/openai/internal';\n\nexport const azureOpenaiTools: {\n applyPatch: typeof applyPatch;\n codeInterpreter: typeof codeInterpreter;\n customTool: typeof customTool;\n fileSearch: typeof fileSearch;\n imageGeneration: typeof imageGeneration;\n shell: typeof shell;\n toolSearch: typeof toolSearch;\n webSearch: typeof webSearch;\n /**\n * @deprecated Use `webSearch` instead.\n */\n webSearchPreview: typeof webSearchPreview;\n} = {\n applyPatch,\n codeInterpreter,\n customTool,\n fileSearch,\n imageGeneration,\n shell,\n toolSearch,\n webSearch,\n webSearchPreview,\n};\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const azureSpeechSpeechModelOptionsShape = () => ({\n /**\n * Speaking style applied with `mstts:express-as`, e.g. `excited` or\n * `whispering`. Supported styles vary by voice.\n */\n style: z.string().min(1).optional(),\n\n /**\n * Intensity of `style`, from 0.01 to 2. Azure defaults to 1.\n */\n styleDegree: z.number().min(0.01).max(2).optional(),\n});\n\nexport const azureSpeechSpeechModelOptions = lazySchema(() =>\n zodSchema(z.strictObject(azureSpeechSpeechModelOptionsShape())),\n);\n\nexport type AzureSpeechModelSpeechOptions = InferSchema<\n typeof azureSpeechSpeechModelOptions\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { openaiSpeechModelOptionsShape } from '@ai-sdk/openai/internal';\nimport { z } from 'zod/v4';\nimport { getAzureModelEntry } from './azure-model-catalog';\nimport { azureSpeechSpeechModelOptionsShape } from './azure-speech-speech-model-options';\n\nexport const azureSpeechModelOptions = lazySchema(() =>\n zodSchema(\n z.strictObject({\n /**\n * API to use. Defaults to Speech for MAI-Voice models, OpenAI otherwise.\n */\n api: z.enum(['openai', 'speech']).optional(),\n // OpenAI API options for Azure OpenAI deployments.\n ...openaiSpeechModelOptionsShape(),\n ...azureSpeechSpeechModelOptionsShape(),\n }),\n ),\n);\n\nexport type AzureSpeechModelOptions = InferSchema<\n typeof azureSpeechModelOptions\n>;\n\nexport function getMAIVoiceModel(modelId: string) {\n return getAzureModelEntry(modelId)?.requestConfig?.speech?.voiceModel;\n}\n","import {\n APICallError,\n type SharedV4Warning,\n type SpeechModelV4,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n createBinaryResponseHandler,\n extractResponseHeaders,\n postToApi,\n safeParseJSON,\n resolve,\n type Resolvable,\n type FetchFunction,\n type ResponseHandler,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { getMAIVoiceModel } from './azure-speech-model-options';\nimport type { AzureSpeechModelSpeechOptions } from './azure-speech-speech-model-options';\n\nconst DEFAULT_VOICE = 'en-US-Harper';\n\n// Default voice per ISO 639-1 language; available on MAI-Voice-2,\n// MAI-Voice-2.1, and their Flash variants.\nconst DEFAULT_VOICES = new Map([\n ['de', 'de-DE-Mia'],\n ['en', DEFAULT_VOICE],\n ['es', 'es-MX-Valeria'],\n ['fr', 'fr-FR-Soleil'],\n ['hi', 'hi-IN-Kavya'],\n ['hu', 'hu-HU-Lilla'],\n ['it', 'it-IT-Rosa'],\n ['ko', 'ko-KR-Haena'],\n ['nl', 'nl-NL-Fleur'],\n ['pt', 'pt-BR-Luana'],\n ['ro', 'ro-RO-Elena'],\n ['ru', 'ru-RU-Masha'],\n ['th', 'th-TH-Krit'],\n ['tr', 'tr-TR-Elif'],\n ['zh', 'zh-CN-Mei'],\n]);\nconst DEFAULT_OUTPUT_FORMAT = 'audio-24khz-160kbitrate-mono-mp3';\n\n// Shorthand formats for `outputFormat`; other X-Microsoft-OutputFormat values\n// (e.g. `audio-48khz-192kbitrate-mono-mp3`) are passed through unchanged.\nconst OUTPUT_FORMATS = new Map([\n ['mp3', DEFAULT_OUTPUT_FORMAT],\n ['opus', 'ogg-24khz-16bit-mono-opus'],\n ['pcm', 'raw-24khz-16bit-mono-pcm'],\n ['wav', 'riff-24khz-16bit-mono-pcm'],\n]);\nconst NATIVE_OUTPUT_FORMAT =\n /^(?:amr|audio|g722|ogg|raw|riff|webm)-[a-z0-9-]+$/;\n\n/**\n * Azure Speech text to speech with SSML. The model is appended to the voice\n * name, e.g. `en-US-Harper:MAI-Voice-2`.\n */\nexport class AzureSpeechSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.speech';\n\n constructor(\n readonly modelId: string,\n private readonly config: {\n url: () => string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n _internal?: { currentDate?: () => Date };\n },\n ) {}\n\n async doGenerate(\n options: Parameters<SpeechModelV4['doGenerate']>[0],\n azureOptions: AzureSpeechModelSpeechOptions = {},\n ): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const warnings: SharedV4Warning[] = [];\n const { style, styleDegree } = azureOptions;\n\n if (options.instructions != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'instructions',\n details: 'Use providerOptions.azure.style to control speaking style.',\n });\n }\n const { voice, languageWarning } = resolveVoice(\n options.voice,\n options.language,\n );\n if (languageWarning != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'language',\n details: languageWarning,\n });\n }\n if (styleDegree != null && style == null) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions.azure.styleDegree',\n details: 'styleDegree requires style.',\n });\n }\n\n let outputFormat = DEFAULT_OUTPUT_FORMAT;\n if (options.outputFormat != null) {\n const format = options.outputFormat.toLowerCase();\n const shorthand = OUTPUT_FORMATS.get(format);\n if (shorthand != null) {\n outputFormat = shorthand;\n } else if (NATIVE_OUTPUT_FORMAT.test(format)) {\n outputFormat = format;\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'outputFormat',\n details: `Unsupported output format: ${options.outputFormat}. Using mp3 instead.`,\n });\n }\n }\n\n const ssml = buildSsml({\n text: options.text,\n voiceName: voice.includes(':')\n ? voice\n : `${voice}:${getMAIVoiceModel(this.modelId) ?? this.modelId}`,\n locale: /^([a-z]{2,3}-[a-z]{2,4})-/i.exec(voice)?.[1],\n speed: options.speed,\n style,\n styleDegree: style != null ? styleDegree : undefined,\n });\n\n const {\n value: audio,\n responseHeaders,\n rawValue,\n } = await postToApi({\n url: this.config.url(),\n headers: combineHeaders(\n await resolve(this.config.headers),\n {\n 'Content-Type': 'application/ssml+xml',\n 'X-Microsoft-OutputFormat': outputFormat,\n },\n options.headers,\n ),\n body: { content: ssml, values: ssml },\n failedResponseHandler,\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n audio,\n warnings,\n request: { body: ssml },\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawValue,\n },\n };\n }\n}\n\nfunction buildSsml({\n text,\n voiceName,\n locale = 'en-US',\n speed,\n style,\n styleDegree,\n}: {\n text: string;\n voiceName: string;\n locale?: string;\n speed?: number;\n style?: string;\n styleDegree?: number;\n}) {\n let content = escapeXml(text);\n if (speed != null) {\n content = `<prosody rate=\"${speed}\">${content}</prosody>`;\n }\n if (style != null) {\n const degree = styleDegree != null ? ` styledegree=\"${styleDegree}\"` : '';\n content = `<mstts:express-as style=\"${escapeXml(style)}\"${degree}>${content}</mstts:express-as>`;\n }\n return (\n `<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" ` +\n `xmlns:mstts=\"http://www.w3.org/2001/mstts\" xml:lang=\"${escapeXml(locale)}\">` +\n `<voice name=\"${escapeXml(voiceName)}\">${content}</voice></speak>`\n );\n}\n\nconst XML_ESCAPES: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n};\n\nfunction escapeXml(value: string) {\n return value.replace(/[&<>\"']/g, char => XML_ESCAPES[char]);\n}\n\n// Uses the language's default voice when no voice is set. An explicit voice\n// wins, and its locale selects the language.\nfunction resolveVoice(\n voice: string | undefined,\n language: string | undefined,\n): { voice: string; languageWarning?: string } {\n const code = language ? language.split('-')[0].toLowerCase() : undefined;\n if (voice == null) {\n if (code == null) return { voice: DEFAULT_VOICE };\n if (code === 'auto') {\n return {\n voice: DEFAULT_VOICE,\n languageWarning: `Automatic language detection is not supported. ${DEFAULT_VOICE} was used.`,\n };\n }\n const defaultVoice = DEFAULT_VOICES.get(code);\n return defaultVoice != null\n ? { voice: defaultVoice }\n : {\n voice: DEFAULT_VOICE,\n languageWarning: `No default MAI voice for language \"${language}\". ${DEFAULT_VOICE} was used.`,\n };\n }\n const voiceLanguage = /^([a-z]{2,3})-[a-z]{2,4}-/i\n .exec(voice)?.[1]\n ?.toLowerCase();\n return code != null &&\n code !== 'auto' &&\n voiceLanguage != null &&\n code !== voiceLanguage\n ? {\n voice,\n languageWarning: `The voice ${voice} selects the language. Language \"${language}\" was ignored.`,\n }\n : { voice };\n}\n\nconst errorSchema = lazySchema(() =>\n zodSchema(\n z.object({\n error: z.object({ message: z.string() }),\n }),\n ),\n);\n\n// Azure Speech answers invalid requests (unknown voice, unsupported style, or\n// output format) with an empty 400 body.\nconst failedResponseHandler: ResponseHandler<APICallError> = async ({\n response,\n url,\n requestBodyValues,\n}) => {\n const responseHeaders = extractResponseHeaders(response);\n const responseBody = await response.text();\n const parsed = await safeParseJSON({\n text: responseBody,\n schema: errorSchema,\n });\n const message = parsed.success\n ? parsed.value.error.message\n : response.status === 400\n ? 'Azure Speech request failed with status 400. Check the voice name, style, and output format.'\n : `Azure Speech request failed with status ${response.status}.`;\n\n return {\n responseHeaders,\n value: new APICallError({\n message,\n url,\n requestBodyValues,\n statusCode: response.status,\n responseHeaders,\n responseBody,\n }),\n };\n};\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const azureMaiTranscriptionModelOptionsShape = () => ({\n /**\n * Language hint for streaming transcription, e.g. `en`. Omit for automatic\n * language detection.\n */\n language: z.string().min(1).optional(),\n});\n\nexport const azureMaiTranscriptionModelOptions = lazySchema(() =>\n zodSchema(z.strictObject(azureMaiTranscriptionModelOptionsShape())),\n);\n\nexport type AzureTranscriptionModelMaiOptions = InferSchema<\n typeof azureMaiTranscriptionModelOptions\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// Strict objects reject unknown keys (e.g. `diarization.maxSpeakers`, which\n// MAI-Transcribe-2 does not support) instead of silently dropping them.\nexport const azureSpeechTranscriptionModelOptionsShape = () => ({\n /**\n * Timing granularity. Defaults to `segment` so that transcription results\n * include timed segments (Azure's own default is `none`).\n */\n timestamps: z.enum(['word', 'segment', 'none']).optional(),\n\n /**\n * `verbatim` keeps fillers and false starts, `clean` removes them.\n * Azure defaults to `verbatim`.\n */\n transcribeStyle: z.enum(['verbatim', 'clean']).optional(),\n\n /**\n * Forces a single language, e.g. `['en']`. Omit for automatic language\n * detection and code switching.\n */\n locales: z.array(z.string()).length(1).optional(),\n\n /**\n * Speaker diarization. Speaker IDs are available in provider metadata.\n */\n diarization: z.strictObject({ enabled: z.boolean() }).optional(),\n\n /**\n * Keyword biasing for names and domain terminology.\n */\n phraseList: z.strictObject({ phrases: z.array(z.string()) }).optional(),\n});\n\nexport const azureSpeechTranscriptionModelOptions = lazySchema(() =>\n zodSchema(z.strictObject(azureSpeechTranscriptionModelOptionsShape())),\n);\n\nexport type AzureTranscriptionModelSpeechOptions = InferSchema<\n typeof azureSpeechTranscriptionModelOptions\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { openAITranscriptionModelOptionsShape } from '@ai-sdk/openai/internal';\nimport { z } from 'zod/v4';\nimport { getAzureModelEntry } from './azure-model-catalog';\nimport { azureMaiTranscriptionModelOptionsShape } from './azure-mai-transcription-model-options';\nimport { azureSpeechTranscriptionModelOptionsShape } from './azure-speech-transcription-model-options';\n\nexport const azureTranscriptionModelOptions = lazySchema(() =>\n zodSchema(\n z.strictObject({\n /**\n * API to use. Defaults to Speech for MAI-Transcribe models, MAI for\n * MAI-Transcribe-2-Streaming, and OpenAI otherwise.\n */\n api: z.enum(['openai', 'speech', 'mai']).optional(),\n // OpenAI API options for Azure OpenAI deployments. Listed first so the\n // shared `language` key keeps the MAI validation.\n ...openAITranscriptionModelOptionsShape(),\n ...azureSpeechTranscriptionModelOptionsShape(),\n ...azureMaiTranscriptionModelOptionsShape(),\n }),\n ),\n);\n\nexport type AzureTranscriptionModelOptions = InferSchema<\n typeof azureTranscriptionModelOptions\n>;\n\nexport function getMAITranscribeModel(modelId: string) {\n const config = getAzureModelEntry(modelId)?.requestConfig?.transcription;\n return config?.api === 'speech'\n ? { name: config.name, supportsTimestamps: config.supportsTimestamps }\n : undefined;\n}\n\nexport function isMAITranscribeStreaming(modelId: string): boolean {\n return (\n getAzureModelEntry(modelId)?.requestConfig?.transcription?.api === 'mai'\n );\n}\n","import type { SharedV4Warning, TranscriptionModelV4 } from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n convertBase64ToUint8Array,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n mediaTypeToExtension,\n postFormDataToApi,\n resolve,\n type Resolvable,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { AzureTranscriptionProviderMetadata } from './azure-transcription-provider-metadata';\nimport type { AzureTranscriptionModelSpeechOptions } from './azure-speech-transcription-model-options';\nimport { getMAITranscribeModel } from './azure-transcription-model-options';\n\nexport class AzureSpeechTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.transcription';\n\n constructor(\n readonly modelId: string,\n private readonly config: {\n url: () => string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n },\n ) {}\n\n async doGenerate(\n options: Parameters<TranscriptionModelV4['doGenerate']>[0],\n azureOptions: AzureTranscriptionModelSpeechOptions = {},\n ): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {\n const timestamp = new Date();\n const maiModel = getMAITranscribeModel(this.modelId);\n const warnings: SharedV4Warning[] = [];\n let timestamps = azureOptions.timestamps;\n if (options.timestampGranularities != null) {\n const wantsWord = options.timestampGranularities.includes('word');\n const wantsSegment = options.timestampGranularities.includes('segment');\n if (\n maiModel?.supportsTimestamps === false &&\n (wantsWord || wantsSegment)\n ) {\n warnings.push({\n type: 'unsupported',\n feature: 'timestampGranularities',\n details: `${maiModel.name} cannot return word or segment timings.`,\n });\n } else if (timestamps == null) {\n if (wantsWord) {\n timestamps = 'word';\n } else if (wantsSegment) {\n timestamps = 'segment';\n }\n } else if (\n (wantsWord && timestamps !== 'word') ||\n (wantsSegment && timestamps === 'none')\n ) {\n warnings.push({\n type: 'unsupported',\n feature: 'timestampGranularities',\n details: `providerOptions.azure.timestamps is \"${timestamps}\" and overrides the requested timestamp granularities.`,\n });\n }\n }\n const formData = new FormData();\n formData.append(\n 'audio',\n new Blob(\n [\n typeof options.audio === 'string'\n ? convertBase64ToUint8Array(options.audio)\n : (options.audio as Uint8Array<ArrayBuffer>),\n ],\n { type: options.mediaType },\n ),\n `audio.${mediaTypeToExtension(options.mediaType)}`,\n );\n formData.append(\n 'definition',\n JSON.stringify({\n enhancedMode: {\n enabled: true,\n model: maiModel?.name ?? this.modelId,\n modelOptions: {\n timestamps:\n timestamps ??\n (maiModel?.supportsTimestamps === false ? undefined : 'segment'),\n transcribeStyle: azureOptions.transcribeStyle,\n },\n },\n locales: azureOptions.locales,\n diarization: azureOptions.diarization,\n phraseList: azureOptions.phraseList,\n }),\n );\n\n const { value, rawValue, responseHeaders } = await postFormDataToApi({\n url: this.config.url(),\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n formData,\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: z.union([\n z.object({ error: z.object({ message: z.string() }) }),\n z.object({ message: z.string() }),\n ]),\n errorToMessage: data =>\n 'error' in data ? data.error.message : data.message,\n }),\n successfulResponseHandler: createJsonResponseHandler(responseSchema),\n });\n\n const phrases = value.phrases ?? [];\n // Consider every reported locale so mixed results (e.g. en + fil) are not\n // collapsed to one language; only ISO-639-1 codes are reported.\n const languages = new Set(\n phrases.flatMap(phrase =>\n phrase.locale ? [phrase.locale.split('-')[0].toLowerCase()] : [],\n ),\n );\n const [language] = languages;\n const reportedLanguage =\n languages.size === 1 && /^[a-z]{2}$/.test(language)\n ? language\n : undefined;\n\n const words = phrases.flatMap(phrase =>\n (phrase.words ?? []).flatMap(word =>\n word.offsetMilliseconds != null && word.durationMilliseconds != null\n ? [\n {\n text: word.text,\n startSecond: word.offsetMilliseconds / 1000,\n endSecond:\n (word.offsetMilliseconds + word.durationMilliseconds) / 1000,\n },\n ]\n : [],\n ),\n );\n\n return {\n text: value.combinedPhrases.map(phrase => phrase.text).join(' '),\n ...(words.length > 0 ? { words } : {}),\n segments: phrases.flatMap(phrase =>\n phrase.offsetMilliseconds != null && phrase.durationMilliseconds != null\n ? [\n {\n text: phrase.text,\n startSecond: phrase.offsetMilliseconds / 1000,\n endSecond:\n (phrase.offsetMilliseconds + phrase.durationMilliseconds) /\n 1000,\n },\n ]\n : [],\n ),\n language: reportedLanguage,\n durationInSeconds:\n value.durationMilliseconds != null\n ? value.durationMilliseconds / 1000\n : undefined,\n warnings,\n providerMetadata: {\n azure: { phrases },\n } satisfies AzureTranscriptionProviderMetadata,\n response: {\n timestamp,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawValue,\n },\n };\n }\n}\n\nconst responseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n combinedPhrases: z.array(z.object({ text: z.string() })),\n durationMilliseconds: z.number().nullish(),\n phrases: z\n .array(\n z.object({\n text: z.string(),\n offsetMilliseconds: z.number().nullish(),\n durationMilliseconds: z.number().nullish(),\n locale: z.string().nullish(),\n speaker: z.number().nullish(),\n confidence: z.number().nullish(),\n words: z\n .array(\n z.object({\n text: z.string(),\n offsetMilliseconds: z.number().nullish(),\n durationMilliseconds: z.number().nullish(),\n }),\n )\n .nullish(),\n }),\n )\n .nullish(),\n }),\n ),\n);\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAISpeechModel,\n OpenAITranscriptionModel,\n openaiImageModelEditOptionsShape,\n openaiImageModelGenerationOptionsShape,\n openaiSpeechModelOptionsShape,\n openAITranscriptionModelOptionsShape,\n} from '@ai-sdk/openai/internal';\nimport { DeepSeekChatLanguageModel } from '@ai-sdk/deepseek/internal';\nimport {\n InvalidArgumentError,\n UnsupportedFunctionalityError,\n type EmbeddingModelV4,\n type LanguageModelV4,\n type ProviderV4,\n type ImageModelV4,\n type SharedV4ProviderOptions,\n type SharedV4Warning,\n type SpeechModelV4,\n type TranscriptionModelV4,\n} from '@ai-sdk/provider';\nimport {\n isValidHostnamePart,\n loadApiKey,\n loadSetting,\n normalizeHeaders,\n parseProviderOptions,\n resolveWith,\n serializeModelOptions,\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n type Resolvable,\n type WebSocketConstructor,\n} from '@ai-sdk/provider-utils';\nimport {\n azureImageModelOptions,\n isMAIImageModel,\n} from './azure-image-model-options';\nimport { AzureMaiImageModel } from './azure-mai-image-model';\nimport { AzureMaiTranscriptionModel } from './azure-mai-transcription-model';\nimport { azureOpenaiTools } from './azure-openai-tools';\nimport {\n azureSpeechModelOptions,\n getMAIVoiceModel,\n} from './azure-speech-model-options';\nimport { azureSpeechSpeechModelOptionsShape } from './azure-speech-speech-model-options';\nimport { AzureSpeechSpeechModel } from './azure-speech-speech-model';\nimport { AzureSpeechTranscriptionModel } from './azure-speech-transcription-model';\nimport { azureSpeechTranscriptionModelOptionsShape } from './azure-speech-transcription-model-options';\nimport {\n azureTranscriptionModelOptions,\n getMAITranscribeModel,\n isMAITranscribeStreaming,\n} from './azure-transcription-model-options';\nimport { VERSION } from './version';\n\nexport interface AzureOpenAILanguageModelSettings {\n /**\n * Underlying model ID used for reported identity and capability detection.\n * Defaults to the deployment ID. Requests always use the deployment ID.\n */\n modelId?: string;\n}\n\nexport interface AzureOpenAIProvider extends ProviderV4 {\n /**\n * Creates a Responses API model. The optional model ID is used for reported\n * identity and capability detection; requests always use the deployment ID.\n */\n (\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI responses API model for text generation.\n * The optional model ID is used for reported identity and capability detection.\n */\n languageModel(\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI chat model for text generation.\n * The optional model ID is used for reported identity and capability detection.\n */\n chat(\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ): LanguageModelV4;\n\n /**\n * Creates an Azure-hosted DeepSeek chat model for text generation.\n */\n deepseek(deploymentId: string): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI responses API model for text generation.\n * The optional model ID is used for reported identity and capability detection.\n */\n responses(\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI completion model for text generation.\n * The optional model ID is used for reported identity.\n */\n completion(\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI model for text embeddings.\n */\n embedding(deploymentId: string): EmbeddingModelV4;\n\n /**\n * Creates an Azure OpenAI model for text embeddings.\n */\n embeddingModel(deploymentId: string): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embedding` instead.\n */\n textEmbedding(deploymentId: string): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(deploymentId: string): EmbeddingModelV4;\n\n /**\n * Creates an Azure image model. MAI-Image models use the MAI image API by\n * default; other IDs use OpenAI. Override with providerOptions.azure.api.\n */\n image(deploymentId: string): ImageModelV4;\n\n /**\n * Creates an Azure image model. Alias of `image`.\n */\n imageModel(deploymentId: string): ImageModelV4;\n\n /**\n * Creates an Azure transcription model. MAI-Transcribe models use the Speech\n * API and MAI-Transcribe-2-Streaming the MAI realtime API by default; other\n * IDs use OpenAI. Override with providerOptions.azure.api.\n */\n transcription(deploymentId: string): TranscriptionModelV4;\n\n /**\n * Creates an Azure transcription model. Alias of `transcription`.\n */\n transcriptionModel(deploymentId: string): TranscriptionModelV4;\n\n /**\n * Creates an Azure speech generation model. MAI-Voice models use the Speech\n * API by default; other IDs use OpenAI. Override with providerOptions.azure.api.\n */\n speech(deploymentId: string): SpeechModelV4;\n\n /**\n * Creates an Azure speech generation model. Alias of `speech`.\n */\n speechModel(deploymentId: string): SpeechModelV4;\n\n /**\n * AzureOpenAI-specific tools.\n */\n tools: typeof azureOpenaiTools;\n}\n\nexport interface AzureOpenAIProviderSettings {\n /**\n * Name of the Azure OpenAI resource. Either this or `baseURL` can be used.\n *\n * The resource name is used in the assembled URL: `https://{resourceName}.openai.azure.com/openai/v1{path}`.\n * It must be a single DNS label (letters, digits, and hyphens).\n */\n resourceName?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers. Either this or `resourceName` can be used.\n * When a baseURL is provided, the resourceName is ignored.\n *\n * With an unversioned Azure OpenAI baseURL, the resolved URL is `{baseURL}/v1{path}`.\n * Azure OpenAI base URLs that already end in `/openai/v1` are used as-is.\n * With a non-Azure custom gateway baseURL, the resolved URL is `{baseURL}{path}`.\n */\n baseURL?: string;\n\n /**\n * API key for authenticating requests. A callback is resolved before each request.\n */\n apiKey?: Resolvable<string>;\n\n /**\n * A function that returns an access token for Microsoft Entra\n * (formerly known as Azure Active Directory), which will be invoked\n * on every request.\n */\n tokenProvider?: (() => Promise<string>) | undefined;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n\n /**\n * Custom api version to use. Defaults to `v1`.\n * Complete v1 base URLs are used as-is.\n */\n apiVersion?: string;\n\n /**\n * Use deployment-based URLs for specific model types. Set to true to use legacy deployment format:\n * `{baseURL}/deployments/{deploymentId}{path}?api-version={apiVersion}` instead of\n * `{baseURL}/v1{path}?api-version={apiVersion}`.\n */\n useDeploymentBasedUrls?: boolean;\n\n /**\n * URL prefix for Azure Speech (MAI-Transcribe transcription and MAI-Voice\n * speech), e.g. a regional endpoint like\n * `https://eastus.api.cognitive.microsoft.com`.\n * Defaults to `https://{resourceName}.cognitiveservices.azure.com`.\n * Speech requests do not use `baseURL` or `apiVersion`.\n */\n speechBaseURL?: string;\n\n /**\n * URL prefix for MAI APIs (MAI-Image, MAI-Transcribe-2-Streaming). Defaults\n * to `https://{resourceName}.services.ai.azure.com/mai/v1`.\n */\n maiBaseURL?: string;\n\n /**\n * Custom WebSocket implementation for MAI streaming transcription, e.g.\n * `ws` in Node.js. With a custom implementation the API key is sent as a\n * header; otherwise it is sent as the `api-key` query parameter. Entra ID\n * tokens require a custom implementation; streaming rejects them otherwise.\n */\n webSocket?: WebSocketConstructor;\n}\n\nfunction getAzureOpenAIBaseURLInfo(baseURL: string | undefined) {\n if (baseURL == null) {\n return {\n isAzureOpenAI: true,\n isFoundryProject: false,\n isVersioned: false,\n };\n }\n\n const url = new URL(baseURL);\n const hostname = url.hostname;\n const isAzureOpenAI =\n hostname.endsWith('.openai.azure.com') ||\n hostname.endsWith('.services.ai.azure.com') ||\n hostname.endsWith('.cognitiveservices.azure.com');\n const pathname = url.pathname.replace(/\\/+$/, '');\n\n return {\n isAzureOpenAI,\n isFoundryProject:\n hostname.endsWith('.services.ai.azure.com') &&\n pathname.startsWith('/api/projects/'),\n isVersioned: isAzureOpenAI && pathname.toLowerCase().endsWith('/openai/v1'),\n };\n}\n\n/**\n * Create an Azure OpenAI provider instance.\n */\nexport function createAzure(\n options: AzureOpenAIProviderSettings = {},\n): AzureOpenAIProvider {\n const tokenProvider = options.tokenProvider;\n\n if (options.apiKey && tokenProvider) {\n throw new InvalidArgumentError({\n argument: 'apiKey/tokenProvider',\n message:\n 'Both apiKey and tokenProvider were provided. Please use only one authentication method.',\n });\n }\n\n const getHeaders = (api: 'openai' | 'speech' | 'mai' = 'openai') =>\n resolveWith(tokenProvider ? undefined : options.apiKey, apiKey => {\n const authHeaders = tokenProvider\n ? {}\n : {\n [api === 'speech' ? 'Ocp-Apim-Subscription-Key' : 'api-key']:\n loadApiKey({\n apiKey,\n environmentVariableName: 'AZURE_API_KEY',\n description:\n api === 'speech'\n ? 'Azure Speech'\n : api === 'mai'\n ? 'Azure MAI'\n : 'Azure OpenAI',\n }),\n };\n\n return withUserAgentSuffix(\n {\n ...authHeaders,\n ...options.headers,\n },\n `ai-sdk-azure/${VERSION}`,\n );\n });\n\n const fetch: FetchFunction | undefined = tokenProvider\n ? async (input, init) => {\n const headers = normalizeHeaders(init?.headers);\n\n if (headers.authorization == null) {\n headers.authorization = `Bearer ${await tokenProvider()}`;\n }\n\n return (options.fetch ?? globalThis.fetch)(input, {\n ...init,\n headers,\n });\n }\n : options.fetch;\n\n const getResourceName = () => {\n const resourceName = loadSetting({\n settingValue: options.resourceName,\n settingName: 'resourceName',\n environmentVariableName: 'AZURE_RESOURCE_NAME',\n description: 'Azure OpenAI resource name',\n });\n\n // The resource name becomes part of the request host, so only a DNS label\n // is accepted (e.g. `user@internal:8080/#` would rewrite the host).\n if (!isValidHostnamePart(resourceName)) {\n throw new InvalidArgumentError({\n argument: 'resourceName',\n message:\n 'Invalid Azure resource name. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',\n });\n }\n\n return resourceName;\n };\n\n const apiVersion = options.apiVersion ?? 'v1';\n const {\n isAzureOpenAI,\n isFoundryProject,\n isVersioned: isAzureOpenAIVersioned,\n } = getAzureOpenAIBaseURLInfo(options.baseURL);\n\n const url = ({ path, modelId }: { path: string; modelId: string }) => {\n const baseUrlPrefix = withoutTrailingSlash(\n options.baseURL ?? `https://${getResourceName()}.openai.azure.com/openai`,\n );\n\n let fullUrl: URL;\n if (options.useDeploymentBasedUrls) {\n // Use deployment-based format for compatibility with certain Azure OpenAI models\n fullUrl = new URL(`${baseUrlPrefix}/deployments/${modelId}${path}`);\n } else if (!isAzureOpenAI || isAzureOpenAIVersioned) {\n // Custom gateways can own Azure routing and versioning themselves.\n // Complete Azure OpenAI v1 URLs also own their versioning.\n fullUrl = new URL(`${baseUrlPrefix}${path}`);\n } else {\n // Use v1 API format - no deployment ID in URL\n fullUrl = new URL(`${baseUrlPrefix}/v1${path}`);\n }\n\n if (\n options.useDeploymentBasedUrls ||\n (isAzureOpenAI && !isAzureOpenAIVersioned && !isFoundryProject)\n ) {\n fullUrl.searchParams.set('api-version', apiVersion);\n }\n\n return fullUrl.toString();\n };\n\n const createChatModel = (\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ) =>\n new OpenAIChatLanguageModel(settings?.modelId ?? deploymentId, {\n provider: 'azure.chat',\n requestModelId: deploymentId,\n url,\n headers: getHeaders,\n fetch,\n });\n\n const createDeepSeekModel = (deploymentName: string) =>\n new DeepSeekChatLanguageModel(deploymentName, {\n provider: 'azure.deepseek',\n url,\n headers: getHeaders,\n fetch,\n supportsPenaltySampling: true,\n supportsThinking: false,\n // json_object with thinking enabled makes Azure return the JSON in reasoning_content with empty content\n supportsStructuredOutputs: true,\n });\n\n const createCompletionModel = (\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ) =>\n new OpenAICompletionLanguageModel(settings?.modelId ?? deploymentId, {\n provider: 'azure.completion',\n requestModelId: deploymentId,\n url,\n headers: getHeaders,\n fetch,\n });\n\n const createEmbeddingModel = (modelId: string) =>\n new OpenAIEmbeddingModel(modelId, {\n provider: 'azure.embeddings',\n headers: getHeaders,\n url,\n fetch,\n });\n\n const createResponsesModel = (\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ) =>\n new OpenAIResponsesLanguageModel(settings?.modelId ?? deploymentId, {\n provider: 'azure.responses',\n requestModelId: deploymentId,\n url,\n headers: getHeaders,\n fetch,\n explicitMessageItemType: isFoundryProject,\n // Soft-deprecated. TODO: remove in v8\n fileIdPrefixes: ['assistant-'],\n });\n\n const maiBaseURL = () =>\n withoutTrailingSlash(options.maiBaseURL) ??\n `https://${getResourceName()}.services.ai.azure.com/mai/v1`;\n\n // Always provide a raw delegate, including when no custom fetch is set, so\n // file downloads cannot fall back to the token-injecting API fetch wrapper.\n const downloadFetch: FetchFunction = (input, init) =>\n (options.fetch ?? globalThis.fetch)(input, init);\n\n const createImageModel = (modelId: string) =>\n new AzureImageModel(\n modelId,\n options,\n new OpenAIImageModel(modelId, {\n provider: 'azure.image',\n url,\n headers: getHeaders,\n fetch,\n downloadFetch,\n // Azure model IDs are user-defined deployment names, so OpenAI model\n // family capabilities cannot be inferred from them.\n imageInputCapabilities: {\n supportsFileInputs: undefined,\n supportsMaskInputs: undefined,\n },\n }),\n new AzureMaiImageModel(modelId, {\n url: path => `${maiBaseURL()}${path}`,\n headers: () => getHeaders('mai'),\n fetch,\n downloadFetch,\n }),\n );\n\n const speechBaseURL = () =>\n withoutTrailingSlash(options.speechBaseURL) ??\n `https://${getResourceName()}.cognitiveservices.azure.com`;\n\n const createTranscriptionModel = (modelId: string) =>\n new AzureTranscriptionModel(\n modelId,\n options,\n new OpenAITranscriptionModel(modelId, {\n provider: 'azure.transcription',\n url,\n headers: getHeaders,\n fetch,\n }),\n new AzureSpeechTranscriptionModel(modelId, {\n url: () =>\n `${speechBaseURL()}/speechtotext/transcriptions:transcribe?api-version=2025-10-15`,\n headers: () => getHeaders('speech'),\n fetch,\n }),\n new AzureMaiTranscriptionModel(modelId, {\n url: () => `${maiBaseURL()}/realtime?intent=transcription`,\n headers: async () =>\n tokenProvider\n ? {\n authorization: `Bearer ${await tokenProvider()}`,\n ...(await getHeaders('mai')),\n }\n : getHeaders('mai'),\n webSocket: options.webSocket,\n }),\n );\n\n const createSpeechModel = (modelId: string) =>\n new AzureSpeechModel(\n modelId,\n options,\n new OpenAISpeechModel(modelId, {\n provider: 'azure.speech',\n url,\n headers: getHeaders,\n fetch,\n }),\n new AzureSpeechSpeechModel(modelId, {\n url: () => `${speechBaseURL()}/tts/cognitiveservices/v1`,\n headers: () => getHeaders('speech'),\n fetch,\n }),\n );\n\n const provider = function (\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ) {\n if (new.target) {\n throw new Error(\n 'The Azure OpenAI model function cannot be called with the new keyword.',\n );\n }\n\n return createResponsesModel(deploymentId, settings);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createResponsesModel;\n provider.chat = createChatModel;\n provider.deepseek = createDeepSeekModel;\n provider.completion = createCompletionModel;\n provider.embedding = createEmbeddingModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.responses = createResponsesModel;\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n provider.tools = azureOpenaiTools;\n return provider;\n}\n\n/**\n * Default Azure OpenAI provider instance.\n */\nexport const azure = createAzure();\n\n// Resolves the API per request: providerOptions also reach this model via Gateway.\nclass AzureTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.transcription';\n\n constructor(\n readonly modelId: string,\n private readonly config: AzureOpenAIProviderSettings,\n private readonly openai: OpenAITranscriptionModel,\n private readonly speech: AzureSpeechTranscriptionModel,\n private readonly mai: AzureMaiTranscriptionModel,\n ) {}\n\n static [WORKFLOW_SERIALIZE](model: AzureTranscriptionModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: string;\n config: AzureOpenAIProviderSettings;\n }) {\n return createAzure(options.config).transcription(options.modelId);\n }\n\n async doGenerate(options: Parameters<TranscriptionModelV4['doGenerate']>[0]) {\n const { api, speechOptions, maiOptions, openaiOptions } =\n await this.getOptions(options.providerOptions);\n if (api === 'mai') {\n return this.mai.doGenerate();\n }\n if (api === 'speech') {\n const result = await this.speech.doGenerate(options, speechOptions);\n return {\n ...result,\n warnings: [\n ...result.warnings,\n ...maiOnlyWarnings(maiOptions),\n ...openaiTranscriptionOnlyWarnings(openaiOptions),\n ],\n };\n }\n\n const result = await this.openai.doGenerate(\n withAzureOptionsForOpenAI(options, openaiOptions),\n );\n return {\n ...result,\n warnings: [...result.warnings, ...speechOnlyWarnings(speechOptions)],\n };\n }\n\n async doStream(\n options: Parameters<NonNullable<TranscriptionModelV4['doStream']>>[0],\n ) {\n const { api, speechOptions, maiOptions, openaiOptions } =\n await this.getOptions(options.providerOptions);\n if (api === 'speech') {\n throw new UnsupportedFunctionalityError({\n functionality: 'streaming transcription with the Azure Speech API',\n });\n }\n if (api === 'mai') {\n return this.mai.doStream(options, maiOptions, [\n ...speechOnlyWarnings(speechOptions),\n ...openaiTranscriptionOnlyWarnings(openaiOptions),\n ]);\n }\n return this.openai.doStream(\n withAzureOptionsForOpenAI(options, openaiOptions),\n );\n }\n\n private async getOptions(\n providerOptions: Parameters<\n TranscriptionModelV4['doGenerate']\n >[0]['providerOptions'],\n ) {\n const { api, language, ...options } =\n (await parseProviderOptions({\n provider: 'azure',\n providerOptions,\n schema: azureTranscriptionModelOptions,\n })) ?? {};\n return {\n api:\n api ??\n (isMAITranscribeStreaming(this.modelId)\n ? ('mai' as const)\n : getMAITranscribeModel(this.modelId)\n ? ('speech' as const)\n : ('openai' as const)),\n speechOptions: pickKeys(\n options,\n azureSpeechTranscriptionModelOptionsShape(),\n ),\n maiOptions: language != null ? { language } : {},\n openaiOptions: pickAzureOptions(\n providerOptions,\n openAITranscriptionModelOptionsShape(),\n ),\n };\n }\n}\n\n// Resolves the API per request: providerOptions also reach this model via Gateway.\nclass AzureSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.speech';\n\n constructor(\n readonly modelId: string,\n private readonly config: AzureOpenAIProviderSettings,\n private readonly openai: OpenAISpeechModel,\n private readonly speech: AzureSpeechSpeechModel,\n ) {}\n\n static [WORKFLOW_SERIALIZE](model: AzureSpeechModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: string;\n config: AzureOpenAIProviderSettings;\n }) {\n return createAzure(options.config).speech(options.modelId);\n }\n\n async doGenerate(options: Parameters<SpeechModelV4['doGenerate']>[0]) {\n const { api, ...parsedOptions } =\n (await parseProviderOptions({\n provider: 'azure',\n providerOptions: options.providerOptions,\n schema: azureSpeechModelOptions,\n })) ?? {};\n const speechOptions = pickKeys(\n parsedOptions,\n azureSpeechSpeechModelOptionsShape(),\n );\n const openaiOptions = pickAzureOptions(\n options.providerOptions,\n openaiSpeechModelOptionsShape(),\n );\n if (\n (api ?? (getMAIVoiceModel(this.modelId) ? 'speech' : 'openai')) ===\n 'speech'\n ) {\n const result = await this.speech.doGenerate(options, speechOptions);\n return {\n ...result,\n warnings: [\n ...result.warnings,\n ...unsupportedOptionWarnings(\n openaiOptions,\n 'This option requires the OpenAI speech API.',\n ),\n ],\n };\n }\n\n const result = await this.openai.doGenerate(\n withAzureOptionsForOpenAI(options, openaiOptions),\n );\n return {\n ...result,\n warnings: [...result.warnings, ...speechOnlyWarnings(speechOptions)],\n };\n }\n}\n\n// Resolves the API per request: providerOptions also reach this model via Gateway.\nclass AzureImageModel implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.image';\n\n constructor(\n readonly modelId: string,\n private readonly config: AzureOpenAIProviderSettings,\n private readonly openai: OpenAIImageModel,\n private readonly mai: AzureMaiImageModel,\n ) {}\n\n // Capabilities follow the default route; an `api` override is per request.\n private get defaultModel() {\n return isMAIImageModel(this.modelId) ? this.mai : this.openai;\n }\n\n get maxImagesPerCall() {\n return this.defaultModel.maxImagesPerCall;\n }\n\n get supportsFileInputs() {\n return this.defaultModel.supportsFileInputs;\n }\n\n get supportsMaskInputs() {\n return this.defaultModel.supportsMaskInputs;\n }\n\n static [WORKFLOW_SERIALIZE](model: AzureImageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: string;\n config: AzureOpenAIProviderSettings;\n }) {\n return createAzure(options.config).image(options.modelId);\n }\n\n async doGenerate(options: Parameters<ImageModelV4['doGenerate']>[0]) {\n const { api, ...maiOptions } =\n (await parseProviderOptions({\n provider: 'azure',\n providerOptions: options.providerOptions,\n schema: azureImageModelOptions,\n })) ?? {};\n if ((api ?? (isMAIImageModel(this.modelId) ? 'mai' : 'openai')) === 'mai') {\n return this.mai.doGenerate(options, maiOptions);\n }\n\n const result = await this.openai.doGenerate(\n withAzureOptionsForOpenAI(\n options,\n pickAzureOptions(\n options.providerOptions,\n options.files != null\n ? openaiImageModelEditOptionsShape()\n : openaiImageModelGenerationOptionsShape(),\n ),\n ),\n );\n return {\n ...result,\n warnings: [\n ...result.warnings,\n ...unsupportedOptionWarnings(\n maiOptions,\n 'This option requires the MAI image API.',\n ),\n ],\n };\n }\n}\n\n/**\n * Picks the options that the given schema shape accepts from the raw `azure`\n * provider options. Raw values are used so schema defaults are not injected;\n * the OpenAI model validates them again.\n */\nfunction pickAzureOptions(\n providerOptions: SharedV4ProviderOptions | undefined,\n shape: Record<string, unknown>,\n): Record<string, unknown> {\n return pickKeys(providerOptions?.azure ?? {}, shape);\n}\n\nfunction pickKeys(\n options: Record<string, unknown>,\n shape: Record<string, unknown>,\n): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(options).filter(\n ([key, value]) => Object.hasOwn(shape, key) && value !== undefined,\n ),\n );\n}\n\n/**\n * Azure OpenAI deployments accept their OpenAI API options under `azure` as\n * well as `openai`. Both are merged into `openai` for the OpenAI model; `azure`\n * wins, like it does for Azure chat and completion models.\n */\nfunction withAzureOptionsForOpenAI<\n OPTIONS extends { providerOptions?: SharedV4ProviderOptions },\n>(options: OPTIONS, azureOptions: Record<string, unknown>): OPTIONS {\n if (Object.keys(azureOptions).length === 0) {\n return options;\n }\n\n return {\n ...options,\n providerOptions: {\n ...options.providerOptions,\n openai: {\n ...options.providerOptions?.openai,\n ...azureOptions,\n } as SharedV4ProviderOptions[string],\n },\n };\n}\n\nfunction openaiTranscriptionOnlyWarnings(options: Record<string, unknown>) {\n // `language` is shared with MAI and reported by `maiOnlyWarnings`.\n const { language: _language, ...openaiOnlyOptions } = options;\n return unsupportedOptionWarnings(\n openaiOnlyOptions,\n 'This option requires the OpenAI transcription API.',\n );\n}\n\nfunction speechOnlyWarnings(options: Record<string, unknown>) {\n return unsupportedOptionWarnings(\n options,\n 'This option requires the Azure Speech API.',\n );\n}\n\nfunction maiOnlyWarnings(options: Record<string, unknown>) {\n return unsupportedOptionWarnings(\n options,\n 'This option requires MAI streaming transcription.',\n );\n}\n\nfunction unsupportedOptionWarnings(\n options: Record<string, unknown>,\n details: string,\n): SharedV4Warning[] {\n return Object.entries(options)\n .filter(([, value]) => value !== undefined)\n .map(([key]) => ({\n type: 'unsupported',\n feature: `providerOptions.azure.${key}`,\n details,\n }));\n}\n"],"mappings":";;;;;;AAyDA,SAAS,WAAW,cAAwC;CAC1D,OAAO;EACL,cAAc,EACZ,OAAO;GACL,OAAO,EACL,aAAa,yDACf;GACA,WAAW;GACX,WAAW;GACX,kBAAkB;EACpB,EACF;EACA,iBAAiB,EACf,OAAO;GAAE,KAAK;GAAM,iBAAiB;GAAc;EAAa,EAClE;EACA,eAAe,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE;CACzC;AACF;AAEA,SAAS,YAAY,YAAqC;CACxD,OAAO;EACL,cAAc,EAAE,QAAQ,EAAE,cAAc,MAAM,EAAE;EAChD,iBAAiB,EACf,QAAQ;GACN,KAAK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AAK;AACrD;AAEA,SAAS,SACP,SACA,OACyB;CACzB,OAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,CAAC,CAAC,QACrB,CAAC,KAAK,WAAW,OAAO,OAAO,OAAO,GAAG,KAAK,UAAU,KAAA,CAC3D,CACF;AACF;;;;;;AAOA,SAAS,0BAEP,SAAkB,cAAgD;CAClE,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,GACvC,OAAO;CAGT,OAAO;EACL,GAAG;EACH,iBAAiB;GACf,GAAG,QAAQ;GACX,QAAQ;IACN,GAAG,QAAQ,iBAAiB;IAC5B,GAAG;GACL;EACF;CACF;AACF;AAEA,SAAS,gCAAgC,SAAkC;CAEzE,MAAM,EAAE,UAAU,WAAW,GAAG,sBAAsB;CACtD,OAAO,0BACL,mBACA,oDACF;AACF;AAEA,SAAS,mBAAmB,SAAkC;CAC5D,OAAO,0BACL,SACA,4CACF;AACF;AAEA,SAAS,gBAAgB,SAAkC;CACzD,OAAO,0BACL,SACA,mDACF;AACF;AAEA,SAAS,0BACP,SACA,SACmB;CACnB,OAAO,OAAO,QAAQ,OAAO,CAAC,CAC3B,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CAAC,CAC1C,KAAK,CAAC,UAAU;EACf,MAAM;EACN,SAAS,yBAAyB;EAClC;CACF,EAAE;AACN"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/azure-model-catalog.ts","../src/azure-mai-image-model-options.ts","../src/azure-image-model-options.ts","../src/azure-mai-image-model.ts","../src/azure-mai-transcription-model.ts","../src/azure-openai-tools.ts","../src/azure-speech-speech-model-options.ts","../src/azure-speech-model-options.ts","../src/azure-speech-speech-model.ts","../src/azure-mai-transcription-model-options.ts","../src/azure-speech-transcription-model-options.ts","../src/azure-transcription-model-options.ts","../src/azure-speech-transcription-model.ts","../src/version.ts","../src/azure-openai-provider.ts"],"sourcesContent":["import type {\n ModelEntry,\n ProviderOptionDefinition,\n ProviderOptionDefinitions,\n} from '@ai-sdk/provider';\nimport type { AzureImageModelOptions } from './azure-image-model-options';\nimport type { AzureTranscriptionModelMaiOptions } from './azure-mai-transcription-model-options';\nimport type { AzureSpeechModelOptions } from './azure-speech-model-options';\nimport type { AzureSpeechModelSpeechOptions } from './azure-speech-speech-model-options';\nimport type { AzureTranscriptionModelSpeechOptions } from './azure-speech-transcription-model-options';\nimport type { AzureTranscriptionModelOptions } from './azure-transcription-model-options';\n\n/**\n * Azure-specific options; OpenAI-backed operations retain OpenAI's options,\n * which they also accept under `azure`.\n */\nexport const azureProviderOptions = {\n image: {\n api: { description: 'Select the OpenAI or MAI image API.' },\n autoAspectRatio: { description: 'Choose the aspect ratio automatically.' },\n webGrounding: { description: 'Ground image generation in web search.' },\n background: { description: 'Transparent or opaque image background.' },\n } satisfies Record<keyof AzureImageModelOptions, ProviderOptionDefinition>,\n speech: {\n api: { description: 'Select the OpenAI or Azure Speech API.' },\n style: { description: 'Speaking style supported by the selected voice.' },\n styleDegree: { description: 'Intensity of the speaking style.' },\n } satisfies Record<\n | ('api' & keyof AzureSpeechModelOptions)\n | keyof AzureSpeechModelSpeechOptions,\n ProviderOptionDefinition\n >,\n transcription: {\n api: { description: 'Select the OpenAI, Azure Speech, or MAI API.' },\n language: { description: 'Language hint for MAI streaming transcription.' },\n timestamps: { description: 'Word, segment, or no timestamps.' },\n transcribeStyle: { description: 'Verbatim or cleaned transcription.' },\n locales: { description: 'Language to use for transcription.' },\n diarization: { description: 'Enable speaker diarization.' },\n phraseList: { description: 'Phrases to bias transcription toward.' },\n } satisfies Record<\n | ('api' & keyof AzureTranscriptionModelOptions)\n | keyof AzureTranscriptionModelSpeechOptions\n | keyof AzureTranscriptionModelMaiOptions,\n ProviderOptionDefinition\n >,\n} as const satisfies ProviderOptionDefinitions;\n\ntype AzureRequestConfig = {\n image?: { api: 'mai' };\n speech?: { api: 'speech'; voiceModel: string };\n transcription?:\n | { api: 'speech'; name: string; supportsTimestamps: boolean }\n | { api: 'mai' };\n};\n\ntype AzureModelEntry = ModelEntry<AzureRequestConfig>;\n\nfunction imageEntry({\n webGrounding = false,\n background = false,\n}: { webGrounding?: boolean; background?: boolean } = {}): AzureModelEntry {\n return {\n capabilities: {\n image: {\n sizes: {\n description: 'Sides must be multiples of 16 and at least 768 pixels.',\n },\n fileInput: true,\n maskInput: false,\n maxImagesPerCall: 1,\n },\n },\n providerOptions: {\n image: {\n api: true,\n autoAspectRatio: webGrounding,\n webGrounding,\n background,\n },\n },\n requestConfig: { image: { api: 'mai' } },\n };\n}\n\nfunction speechEntry(voiceModel: string): AzureModelEntry {\n return {\n capabilities: { speech: { instructions: false } },\n providerOptions: {\n speech: {\n api: true,\n style: {\n condition: 'Supported styles depend on the selected voice and model.',\n },\n styleDegree: { condition: 'Requires a supported speaking style.' },\n },\n },\n requestConfig: { speech: { api: 'speech', voiceModel } },\n };\n}\n\nfunction transcriptionEntry(\n name: string,\n supportsTimestamps: boolean,\n): AzureModelEntry {\n return {\n capabilities: {\n transcription: {\n transcription: true,\n streaming: false,\n duration: true,\n segments: supportsTimestamps,\n language: true,\n },\n },\n providerOptions: {\n transcription: {\n api: true,\n language: { condition: 'Requires the MAI streaming API override.' },\n timestamps: supportsTimestamps\n ? true\n : { condition: 'Only none is supported.' },\n transcribeStyle: supportsTimestamps\n ? true\n : { condition: 'Only verbatim is supported.' },\n locales: true,\n diarization: supportsTimestamps,\n phraseList: true,\n },\n },\n requestConfig: {\n transcription: { api: 'speech', name, supportsTimestamps },\n },\n };\n}\n\n/**\n * Azure-owned models. OpenAI and DeepSeek deployments use their adapters' model\n * catalogs; arbitrary deployment names do not declare model-family support.\n */\nexport const azureModelCatalog: Readonly<Record<string, AzureModelEntry>> = {\n 'mai-image-2.5': imageEntry(),\n 'mai-image-2.5-flash': imageEntry(),\n 'mai-image-2.5-pro': imageEntry(),\n 'mai-image-2.6': imageEntry({ webGrounding: true }),\n 'mai-image-2.6-flash': imageEntry({ webGrounding: true }),\n 'mai-image-2.7': imageEntry({ webGrounding: true, background: true }),\n 'mai-image-2.7-flash': imageEntry({ webGrounding: true, background: true }),\n 'mai-voice-2.1-flash': speechEntry('MAI-Voice-2.1-Flash'),\n 'mai-voice-2.1': speechEntry('MAI-Voice-2.1'),\n 'mai-voice-2-flash': speechEntry('MAI-Voice-2-Flash'),\n 'mai-voice-2': speechEntry('MAI-Voice-2'),\n 'mai-transcribe-2': transcriptionEntry('MAI-Transcribe-2', true),\n 'mai-transcribe-1.5': transcriptionEntry('MAI-Transcribe-1.5', false),\n 'mai-transcribe-2-streaming': {\n capabilities: {\n transcription: {\n transcription: false,\n streaming: true,\n duration: {\n condition: 'Requires an audio format with a known byte rate.',\n },\n segments: false,\n language: { condition: 'Reports the configured language hint.' },\n },\n },\n providerOptions: {\n transcription: {\n api: true,\n language: true,\n timestamps: false,\n transcribeStyle: false,\n locales: false,\n diarization: false,\n phraseList: false,\n },\n },\n requestConfig: { transcription: { api: 'mai' } },\n },\n};\n\nexport function getAzureModelEntry(\n modelId: string,\n): AzureModelEntry | undefined {\n const id = modelId.toLowerCase();\n return Object.prototype.hasOwnProperty.call(azureModelCatalog, id)\n ? azureModelCatalog[id]\n : undefined;\n}\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const azureMaiImageModelOptionsShape = () => ({\n /**\n * Let the model pick the output aspect ratio from the prompt and any\n * reference images. MAI-Image-2.6 and MAI-Image-2.7 models only.\n */\n autoAspectRatio: z.boolean().optional(),\n\n /**\n * Ground generation in Bing web search results. MAI-Image-2.6 and\n * MAI-Image-2.7 models only.\n */\n webGrounding: z.boolean().optional(),\n\n /**\n * Image background. `transparent` returns a PNG with an alpha channel;\n * the API defaults to `opaque`. MAI-Image-2.7 models only.\n */\n background: z.enum(['transparent', 'opaque']).optional(),\n});\n\nexport const azureMaiImageModelOptions = lazySchema(() =>\n zodSchema(z.object(azureMaiImageModelOptionsShape())),\n);\n\nexport type AzureImageModelMaiOptions = InferSchema<\n typeof azureMaiImageModelOptions\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { getAzureModelEntry } from './azure-model-catalog';\nimport { azureMaiImageModelOptionsShape } from './azure-mai-image-model-options';\n\nexport const azureImageModelOptions = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * API to use. Defaults to MAI for MAI-Image models, OpenAI otherwise.\n */\n api: z.enum(['openai', 'mai']).optional(),\n ...azureMaiImageModelOptionsShape(),\n\n /**\n * Image background. The MAI image API (MAI-Image-2.7 models) supports\n * `transparent` and `opaque`; OpenAI image deployments also accept `auto`.\n */\n background: z.enum(['transparent', 'opaque', 'auto']).optional(),\n }),\n ),\n);\n\nexport type AzureImageModelOptions = InferSchema<typeof azureImageModelOptions>;\n\nexport function isMAIImageModel(modelId: string) {\n return getAzureModelEntry(modelId)?.requestConfig?.image?.api === 'mai';\n}\n","import type {\n ImageModelV4,\n ImageModelV4File,\n ImageModelV4Usage,\n SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n convertBase64ToUint8Array,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n downloadBlob,\n postFormDataToApi,\n postJsonToApi,\n resolve,\n type Resolvable,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { AzureImageModelMaiOptions } from './azure-mai-image-model-options';\n\n// MAI rejects either side below 768px; 1024x1024 is its default output.\nconst MIN_SIDE = 768;\nconst DEFAULT_PIXELS = 1024 * 1024;\n\n/**\n * MAI image generations and edits (`/mai/v1/images/*`) on Azure AI Foundry.\n * The API returns one PNG per request and takes `width`/`height`, not `size`.\n */\nexport class AzureMaiImageModel implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.image';\n readonly maxImagesPerCall = 1;\n readonly supportsFileInputs = true;\n readonly supportsMaskInputs = false;\n\n constructor(\n readonly modelId: string,\n private readonly config: {\n url: (path: string) => string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n /** Transport for untrusted file URLs, without provider authentication. */\n downloadFetch?: FetchFunction;\n _internal?: { currentDate?: () => Date };\n },\n ) {}\n\n async doGenerate(\n {\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n files,\n mask,\n headers,\n abortSignal,\n }: Parameters<ImageModelV4['doGenerate']>[0],\n {\n autoAspectRatio,\n webGrounding,\n background,\n }: AzureImageModelMaiOptions = {},\n ): Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const warnings: SharedV4Warning[] = [];\n\n if (seed != null) {\n warnings.push({ type: 'unsupported', feature: 'seed' });\n }\n if (mask != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'mask',\n details: 'MAI image edits do not support masks.',\n });\n }\n\n let dimensions = parseSize(size);\n if (size != null && aspectRatio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: 'aspectRatio is ignored when size is set.',\n });\n } else if (aspectRatio != null) {\n dimensions = dimensionsForAspectRatio(aspectRatio);\n if (dimensions == null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: `Invalid aspect ratio: ${aspectRatio}.`,\n });\n }\n }\n\n const fields = {\n model: this.modelId,\n prompt,\n width: dimensions?.width,\n height: dimensions?.height,\n auto_aspect_ratio: autoAspectRatio,\n web_grounding: webGrounding,\n background,\n };\n const requestOptions = {\n headers: combineHeaders(await resolve(this.config.headers), headers),\n failedResponseHandler: maiFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n maiImageResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n };\n const images =\n files != null && files.length > 0\n ? await Promise.all(\n files.map(file =>\n fileToBlob(\n file,\n abortSignal,\n this.config.downloadFetch ?? this.config.fetch,\n ),\n ),\n )\n : undefined;\n\n // The API ignores `n`, so a call reached with n > 1 (e.g. through an\n // `api: 'mai'` override) sends one request per image.\n const responses = await Promise.all(\n Array.from({ length: Math.max(1, n) }, () =>\n images != null\n ? postFormDataToApi({\n ...requestOptions,\n url: this.config.url('/images/edits'),\n formData: toFormData(fields, images),\n })\n : postJsonToApi({\n ...requestOptions,\n url: this.config.url('/images/generations'),\n body: fields,\n }),\n ),\n );\n\n let usage: ImageModelV4Usage | undefined;\n const metadata: Array<Record<string, number | string>> = [];\n for (const { value: response } of responses) {\n const textTokens = response.usage?.num_input_text_tokens ?? undefined;\n const imageTokens = response.usage?.num_input_image_tokens ?? undefined;\n if (response.usage != null) {\n const inputTokens = addTokens(textTokens, imageTokens);\n const outputTokens = response.usage.num_output_tokens ?? undefined;\n usage = {\n inputTokens: addTokens(usage?.inputTokens, inputTokens),\n outputTokens: addTokens(usage?.outputTokens, outputTokens),\n totalTokens: addTokens(\n usage?.totalTokens,\n addTokens(inputTokens, outputTokens),\n ),\n };\n }\n metadata.push(\n ...response.data.map(() => ({\n ...(response.created != null ? { created: response.created } : {}),\n ...(response.size != null ? { size: response.size } : {}),\n ...(textTokens != null ? { textTokens } : {}),\n ...(imageTokens != null ? { imageTokens } : {}),\n })),\n );\n }\n\n return {\n images: responses.flatMap(({ value }) =>\n value.data.map(item => item.b64_json),\n ),\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responses[0]?.responseHeaders,\n },\n usage,\n providerMetadata: { azure: { images: metadata } },\n };\n }\n}\n\nfunction addTokens(a: number | undefined, b: number | undefined) {\n return a == null && b == null ? undefined : (a ?? 0) + (b ?? 0);\n}\n\nfunction parseSize(size: `${number}x${number}` | undefined) {\n if (size == null) return undefined;\n const [width, height] = size.split('x').map(Number);\n return { width, height };\n}\n\n// Keeps the default 1024x1024 pixel budget, raising the short side to 768.\nexport function dimensionsForAspectRatio(aspectRatio: string) {\n const [w, h] = aspectRatio.split(':').map(Number);\n if (!(w > 0 && h > 0)) return undefined;\n\n const ratio = w / h;\n let width = Math.sqrt(DEFAULT_PIXELS * ratio);\n let height = width / ratio;\n if (Math.min(width, height) < MIN_SIDE) {\n [width, height] =\n width < height\n ? [MIN_SIDE, MIN_SIDE / ratio]\n : [MIN_SIDE * ratio, MIN_SIDE];\n }\n\n const floor16 = (value: number) => Math.floor(value / 16 + 1e-9) * 16;\n return {\n width: Math.max(MIN_SIDE, floor16(width)),\n height: Math.max(MIN_SIDE, floor16(height)),\n };\n}\n\nfunction toFormData(\n fields: Record<string, string | number | boolean | undefined>,\n images: Blob[],\n) {\n const formData = new FormData();\n for (const [key, value] of Object.entries(fields)) {\n if (value != null) formData.append(key, String(value));\n }\n\n images.forEach((blob, index) => {\n const extension = blob.type === 'image/jpeg' ? 'jpg' : 'png';\n formData.append('image', blob, `image-${index + 1}.${extension}`);\n });\n return formData;\n}\n\nasync function fileToBlob(\n file: ImageModelV4File,\n abortSignal: AbortSignal | undefined,\n fetch: FetchFunction | undefined,\n): Promise<Blob> {\n if (file.type === 'url') {\n return downloadBlob(file.url, { abortSignal, fetch });\n }\n\n const data =\n file.data instanceof Uint8Array\n ? file.data\n : convertBase64ToUint8Array(file.data);\n return new Blob([data as BlobPart], { type: file.mediaType });\n}\n\nconst maiErrorSchema = lazySchema(() =>\n zodSchema(\n z.object({\n error: z.object({\n code: z.union([z.string(), z.number()]).nullish(),\n message: z.string(),\n }),\n }),\n ),\n);\n\nconst maiFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: maiErrorSchema,\n errorToMessage: data => data.error.message,\n});\n\n// Only the fields used here, to tolerate API additions.\nconst maiImageResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n created: z.number().nullish(),\n size: z.string().nullish(),\n usage: z\n .object({\n num_input_text_tokens: z.number().nullish(),\n num_input_image_tokens: z.number().nullish(),\n num_output_tokens: z.number().nullish(),\n })\n .nullish(),\n data: z.array(z.object({ b64_json: z.string() })),\n }),\n ),\n);\n","import {\n InvalidArgumentError,\n UnsupportedFunctionalityError,\n type Experimental_TranscriptionModelV4StreamPart as TranscriptionModelV4StreamPart,\n type SharedV4Warning,\n type TranscriptionModelV4,\n} from '@ai-sdk/provider';\nimport {\n connectToWebSocket,\n convertToBase64,\n safeParseJSON,\n toWebSocketUrl,\n waitForWebSocketBufferDrain,\n type WebSocketConnection,\n type WebSocketConstructor,\n type WebSocketLike,\n} from '@ai-sdk/provider-utils';\nimport type { AzureTranscriptionModelMaiOptions } from './azure-mai-transcription-model-options';\n\ntype StreamOptions = Parameters<\n NonNullable<TranscriptionModelV4['doStream']>\n>[0];\n\nconst SUPPORTED_SAMPLE_RATES = [16000, 24000];\nconst DEFAULT_SAMPLE_RATE = 24000;\n\n/**\n * MAI streaming transcription over the OpenAI Realtime-compatible\n * `/mai/v1/realtime` WebSocket. The model ID is the Foundry deployment name.\n */\nexport class AzureMaiTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.transcription';\n\n constructor(\n readonly modelId: string,\n private readonly config: {\n url: () => string;\n headers: () =>\n | Record<string, string | undefined>\n | PromiseLike<Record<string, string | undefined>>;\n webSocket?: WebSocketConstructor;\n _internal?: { currentDate?: () => Date };\n },\n ) {}\n\n async doGenerate(): Promise<\n Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>\n > {\n throw new UnsupportedFunctionalityError({\n functionality: `file transcription with ${this.modelId} (use streaming transcription)`,\n });\n }\n\n async doStream(\n options: StreamOptions,\n maiOptions: AzureTranscriptionModelMaiOptions = {},\n warnings: SharedV4Warning[] = [],\n ): Promise<\n Awaited<ReturnType<NonNullable<TranscriptionModelV4['doStream']>>>\n > {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { type, rate = DEFAULT_SAMPLE_RATE } = options.inputAudioFormat;\n if (type !== 'audio/pcm' || !SUPPORTED_SAMPLE_RATES.includes(rate)) {\n throw new InvalidArgumentError({\n argument: 'inputAudioFormat',\n message: `MAI streaming transcription requires 16-bit mono PCM (audio/pcm) at 16000 or 24000 Hz, got ${type}${options.inputAudioFormat.rate != null ? ` at ${rate} Hz` : ''}.`,\n });\n }\n\n const sessionUpdate = {\n type: 'session.update',\n session: {\n type: 'transcription',\n audio: {\n input: {\n format: { type: 'audio/pcm', rate },\n transcription: {\n model: this.modelId,\n ...(maiOptions.language != null\n ? { language: maiOptions.language }\n : {}),\n },\n // MAI supports neither server VAD nor noise reduction; the stream\n // commits once when the input audio ends.\n turn_detection: null,\n noise_reduction: null,\n },\n },\n },\n };\n\n const headers = {\n ...(await this.config.headers()),\n ...options.headers,\n };\n // Native WebSocket constructors drop headers, so bearer auth would be lost.\n if (\n this.config.webSocket == null &&\n Object.entries(headers).some(\n ([key, value]) =>\n key.toLowerCase() === 'authorization' && value != null,\n )\n ) {\n throw new InvalidArgumentError({\n argument: 'webSocket',\n message:\n 'MAI streaming transcription with Microsoft Entra ID (tokenProvider) or an Authorization header requires a custom webSocket implementation such as `ws`, because the native WebSocket cannot send headers.',\n });\n }\n\n return {\n request: { body: sessionUpdate },\n response: { timestamp: currentDate, modelId: this.modelId },\n stream: createMaiTranscriptionStream({\n ...getConnection({\n url: toWebSocketUrl(this.config.url()),\n headers,\n supportsHeaders: this.config.webSocket != null,\n }),\n webSocket: this.config.webSocket,\n sessionUpdate,\n bytesPerSecond: rate * 2,\n language: maiOptions.language,\n warnings,\n audio: options.audio,\n abortSignal: options.abortSignal,\n includeRawChunks: options.includeRawChunks,\n }),\n };\n }\n}\n\n// Native WebSocket constructors cannot send headers, so the key moves to the\n// `api-key` query parameter that MAI also accepts.\nfunction getConnection({\n url,\n headers,\n supportsHeaders,\n}: {\n url: URL;\n headers: Record<string, string | undefined>;\n supportsHeaders: boolean;\n}) {\n if (supportsHeaders) {\n return { url, headers };\n }\n const remaining: Record<string, string | undefined> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === 'api-key') {\n if (value != null) url.searchParams.set('api-key', value);\n } else {\n remaining[key] = value;\n }\n }\n return { url, headers: remaining };\n}\n\ntype MaiRealtimeEvent = {\n type?: string;\n item_id?: string;\n delta?: string;\n intermediate?: string;\n transcript?: string;\n error?: { message?: string; code?: string };\n};\n\nfunction createMaiTranscriptionStream({\n url,\n headers,\n webSocket,\n sessionUpdate,\n bytesPerSecond,\n language,\n warnings,\n audio,\n abortSignal,\n includeRawChunks,\n}: {\n url: URL;\n headers: Record<string, string | undefined>;\n webSocket: WebSocketConstructor | undefined;\n sessionUpdate: unknown;\n bytesPerSecond: number;\n language: string | undefined;\n warnings: SharedV4Warning[];\n audio: ReadableStream<Uint8Array | string>;\n abortSignal: AbortSignal | undefined;\n includeRawChunks: boolean | undefined;\n}) {\n let finished = false;\n let cleanup: (closeCode?: number) => void = () => {};\n\n return new ReadableStream<TranscriptionModelV4StreamPart>({\n start: controller => {\n let audioReader:\n | ReadableStreamDefaultReader<Uint8Array | string>\n | undefined;\n let connection: WebSocketConnection | undefined;\n let audioStarted = false;\n let committed = false;\n let audioBytes = 0;\n let deltas = '';\n\n cleanup = (closeCode?: number) => {\n if (audioReader != null) {\n void audioReader.cancel().catch(() => {});\n } else {\n void audio.cancel().catch(() => {});\n }\n connection?.close(closeCode);\n };\n\n const finishWithError = (error: unknown) => {\n if (finished) return;\n finished = true;\n cleanup();\n controller.error(error);\n };\n\n const finish = (text: string) => {\n if (finished) return;\n finished = true;\n controller.enqueue({\n type: 'finish',\n text,\n segments: [],\n language,\n ...(audioBytes > 0\n ? { durationInSeconds: audioBytes / bytesPerSecond }\n : {}),\n });\n controller.close();\n cleanup(1000);\n };\n\n const sendAudio = async (socket: WebSocketLike) => {\n audioReader = audio.getReader();\n try {\n while (true) {\n const { done, value } = await audioReader.read();\n if (done || finished) break;\n const base64 = convertToBase64(value);\n if (base64.length === 0) continue;\n audioBytes +=\n typeof value === 'string'\n ? base64ByteLength(base64)\n : value.byteLength;\n socket.send(\n JSON.stringify({\n type: 'input_audio_buffer.append',\n audio: base64,\n }),\n );\n await waitForWebSocketBufferDrain(socket);\n }\n } finally {\n audioReader.releaseLock();\n audioReader = undefined;\n }\n if (finished) return;\n if (audioBytes === 0) {\n finish('');\n return;\n }\n committed = true;\n socket.send(JSON.stringify({ type: 'input_audio_buffer.commit' }));\n };\n\n connection = connectToWebSocket({\n url,\n headers,\n webSocket,\n abortSignal,\n onAbort: finishWithError,\n onProcessingError: finishWithError,\n onOpen: () => {\n controller.enqueue({ type: 'stream-start', warnings });\n },\n onMessageText: async text => {\n const parsed = await safeParseJSON({ text });\n if (!parsed.success) return;\n const event = parsed.value as MaiRealtimeEvent;\n const socket = connection?.socket;\n\n if (includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: event });\n }\n\n switch (event.type) {\n case 'session.created': {\n socket?.send(JSON.stringify(sessionUpdate));\n break;\n }\n\n // Settings are locked after the first append, so audio waits for\n // the server to acknowledge the session configuration.\n case 'session.updated': {\n if (audioStarted || socket == null) break;\n audioStarted = true;\n void sendAudio(socket).catch(finishWithError);\n break;\n }\n\n case 'conversation.item.input_audio_transcription.delta': {\n deltas += event.delta ?? '';\n controller.enqueue({\n type: 'transcript-delta',\n id: event.item_id,\n delta: event.delta ?? '',\n });\n break;\n }\n\n // MAI-specific: the provisional text after the latest delta.\n case 'conversation.item.input_audio_transcription.intermediate': {\n controller.enqueue({\n type: 'transcript-partial',\n id: event.item_id,\n text: event.intermediate ?? '',\n });\n break;\n }\n\n case 'conversation.item.input_audio_transcription.completed': {\n const transcript = event.transcript ?? deltas;\n controller.enqueue({\n type: 'transcript-final',\n id: event.item_id,\n text: transcript,\n });\n if (committed) finish(transcript);\n break;\n }\n\n case 'conversation.item.input_audio_transcription.failed':\n case 'error': {\n finishWithError(\n new Error(\n `Azure MAI transcription error${event.error?.code != null ? ` (${event.error.code})` : ''}: ${event.error?.message ?? 'unknown error'}`,\n ),\n );\n break;\n }\n }\n },\n onSocketError: () => {\n finishWithError(new Error('Azure MAI transcription WebSocket error'));\n },\n onClose: ({ code, reason }) => {\n finishWithError(\n new Error(\n `Azure MAI transcription connection closed before the transcript completed${code != null ? ` (code ${code}${reason ? `: ${reason}` : ''})` : ''}`,\n ),\n );\n },\n });\n },\n\n cancel: () => {\n if (finished) return;\n finished = true;\n cleanup();\n },\n });\n}\n\nfunction base64ByteLength(base64: string) {\n const padding = base64.endsWith('==') ? 2 : base64.endsWith('=') ? 1 : 0;\n return (base64.length * 3) / 4 - padding;\n}\n","import {\n applyPatch,\n codeInterpreter,\n customTool,\n fileSearch,\n imageGeneration,\n shell,\n toolSearch,\n webSearch,\n webSearchPreview,\n} from '@ai-sdk/openai/internal';\n\nexport const azureOpenaiTools: {\n applyPatch: typeof applyPatch;\n codeInterpreter: typeof codeInterpreter;\n customTool: typeof customTool;\n fileSearch: typeof fileSearch;\n imageGeneration: typeof imageGeneration;\n shell: typeof shell;\n toolSearch: typeof toolSearch;\n webSearch: typeof webSearch;\n /**\n * @deprecated Use `webSearch` instead.\n */\n webSearchPreview: typeof webSearchPreview;\n} = {\n applyPatch,\n codeInterpreter,\n customTool,\n fileSearch,\n imageGeneration,\n shell,\n toolSearch,\n webSearch,\n webSearchPreview,\n};\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const azureSpeechSpeechModelOptionsShape = () => ({\n /**\n * Speaking style applied with `mstts:express-as`, e.g. `excited` or\n * `whispering`. Supported styles vary by voice.\n */\n style: z.string().min(1).optional(),\n\n /**\n * Intensity of `style`, from 0.01 to 2. Azure defaults to 1.\n */\n styleDegree: z.number().min(0.01).max(2).optional(),\n});\n\nexport const azureSpeechSpeechModelOptions = lazySchema(() =>\n zodSchema(z.strictObject(azureSpeechSpeechModelOptionsShape())),\n);\n\nexport type AzureSpeechModelSpeechOptions = InferSchema<\n typeof azureSpeechSpeechModelOptions\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { openaiSpeechModelOptionsShape } from '@ai-sdk/openai/internal';\nimport { z } from 'zod/v4';\nimport { getAzureModelEntry } from './azure-model-catalog';\nimport { azureSpeechSpeechModelOptionsShape } from './azure-speech-speech-model-options';\n\nexport const azureSpeechModelOptions = lazySchema(() =>\n zodSchema(\n z.strictObject({\n /**\n * API to use. Defaults to Speech for MAI-Voice models, OpenAI otherwise.\n */\n api: z.enum(['openai', 'speech']).optional(),\n // OpenAI API options for Azure OpenAI deployments.\n ...openaiSpeechModelOptionsShape(),\n ...azureSpeechSpeechModelOptionsShape(),\n }),\n ),\n);\n\nexport type AzureSpeechModelOptions = InferSchema<\n typeof azureSpeechModelOptions\n>;\n\nexport function getMAIVoiceModel(modelId: string) {\n return getAzureModelEntry(modelId)?.requestConfig?.speech?.voiceModel;\n}\n","import {\n APICallError,\n type SharedV4Warning,\n type SpeechModelV4,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n createBinaryResponseHandler,\n extractResponseHeaders,\n postToApi,\n safeParseJSON,\n resolve,\n type Resolvable,\n type FetchFunction,\n type ResponseHandler,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { getMAIVoiceModel } from './azure-speech-model-options';\nimport type { AzureSpeechModelSpeechOptions } from './azure-speech-speech-model-options';\n\nconst DEFAULT_VOICE = 'en-US-Harper';\n\n// Default voice per ISO 639-1 language; available on MAI-Voice-2,\n// MAI-Voice-2.1, and their Flash variants.\nconst DEFAULT_VOICES = new Map([\n ['de', 'de-DE-Mia'],\n ['en', DEFAULT_VOICE],\n ['es', 'es-MX-Valeria'],\n ['fr', 'fr-FR-Soleil'],\n ['hi', 'hi-IN-Kavya'],\n ['hu', 'hu-HU-Lilla'],\n ['it', 'it-IT-Rosa'],\n ['ko', 'ko-KR-Haena'],\n ['nl', 'nl-NL-Fleur'],\n ['pt', 'pt-BR-Luana'],\n ['ro', 'ro-RO-Elena'],\n ['ru', 'ru-RU-Masha'],\n ['th', 'th-TH-Krit'],\n ['tr', 'tr-TR-Elif'],\n ['zh', 'zh-CN-Mei'],\n]);\nconst DEFAULT_OUTPUT_FORMAT = 'audio-24khz-160kbitrate-mono-mp3';\n\n// Shorthand formats for `outputFormat`; other X-Microsoft-OutputFormat values\n// (e.g. `audio-48khz-192kbitrate-mono-mp3`) are passed through unchanged.\nconst OUTPUT_FORMATS = new Map([\n ['mp3', DEFAULT_OUTPUT_FORMAT],\n ['opus', 'ogg-24khz-16bit-mono-opus'],\n ['pcm', 'raw-24khz-16bit-mono-pcm'],\n ['wav', 'riff-24khz-16bit-mono-pcm'],\n]);\nconst NATIVE_OUTPUT_FORMAT =\n /^(?:amr|audio|g722|ogg|raw|riff|webm)-[a-z0-9-]+$/;\n\n/**\n * Azure Speech text to speech with SSML. The model is appended to the voice\n * name, e.g. `en-US-Harper:MAI-Voice-2`.\n */\nexport class AzureSpeechSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.speech';\n\n constructor(\n readonly modelId: string,\n private readonly config: {\n url: () => string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n _internal?: { currentDate?: () => Date };\n },\n ) {}\n\n async doGenerate(\n options: Parameters<SpeechModelV4['doGenerate']>[0],\n azureOptions: AzureSpeechModelSpeechOptions = {},\n ): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const warnings: SharedV4Warning[] = [];\n const { style, styleDegree } = azureOptions;\n\n if (options.instructions != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'instructions',\n details: 'Use providerOptions.azure.style to control speaking style.',\n });\n }\n const { voice, languageWarning } = resolveVoice(\n options.voice,\n options.language,\n );\n if (languageWarning != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'language',\n details: languageWarning,\n });\n }\n if (styleDegree != null && style == null) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions.azure.styleDegree',\n details: 'styleDegree requires style.',\n });\n }\n\n let outputFormat = DEFAULT_OUTPUT_FORMAT;\n if (options.outputFormat != null) {\n const format = options.outputFormat.toLowerCase();\n const shorthand = OUTPUT_FORMATS.get(format);\n if (shorthand != null) {\n outputFormat = shorthand;\n } else if (NATIVE_OUTPUT_FORMAT.test(format)) {\n outputFormat = format;\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'outputFormat',\n details: `Unsupported output format: ${options.outputFormat}. Using mp3 instead.`,\n });\n }\n }\n\n const ssml = buildSsml({\n text: options.text,\n voiceName: voice.includes(':')\n ? voice\n : `${voice}:${getMAIVoiceModel(this.modelId) ?? this.modelId}`,\n locale: /^([a-z]{2,3}-[a-z]{2,4})-/i.exec(voice)?.[1],\n speed: options.speed,\n style,\n styleDegree: style != null ? styleDegree : undefined,\n });\n\n const {\n value: audio,\n responseHeaders,\n rawValue,\n } = await postToApi({\n url: this.config.url(),\n headers: combineHeaders(\n await resolve(this.config.headers),\n {\n 'Content-Type': 'application/ssml+xml',\n 'X-Microsoft-OutputFormat': outputFormat,\n },\n options.headers,\n ),\n body: { content: ssml, values: ssml },\n failedResponseHandler,\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n audio,\n warnings,\n request: { body: ssml },\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawValue,\n },\n };\n }\n}\n\nfunction buildSsml({\n text,\n voiceName,\n locale = 'en-US',\n speed,\n style,\n styleDegree,\n}: {\n text: string;\n voiceName: string;\n locale?: string;\n speed?: number;\n style?: string;\n styleDegree?: number;\n}) {\n let content = escapeXml(text);\n if (speed != null) {\n content = `<prosody rate=\"${speed}\">${content}</prosody>`;\n }\n if (style != null) {\n const degree = styleDegree != null ? ` styledegree=\"${styleDegree}\"` : '';\n content = `<mstts:express-as style=\"${escapeXml(style)}\"${degree}>${content}</mstts:express-as>`;\n }\n return (\n `<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" ` +\n `xmlns:mstts=\"http://www.w3.org/2001/mstts\" xml:lang=\"${escapeXml(locale)}\">` +\n `<voice name=\"${escapeXml(voiceName)}\">${content}</voice></speak>`\n );\n}\n\nconst XML_ESCAPES: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n};\n\nfunction escapeXml(value: string) {\n return value.replace(/[&<>\"']/g, char => XML_ESCAPES[char]);\n}\n\n// Uses the language's default voice when no voice is set. An explicit voice\n// wins, and its locale selects the language.\nfunction resolveVoice(\n voice: string | undefined,\n language: string | undefined,\n): { voice: string; languageWarning?: string } {\n const code = language ? language.split('-')[0].toLowerCase() : undefined;\n if (voice == null) {\n if (code == null) return { voice: DEFAULT_VOICE };\n if (code === 'auto') {\n return {\n voice: DEFAULT_VOICE,\n languageWarning: `Automatic language detection is not supported. ${DEFAULT_VOICE} was used.`,\n };\n }\n const defaultVoice = DEFAULT_VOICES.get(code);\n return defaultVoice != null\n ? { voice: defaultVoice }\n : {\n voice: DEFAULT_VOICE,\n languageWarning: `No default MAI voice for language \"${language}\". ${DEFAULT_VOICE} was used.`,\n };\n }\n const voiceLanguage = /^([a-z]{2,3})-[a-z]{2,4}-/i\n .exec(voice)?.[1]\n ?.toLowerCase();\n return code != null &&\n code !== 'auto' &&\n voiceLanguage != null &&\n code !== voiceLanguage\n ? {\n voice,\n languageWarning: `The voice ${voice} selects the language. Language \"${language}\" was ignored.`,\n }\n : { voice };\n}\n\nconst errorSchema = lazySchema(() =>\n zodSchema(\n z.object({\n error: z.object({ message: z.string() }),\n }),\n ),\n);\n\n// Azure Speech answers invalid requests (unknown voice, unsupported style, or\n// output format) with an empty 400 body.\nconst failedResponseHandler: ResponseHandler<APICallError> = async ({\n response,\n url,\n requestBodyValues,\n}) => {\n const responseHeaders = extractResponseHeaders(response);\n const responseBody = await response.text();\n const parsed = await safeParseJSON({\n text: responseBody,\n schema: errorSchema,\n });\n const message = parsed.success\n ? parsed.value.error.message\n : response.status === 400\n ? 'Azure Speech request failed with status 400. Check the voice name, style, and output format.'\n : `Azure Speech request failed with status ${response.status}.`;\n\n return {\n responseHeaders,\n value: new APICallError({\n message,\n url,\n requestBodyValues,\n statusCode: response.status,\n responseHeaders,\n responseBody,\n }),\n };\n};\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const azureMaiTranscriptionModelOptionsShape = () => ({\n /**\n * Language hint for streaming transcription, e.g. `en`. Omit for automatic\n * language detection.\n */\n language: z.string().min(1).optional(),\n});\n\nexport const azureMaiTranscriptionModelOptions = lazySchema(() =>\n zodSchema(z.strictObject(azureMaiTranscriptionModelOptionsShape())),\n);\n\nexport type AzureTranscriptionModelMaiOptions = InferSchema<\n typeof azureMaiTranscriptionModelOptions\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// Strict objects reject unknown keys (e.g. `diarization.maxSpeakers`, which\n// MAI-Transcribe-2 does not support) instead of silently dropping them.\nexport const azureSpeechTranscriptionModelOptionsShape = () => ({\n /**\n * Timing granularity. Defaults to `segment` so that transcription results\n * include timed segments (Azure's own default is `none`).\n */\n timestamps: z.enum(['word', 'segment', 'none']).optional(),\n\n /**\n * `verbatim` keeps fillers and false starts, `clean` removes them.\n * Azure defaults to `verbatim`.\n */\n transcribeStyle: z.enum(['verbatim', 'clean']).optional(),\n\n /**\n * Forces a single language, e.g. `['en']`. Omit for automatic language\n * detection and code switching.\n */\n locales: z.array(z.string()).length(1).optional(),\n\n /**\n * Speaker diarization. Speaker IDs are available in provider metadata.\n */\n diarization: z.strictObject({ enabled: z.boolean() }).optional(),\n\n /**\n * Keyword biasing for names and domain terminology.\n */\n phraseList: z.strictObject({ phrases: z.array(z.string()) }).optional(),\n});\n\nexport const azureSpeechTranscriptionModelOptions = lazySchema(() =>\n zodSchema(z.strictObject(azureSpeechTranscriptionModelOptionsShape())),\n);\n\nexport type AzureTranscriptionModelSpeechOptions = InferSchema<\n typeof azureSpeechTranscriptionModelOptions\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { openAITranscriptionModelOptionsShape } from '@ai-sdk/openai/internal';\nimport { z } from 'zod/v4';\nimport { getAzureModelEntry } from './azure-model-catalog';\nimport { azureMaiTranscriptionModelOptionsShape } from './azure-mai-transcription-model-options';\nimport { azureSpeechTranscriptionModelOptionsShape } from './azure-speech-transcription-model-options';\n\nexport const azureTranscriptionModelOptions = lazySchema(() =>\n zodSchema(\n z.strictObject({\n /**\n * API to use. Defaults to Speech for MAI-Transcribe models, MAI for\n * MAI-Transcribe-2-Streaming, and OpenAI otherwise.\n */\n api: z.enum(['openai', 'speech', 'mai']).optional(),\n // OpenAI API options for Azure OpenAI deployments. Listed first so the\n // shared `language` key keeps the MAI validation.\n ...openAITranscriptionModelOptionsShape(),\n ...azureSpeechTranscriptionModelOptionsShape(),\n ...azureMaiTranscriptionModelOptionsShape(),\n }),\n ),\n);\n\nexport type AzureTranscriptionModelOptions = InferSchema<\n typeof azureTranscriptionModelOptions\n>;\n\nexport function getMAITranscribeModel(modelId: string) {\n const config = getAzureModelEntry(modelId)?.requestConfig?.transcription;\n return config?.api === 'speech'\n ? { name: config.name, supportsTimestamps: config.supportsTimestamps }\n : undefined;\n}\n\nexport function isMAITranscribeStreaming(modelId: string): boolean {\n return (\n getAzureModelEntry(modelId)?.requestConfig?.transcription?.api === 'mai'\n );\n}\n","import type { SharedV4Warning, TranscriptionModelV4 } from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n convertBase64ToUint8Array,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n mediaTypeToExtension,\n postFormDataToApi,\n resolve,\n type Resolvable,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { AzureTranscriptionProviderMetadata } from './azure-transcription-provider-metadata';\nimport type { AzureTranscriptionModelSpeechOptions } from './azure-speech-transcription-model-options';\nimport { getMAITranscribeModel } from './azure-transcription-model-options';\n\nexport class AzureSpeechTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.transcription';\n\n constructor(\n readonly modelId: string,\n private readonly config: {\n url: () => string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n },\n ) {}\n\n async doGenerate(\n options: Parameters<TranscriptionModelV4['doGenerate']>[0],\n azureOptions: AzureTranscriptionModelSpeechOptions = {},\n ): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {\n const timestamp = new Date();\n const maiModel = getMAITranscribeModel(this.modelId);\n const warnings: SharedV4Warning[] = [];\n let timestamps = azureOptions.timestamps;\n if (options.timestampGranularities != null) {\n const wantsWord = options.timestampGranularities.includes('word');\n const wantsSegment = options.timestampGranularities.includes('segment');\n if (\n maiModel?.supportsTimestamps === false &&\n (wantsWord || wantsSegment)\n ) {\n warnings.push({\n type: 'unsupported',\n feature: 'timestampGranularities',\n details: `${maiModel.name} cannot return word or segment timings.`,\n });\n } else if (timestamps == null) {\n if (wantsWord) {\n timestamps = 'word';\n } else if (wantsSegment) {\n timestamps = 'segment';\n }\n } else if (\n (wantsWord && timestamps !== 'word') ||\n (wantsSegment && timestamps === 'none')\n ) {\n warnings.push({\n type: 'unsupported',\n feature: 'timestampGranularities',\n details: `providerOptions.azure.timestamps is \"${timestamps}\" and overrides the requested timestamp granularities.`,\n });\n }\n }\n const formData = new FormData();\n formData.append(\n 'audio',\n new Blob(\n [\n typeof options.audio === 'string'\n ? convertBase64ToUint8Array(options.audio)\n : (options.audio as Uint8Array<ArrayBuffer>),\n ],\n { type: options.mediaType },\n ),\n `audio.${mediaTypeToExtension(options.mediaType)}`,\n );\n formData.append(\n 'definition',\n JSON.stringify({\n enhancedMode: {\n enabled: true,\n model: maiModel?.name ?? this.modelId,\n modelOptions: {\n timestamps:\n timestamps ??\n (maiModel?.supportsTimestamps === false ? undefined : 'segment'),\n transcribeStyle: azureOptions.transcribeStyle,\n },\n },\n locales: azureOptions.locales,\n diarization: azureOptions.diarization,\n phraseList: azureOptions.phraseList,\n }),\n );\n\n const { value, rawValue, responseHeaders } = await postFormDataToApi({\n url: this.config.url(),\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n formData,\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n failedResponseHandler: createJsonErrorResponseHandler({\n errorSchema: z.union([\n z.object({ error: z.object({ message: z.string() }) }),\n z.object({ message: z.string() }),\n ]),\n errorToMessage: data =>\n 'error' in data ? data.error.message : data.message,\n }),\n successfulResponseHandler: createJsonResponseHandler(responseSchema),\n });\n\n const phrases = value.phrases ?? [];\n // Consider every reported locale so mixed results (e.g. en + fil) are not\n // collapsed to one language; only ISO-639-1 codes are reported.\n const languages = new Set(\n phrases.flatMap(phrase =>\n phrase.locale ? [phrase.locale.split('-')[0].toLowerCase()] : [],\n ),\n );\n const [language] = languages;\n const reportedLanguage =\n languages.size === 1 && /^[a-z]{2}$/.test(language)\n ? language\n : undefined;\n\n const words = phrases.flatMap(phrase =>\n (phrase.words ?? []).flatMap(word =>\n word.offsetMilliseconds != null && word.durationMilliseconds != null\n ? [\n {\n text: word.text,\n startSecond: word.offsetMilliseconds / 1000,\n endSecond:\n (word.offsetMilliseconds + word.durationMilliseconds) / 1000,\n },\n ]\n : [],\n ),\n );\n\n return {\n text: value.combinedPhrases.map(phrase => phrase.text).join(' '),\n ...(words.length > 0 ? { words } : {}),\n segments: phrases.flatMap(phrase =>\n phrase.offsetMilliseconds != null && phrase.durationMilliseconds != null\n ? [\n {\n text: phrase.text,\n startSecond: phrase.offsetMilliseconds / 1000,\n endSecond:\n (phrase.offsetMilliseconds + phrase.durationMilliseconds) /\n 1000,\n },\n ]\n : [],\n ),\n language: reportedLanguage,\n durationInSeconds:\n value.durationMilliseconds != null\n ? value.durationMilliseconds / 1000\n : undefined,\n warnings,\n providerMetadata: {\n azure: { phrases },\n } satisfies AzureTranscriptionProviderMetadata,\n response: {\n timestamp,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawValue,\n },\n };\n }\n}\n\nconst responseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n combinedPhrases: z.array(z.object({ text: z.string() })),\n durationMilliseconds: z.number().nullish(),\n phrases: z\n .array(\n z.object({\n text: z.string(),\n offsetMilliseconds: z.number().nullish(),\n durationMilliseconds: z.number().nullish(),\n locale: z.string().nullish(),\n speaker: z.number().nullish(),\n confidence: z.number().nullish(),\n words: z\n .array(\n z.object({\n text: z.string(),\n offsetMilliseconds: z.number().nullish(),\n durationMilliseconds: z.number().nullish(),\n }),\n )\n .nullish(),\n }),\n )\n .nullish(),\n }),\n ),\n);\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAISpeechModel,\n OpenAITranscriptionModel,\n openaiImageModelEditOptionsShape,\n openaiImageModelGenerationOptionsShape,\n openaiSpeechModelOptionsShape,\n openAITranscriptionModelOptionsShape,\n} from '@ai-sdk/openai/internal';\nimport { DeepSeekChatLanguageModel } from '@ai-sdk/deepseek/internal';\nimport {\n InvalidArgumentError,\n UnsupportedFunctionalityError,\n type EmbeddingModelV4,\n type LanguageModelV4,\n type ProviderV4,\n type ImageModelV4,\n type SharedV4ProviderOptions,\n type SharedV4Warning,\n type SpeechModelV4,\n type TranscriptionModelV4,\n} from '@ai-sdk/provider';\nimport {\n isValidHostnamePart,\n loadApiKey,\n loadSetting,\n normalizeHeaders,\n parseProviderOptions,\n resolveWith,\n serializeModelOptions,\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n type Resolvable,\n type WebSocketConstructor,\n} from '@ai-sdk/provider-utils';\nimport {\n azureImageModelOptions,\n isMAIImageModel,\n} from './azure-image-model-options';\nimport { AzureMaiImageModel } from './azure-mai-image-model';\nimport { AzureMaiTranscriptionModel } from './azure-mai-transcription-model';\nimport { azureOpenaiTools } from './azure-openai-tools';\nimport {\n azureSpeechModelOptions,\n getMAIVoiceModel,\n} from './azure-speech-model-options';\nimport { azureSpeechSpeechModelOptionsShape } from './azure-speech-speech-model-options';\nimport { AzureSpeechSpeechModel } from './azure-speech-speech-model';\nimport { AzureSpeechTranscriptionModel } from './azure-speech-transcription-model';\nimport { azureSpeechTranscriptionModelOptionsShape } from './azure-speech-transcription-model-options';\nimport {\n azureTranscriptionModelOptions,\n getMAITranscribeModel,\n isMAITranscribeStreaming,\n} from './azure-transcription-model-options';\nimport { VERSION } from './version';\n\nexport interface AzureOpenAILanguageModelSettings {\n /**\n * Underlying model ID used for reported identity and capability detection.\n * Defaults to the deployment ID. Requests always use the deployment ID.\n */\n modelId?: string;\n}\n\nexport interface AzureOpenAIProvider extends ProviderV4 {\n /**\n * Creates a Responses API model. The optional model ID is used for reported\n * identity and capability detection; requests always use the deployment ID.\n */\n (\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI responses API model for text generation.\n * The optional model ID is used for reported identity and capability detection.\n */\n languageModel(\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI chat model for text generation.\n * The optional model ID is used for reported identity and capability detection.\n */\n chat(\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ): LanguageModelV4;\n\n /**\n * Creates an Azure-hosted DeepSeek chat model for text generation.\n */\n deepseek(deploymentId: string): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI responses API model for text generation.\n * The optional model ID is used for reported identity and capability detection.\n */\n responses(\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI completion model for text generation.\n * The optional model ID is used for reported identity.\n */\n completion(\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI model for text embeddings.\n */\n embedding(deploymentId: string): EmbeddingModelV4;\n\n /**\n * Creates an Azure OpenAI model for text embeddings.\n */\n embeddingModel(deploymentId: string): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embedding` instead.\n */\n textEmbedding(deploymentId: string): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(deploymentId: string): EmbeddingModelV4;\n\n /**\n * Creates an Azure image model. MAI-Image models use the MAI image API by\n * default; other IDs use OpenAI. Override with providerOptions.azure.api.\n */\n image(deploymentId: string): ImageModelV4;\n\n /**\n * Creates an Azure image model. Alias of `image`.\n */\n imageModel(deploymentId: string): ImageModelV4;\n\n /**\n * Creates an Azure transcription model. MAI-Transcribe models use the Speech\n * API and MAI-Transcribe-2-Streaming the MAI realtime API by default; other\n * IDs use OpenAI. Override with providerOptions.azure.api.\n */\n transcription(deploymentId: string): TranscriptionModelV4;\n\n /**\n * Creates an Azure transcription model. Alias of `transcription`.\n */\n transcriptionModel(deploymentId: string): TranscriptionModelV4;\n\n /**\n * Creates an Azure speech generation model. MAI-Voice models use the Speech\n * API by default; other IDs use OpenAI. Override with providerOptions.azure.api.\n */\n speech(deploymentId: string): SpeechModelV4;\n\n /**\n * Creates an Azure speech generation model. Alias of `speech`.\n */\n speechModel(deploymentId: string): SpeechModelV4;\n\n /**\n * AzureOpenAI-specific tools.\n */\n tools: typeof azureOpenaiTools;\n}\n\nexport interface AzureOpenAIProviderSettings {\n /**\n * Name of the Azure OpenAI resource. Either this or `baseURL` can be used.\n *\n * The resource name is used in the assembled URL: `https://{resourceName}.openai.azure.com/openai/v1{path}`.\n * It must be a single DNS label (letters, digits, and hyphens).\n */\n resourceName?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers. Either this or `resourceName` can be used.\n * When a baseURL is provided, the resourceName is ignored.\n *\n * With an unversioned Azure OpenAI baseURL, the resolved URL is `{baseURL}/v1{path}`.\n * Azure OpenAI base URLs that already end in `/openai/v1` are used as-is.\n * With a non-Azure custom gateway baseURL, the resolved URL is `{baseURL}{path}`.\n */\n baseURL?: string;\n\n /**\n * API key for authenticating requests. A callback is resolved before each request.\n */\n apiKey?: Resolvable<string>;\n\n /**\n * A function that returns an access token for Microsoft Entra\n * (formerly known as Azure Active Directory), which will be invoked\n * on every request.\n */\n tokenProvider?: (() => Promise<string>) | undefined;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n\n /**\n * Custom api version to use. Defaults to `v1`.\n * Complete v1 base URLs are used as-is.\n */\n apiVersion?: string;\n\n /**\n * Use deployment-based URLs for specific model types. Set to true to use legacy deployment format:\n * `{baseURL}/deployments/{deploymentId}{path}?api-version={apiVersion}` instead of\n * `{baseURL}/v1{path}?api-version={apiVersion}`.\n */\n useDeploymentBasedUrls?: boolean;\n\n /**\n * URL prefix for Azure Speech (MAI-Transcribe transcription and MAI-Voice\n * speech), e.g. a regional endpoint like\n * `https://eastus.api.cognitive.microsoft.com`.\n * Defaults to `https://{resourceName}.cognitiveservices.azure.com`.\n * Speech requests do not use `baseURL` or `apiVersion`.\n */\n speechBaseURL?: string;\n\n /**\n * URL prefix for MAI APIs (MAI-Image, MAI-Transcribe-2-Streaming). Defaults\n * to `https://{resourceName}.services.ai.azure.com/mai/v1`.\n */\n maiBaseURL?: string;\n\n /**\n * Custom WebSocket implementation for MAI streaming transcription, e.g.\n * `ws` in Node.js. With a custom implementation the API key is sent as a\n * header; otherwise it is sent as the `api-key` query parameter. Entra ID\n * tokens require a custom implementation; streaming rejects them otherwise.\n */\n webSocket?: WebSocketConstructor;\n}\n\nfunction getAzureOpenAIBaseURLInfo(baseURL: string | undefined) {\n if (baseURL == null) {\n return {\n isAzureOpenAI: true,\n isFoundryProject: false,\n isVersioned: false,\n };\n }\n\n const url = new URL(baseURL);\n const hostname = url.hostname;\n const isAzureOpenAI =\n hostname.endsWith('.openai.azure.com') ||\n hostname.endsWith('.services.ai.azure.com') ||\n hostname.endsWith('.cognitiveservices.azure.com');\n const pathname = url.pathname.replace(/\\/+$/, '');\n\n return {\n isAzureOpenAI,\n isFoundryProject:\n hostname.endsWith('.services.ai.azure.com') &&\n pathname.startsWith('/api/projects/'),\n isVersioned: isAzureOpenAI && pathname.toLowerCase().endsWith('/openai/v1'),\n };\n}\n\n/**\n * Create an Azure OpenAI provider instance.\n */\nexport function createAzure(\n options: AzureOpenAIProviderSettings = {},\n): AzureOpenAIProvider {\n const tokenProvider = options.tokenProvider;\n\n if (options.apiKey && tokenProvider) {\n throw new InvalidArgumentError({\n argument: 'apiKey/tokenProvider',\n message:\n 'Both apiKey and tokenProvider were provided. Please use only one authentication method.',\n });\n }\n\n const getHeaders = (api: 'openai' | 'speech' | 'mai' = 'openai') =>\n resolveWith(tokenProvider ? undefined : options.apiKey, apiKey => {\n const authHeaders = tokenProvider\n ? {}\n : {\n [api === 'speech' ? 'Ocp-Apim-Subscription-Key' : 'api-key']:\n loadApiKey({\n apiKey,\n environmentVariableName: 'AZURE_API_KEY',\n description:\n api === 'speech'\n ? 'Azure Speech'\n : api === 'mai'\n ? 'Azure MAI'\n : 'Azure OpenAI',\n }),\n };\n\n return withUserAgentSuffix(\n {\n ...authHeaders,\n ...options.headers,\n },\n `ai-sdk-azure/${VERSION}`,\n );\n });\n\n const fetch: FetchFunction | undefined = tokenProvider\n ? async (input, init) => {\n const headers = normalizeHeaders(init?.headers);\n\n if (headers.authorization == null) {\n headers.authorization = `Bearer ${await tokenProvider()}`;\n }\n\n return (options.fetch ?? globalThis.fetch)(input, {\n ...init,\n headers,\n });\n }\n : options.fetch;\n\n const getResourceName = () => {\n const resourceName = loadSetting({\n settingValue: options.resourceName,\n settingName: 'resourceName',\n environmentVariableName: 'AZURE_RESOURCE_NAME',\n description: 'Azure OpenAI resource name',\n });\n\n // The resource name becomes part of the request host, so only a DNS label\n // is accepted (e.g. `user@internal:8080/#` would rewrite the host).\n if (!isValidHostnamePart(resourceName)) {\n throw new InvalidArgumentError({\n argument: 'resourceName',\n message:\n 'Invalid Azure resource name. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',\n });\n }\n\n return resourceName;\n };\n\n const apiVersion = options.apiVersion ?? 'v1';\n const {\n isAzureOpenAI,\n isFoundryProject,\n isVersioned: isAzureOpenAIVersioned,\n } = getAzureOpenAIBaseURLInfo(options.baseURL);\n\n const url = ({ path, modelId }: { path: string; modelId: string }) => {\n const baseUrlPrefix = withoutTrailingSlash(\n options.baseURL ?? `https://${getResourceName()}.openai.azure.com/openai`,\n );\n\n let fullUrl: URL;\n if (options.useDeploymentBasedUrls) {\n // Use deployment-based format for compatibility with certain Azure OpenAI models\n fullUrl = new URL(`${baseUrlPrefix}/deployments/${modelId}${path}`);\n } else if (!isAzureOpenAI || isAzureOpenAIVersioned) {\n // Custom gateways can own Azure routing and versioning themselves.\n // Complete Azure OpenAI v1 URLs also own their versioning.\n fullUrl = new URL(`${baseUrlPrefix}${path}`);\n } else {\n // Use v1 API format - no deployment ID in URL\n fullUrl = new URL(`${baseUrlPrefix}/v1${path}`);\n }\n\n if (\n options.useDeploymentBasedUrls ||\n (isAzureOpenAI && !isAzureOpenAIVersioned && !isFoundryProject)\n ) {\n fullUrl.searchParams.set('api-version', apiVersion);\n }\n\n return fullUrl.toString();\n };\n\n const createChatModel = (\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ) =>\n new OpenAIChatLanguageModel(settings?.modelId ?? deploymentId, {\n provider: 'azure.chat',\n requestModelId: deploymentId,\n url,\n headers: getHeaders,\n fetch,\n });\n\n const createDeepSeekModel = (deploymentName: string) =>\n new DeepSeekChatLanguageModel(deploymentName, {\n provider: 'azure.deepseek',\n url,\n headers: getHeaders,\n fetch,\n supportsPenaltySampling: true,\n supportsThinking: false,\n // json_object with thinking enabled makes Azure return the JSON in reasoning_content with empty content\n supportsStructuredOutputs: true,\n });\n\n const createCompletionModel = (\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ) =>\n new OpenAICompletionLanguageModel(settings?.modelId ?? deploymentId, {\n provider: 'azure.completion',\n requestModelId: deploymentId,\n url,\n headers: getHeaders,\n fetch,\n });\n\n const createEmbeddingModel = (modelId: string) =>\n new OpenAIEmbeddingModel(modelId, {\n provider: 'azure.embeddings',\n headers: getHeaders,\n url,\n fetch,\n });\n\n const createResponsesModel = (\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ) =>\n new OpenAIResponsesLanguageModel(settings?.modelId ?? deploymentId, {\n provider: 'azure.responses',\n requestModelId: deploymentId,\n url,\n headers: getHeaders,\n fetch,\n explicitMessageItemType: isFoundryProject,\n // Soft-deprecated. TODO: remove in v8\n fileIdPrefixes: ['assistant-'],\n });\n\n const maiBaseURL = () =>\n withoutTrailingSlash(options.maiBaseURL) ??\n `https://${getResourceName()}.services.ai.azure.com/mai/v1`;\n\n // Always provide a raw delegate, including when no custom fetch is set, so\n // file downloads cannot fall back to the token-injecting API fetch wrapper.\n const downloadFetch: FetchFunction = (input, init) =>\n (options.fetch ?? globalThis.fetch)(input, init);\n\n const createImageModel = (modelId: string) =>\n new AzureImageModel(\n modelId,\n options,\n new OpenAIImageModel(modelId, {\n provider: 'azure.image',\n url,\n headers: getHeaders,\n fetch,\n downloadFetch,\n // Azure model IDs are user-defined deployment names, so OpenAI model\n // family capabilities cannot be inferred from them.\n imageInputCapabilities: {\n supportsFileInputs: undefined,\n supportsMaskInputs: undefined,\n },\n }),\n new AzureMaiImageModel(modelId, {\n url: path => `${maiBaseURL()}${path}`,\n headers: () => getHeaders('mai'),\n fetch,\n downloadFetch,\n }),\n );\n\n const speechBaseURL = () =>\n withoutTrailingSlash(options.speechBaseURL) ??\n `https://${getResourceName()}.cognitiveservices.azure.com`;\n\n const createTranscriptionModel = (modelId: string) =>\n new AzureTranscriptionModel(\n modelId,\n options,\n new OpenAITranscriptionModel(modelId, {\n provider: 'azure.transcription',\n url,\n headers: getHeaders,\n fetch,\n }),\n new AzureSpeechTranscriptionModel(modelId, {\n url: () =>\n `${speechBaseURL()}/speechtotext/transcriptions:transcribe?api-version=2025-10-15`,\n headers: () => getHeaders('speech'),\n fetch,\n }),\n new AzureMaiTranscriptionModel(modelId, {\n url: () => `${maiBaseURL()}/realtime?intent=transcription`,\n headers: async () =>\n tokenProvider\n ? {\n authorization: `Bearer ${await tokenProvider()}`,\n ...(await getHeaders('mai')),\n }\n : getHeaders('mai'),\n webSocket: options.webSocket,\n }),\n );\n\n const createSpeechModel = (modelId: string) =>\n new AzureSpeechModel(\n modelId,\n options,\n new OpenAISpeechModel(modelId, {\n provider: 'azure.speech',\n url,\n headers: getHeaders,\n fetch,\n }),\n new AzureSpeechSpeechModel(modelId, {\n url: () => `${speechBaseURL()}/tts/cognitiveservices/v1`,\n headers: () => getHeaders('speech'),\n fetch,\n }),\n );\n\n const provider = function (\n deploymentId: string,\n settings?: AzureOpenAILanguageModelSettings,\n ) {\n if (new.target) {\n throw new Error(\n 'The Azure OpenAI model function cannot be called with the new keyword.',\n );\n }\n\n return createResponsesModel(deploymentId, settings);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createResponsesModel;\n provider.chat = createChatModel;\n provider.deepseek = createDeepSeekModel;\n provider.completion = createCompletionModel;\n provider.embedding = createEmbeddingModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n provider.responses = createResponsesModel;\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n provider.tools = azureOpenaiTools;\n return provider;\n}\n\n/**\n * Default Azure OpenAI provider instance.\n */\nexport const azure = createAzure();\n\n// Resolves the API per request: providerOptions also reach this model via Gateway.\nclass AzureTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.transcription';\n\n constructor(\n readonly modelId: string,\n private readonly config: AzureOpenAIProviderSettings,\n private readonly openai: OpenAITranscriptionModel,\n private readonly speech: AzureSpeechTranscriptionModel,\n private readonly mai: AzureMaiTranscriptionModel,\n ) {}\n\n static [WORKFLOW_SERIALIZE](model: AzureTranscriptionModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: string;\n config: AzureOpenAIProviderSettings;\n }) {\n return createAzure(options.config).transcription(options.modelId);\n }\n\n async doGenerate(options: Parameters<TranscriptionModelV4['doGenerate']>[0]) {\n const { api, speechOptions, maiOptions, openaiOptions } =\n await this.getOptions(options.providerOptions);\n if (api === 'mai') {\n return this.mai.doGenerate();\n }\n if (api === 'speech') {\n const result = await this.speech.doGenerate(options, speechOptions);\n return {\n ...result,\n warnings: [\n ...result.warnings,\n ...maiOnlyWarnings(maiOptions),\n ...openaiTranscriptionOnlyWarnings(openaiOptions),\n ],\n };\n }\n\n const result = await this.openai.doGenerate(\n withAzureOptionsForOpenAI(options, openaiOptions),\n );\n return {\n ...result,\n warnings: [...result.warnings, ...speechOnlyWarnings(speechOptions)],\n };\n }\n\n async doStream(\n options: Parameters<NonNullable<TranscriptionModelV4['doStream']>>[0],\n ) {\n const { api, speechOptions, maiOptions, openaiOptions } =\n await this.getOptions(options.providerOptions);\n if (api === 'speech') {\n throw new UnsupportedFunctionalityError({\n functionality: 'streaming transcription with the Azure Speech API',\n });\n }\n if (api === 'mai') {\n return this.mai.doStream(options, maiOptions, [\n ...speechOnlyWarnings(speechOptions),\n ...openaiTranscriptionOnlyWarnings(openaiOptions),\n ]);\n }\n return this.openai.doStream(\n withAzureOptionsForOpenAI(options, openaiOptions),\n );\n }\n\n private async getOptions(\n providerOptions: Parameters<\n TranscriptionModelV4['doGenerate']\n >[0]['providerOptions'],\n ) {\n const { api, language, ...options } =\n (await parseProviderOptions({\n provider: 'azure',\n providerOptions,\n schema: azureTranscriptionModelOptions,\n })) ?? {};\n return {\n api:\n api ??\n (isMAITranscribeStreaming(this.modelId)\n ? ('mai' as const)\n : getMAITranscribeModel(this.modelId)\n ? ('speech' as const)\n : ('openai' as const)),\n speechOptions: pickKeys(\n options,\n azureSpeechTranscriptionModelOptionsShape(),\n ),\n maiOptions: language != null ? { language } : {},\n openaiOptions: pickAzureOptions(\n providerOptions,\n openAITranscriptionModelOptionsShape(),\n ),\n };\n }\n}\n\n// Resolves the API per request: providerOptions also reach this model via Gateway.\nclass AzureSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.speech';\n\n constructor(\n readonly modelId: string,\n private readonly config: AzureOpenAIProviderSettings,\n private readonly openai: OpenAISpeechModel,\n private readonly speech: AzureSpeechSpeechModel,\n ) {}\n\n static [WORKFLOW_SERIALIZE](model: AzureSpeechModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: string;\n config: AzureOpenAIProviderSettings;\n }) {\n return createAzure(options.config).speech(options.modelId);\n }\n\n async doGenerate(options: Parameters<SpeechModelV4['doGenerate']>[0]) {\n const { api, ...parsedOptions } =\n (await parseProviderOptions({\n provider: 'azure',\n providerOptions: options.providerOptions,\n schema: azureSpeechModelOptions,\n })) ?? {};\n const speechOptions = pickKeys(\n parsedOptions,\n azureSpeechSpeechModelOptionsShape(),\n );\n const openaiOptions = pickAzureOptions(\n options.providerOptions,\n openaiSpeechModelOptionsShape(),\n );\n if (\n (api ?? (getMAIVoiceModel(this.modelId) ? 'speech' : 'openai')) ===\n 'speech'\n ) {\n const result = await this.speech.doGenerate(options, speechOptions);\n return {\n ...result,\n warnings: [\n ...result.warnings,\n ...unsupportedOptionWarnings(\n openaiOptions,\n 'This option requires the OpenAI speech API.',\n ),\n ],\n };\n }\n\n const result = await this.openai.doGenerate(\n withAzureOptionsForOpenAI(options, openaiOptions),\n );\n return {\n ...result,\n warnings: [...result.warnings, ...speechOnlyWarnings(speechOptions)],\n };\n }\n}\n\n// Resolves the API per request: providerOptions also reach this model via Gateway.\nclass AzureImageModel implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.image';\n\n constructor(\n readonly modelId: string,\n private readonly config: AzureOpenAIProviderSettings,\n private readonly openai: OpenAIImageModel,\n private readonly mai: AzureMaiImageModel,\n ) {}\n\n // Capabilities follow the default route; an `api` override is per request.\n private get defaultModel() {\n return isMAIImageModel(this.modelId) ? this.mai : this.openai;\n }\n\n get maxImagesPerCall() {\n return this.defaultModel.maxImagesPerCall;\n }\n\n get supportsFileInputs() {\n return this.defaultModel.supportsFileInputs;\n }\n\n get supportsMaskInputs() {\n return this.defaultModel.supportsMaskInputs;\n }\n\n static [WORKFLOW_SERIALIZE](model: AzureImageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: string;\n config: AzureOpenAIProviderSettings;\n }) {\n return createAzure(options.config).image(options.modelId);\n }\n\n async doGenerate(options: Parameters<ImageModelV4['doGenerate']>[0]) {\n // `background` is shared with the OpenAI API, so it is not MAI-only.\n const { api, background, ...maiOnlyOptions } =\n (await parseProviderOptions({\n provider: 'azure',\n providerOptions: options.providerOptions,\n schema: azureImageModelOptions,\n })) ?? {};\n if ((api ?? (isMAIImageModel(this.modelId) ? 'mai' : 'openai')) === 'mai') {\n if (background !== 'auto') {\n return this.mai.doGenerate(options, { ...maiOnlyOptions, background });\n }\n const result = await this.mai.doGenerate(options, maiOnlyOptions);\n return {\n ...result,\n warnings: [\n ...result.warnings,\n {\n type: 'unsupported',\n feature: 'providerOptions.azure.background',\n details:\n \"The MAI image API supports 'transparent' and 'opaque' backgrounds.\",\n } satisfies SharedV4Warning,\n ],\n };\n }\n\n const result = await this.openai.doGenerate(\n withAzureOptionsForOpenAI(\n options,\n pickAzureOptions(\n options.providerOptions,\n options.files != null\n ? openaiImageModelEditOptionsShape()\n : openaiImageModelGenerationOptionsShape(),\n ),\n ),\n );\n return {\n ...result,\n warnings: [\n ...result.warnings,\n ...unsupportedOptionWarnings(\n maiOnlyOptions,\n 'This option requires the MAI image API.',\n ),\n ],\n };\n }\n}\n\n/**\n * Picks the options that the given schema shape accepts from the raw `azure`\n * provider options. Raw values are used so schema defaults are not injected;\n * the OpenAI model validates them again.\n */\nfunction pickAzureOptions(\n providerOptions: SharedV4ProviderOptions | undefined,\n shape: Record<string, unknown>,\n): Record<string, unknown> {\n return pickKeys(providerOptions?.azure ?? {}, shape);\n}\n\nfunction pickKeys(\n options: Record<string, unknown>,\n shape: Record<string, unknown>,\n): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(options).filter(\n ([key, value]) => Object.hasOwn(shape, key) && value !== undefined,\n ),\n );\n}\n\n/**\n * Azure OpenAI deployments accept their OpenAI API options under `azure` as\n * well as `openai`. Both are merged into `openai` for the OpenAI model; `azure`\n * wins, like it does for Azure chat and completion models.\n */\nfunction withAzureOptionsForOpenAI<\n OPTIONS extends { providerOptions?: SharedV4ProviderOptions },\n>(options: OPTIONS, azureOptions: Record<string, unknown>): OPTIONS {\n if (Object.keys(azureOptions).length === 0) {\n return options;\n }\n\n return {\n ...options,\n providerOptions: {\n ...options.providerOptions,\n openai: {\n ...options.providerOptions?.openai,\n ...azureOptions,\n } as SharedV4ProviderOptions[string],\n },\n };\n}\n\nfunction openaiTranscriptionOnlyWarnings(options: Record<string, unknown>) {\n // `language` is shared with MAI and reported by `maiOnlyWarnings`.\n const { language: _language, ...openaiOnlyOptions } = options;\n return unsupportedOptionWarnings(\n openaiOnlyOptions,\n 'This option requires the OpenAI transcription API.',\n );\n}\n\nfunction speechOnlyWarnings(options: Record<string, unknown>) {\n return unsupportedOptionWarnings(\n options,\n 'This option requires the Azure Speech API.',\n );\n}\n\nfunction maiOnlyWarnings(options: Record<string, unknown>) {\n return unsupportedOptionWarnings(\n options,\n 'This option requires MAI streaming transcription.',\n );\n}\n\nfunction unsupportedOptionWarnings(\n options: Record<string, unknown>,\n details: string,\n): SharedV4Warning[] {\n return Object.entries(options)\n .filter(([, value]) => value !== undefined)\n .map(([key]) => ({\n type: 'unsupported',\n feature: `providerOptions.azure.${key}`,\n details,\n }));\n}\n"],"mappings":";;;;;;AA0DA,SAAS,WAAW,EAClB,eAAe,OACf,aAAa,UACuC,CAAC,GAAoB;CACzE,OAAO;EACL,cAAc,EACZ,OAAO;GACL,OAAO,EACL,aAAa,yDACf;GACA,WAAW;GACX,WAAW;GACX,kBAAkB;EACpB,EACF;EACA,iBAAiB,EACf,OAAO;GACL,KAAK;GACL,iBAAiB;GACjB;GACA;EACF,EACF;EACA,eAAe,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE;CACzC;AACF;AAEA,SAAS,YAAY,YAAqC;CACxD,OAAO;EACL,cAAc,EAAE,QAAQ,EAAE,cAAc,MAAM,EAAE;EAChD,iBAAiB,EACf,QAAQ;GACN,KAAK;GACL,OAAO,EACL,WAAW,2DACb;GACA,aAAa,EAAE,WAAW,uCAAuC;EACnE,EACF;EACA,eAAe,EAAE,QAAQ;GAAE,KAAK;GAAU;EAAW,EAAE;CACzD;AACF;AAEA,SAAS,mBACP,MACA,oBACiB;CACjB,OAAO;EACL,cAAc,EACZ,eAAe;GACb,eAAe;GACf,WAAW;GACX,UAAU;GACV,UAAU;GACV,UAAU;EACZ,EACF;EACA,iBAAiB,EACf,eAAe;GACb,KAAK;GACL,UAAU,EAAE,WAAW,2CAA2C;GAClE,YAAY,qBACR,OACA,EAAE,WAAW,0BAA0B;GAC3C,iBAAiB,qBACb,OACA,EAAE,WAAW,8BAA8B;GAC/C,SAAS;GACT,aAA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,SAAS,iBACP,iBACA,OACyB;CACzB,OAAO,SAAS,iBAAiB,SAAS,CAAC,GAAG,KAAK;AACrD;AAEA,SAAS,SACP,SACA,OACyB;CACzB,OAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,CAAC,CAAC,QACrB,CAAC,KAAK,WAAW,OAAO,OAAO,OAAO,GAAG,KAAK,UAAU,KAAA,CAC3D,CACF;AACF;;;;;;AAOA,SAAS,0BAEP,SAAkB,cAAgD;CAClE,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,GACvC,OAAO;CAGT,OAAO;EACL,GAAG;EACH,iBAAiB;GACf,GAAG,QAAQ;GACX,QAAQ;IACN,GAAG,QAAQ,iBAAiB;IAC5B,GAAG;GACL;EACF;CACF;AACF;AAEA,SAAS,gCAAgC,SAAkC;CAEzE,MAAM,EAAE,UAAU,WAAW,GAAG,sBAAsB;CACtD,OAAO,0BACL,mBACA,oDACF;AACF;AAEA,SAAS,mBAAmB,SAAkC;CAC5D,OAAO,0BACL,SACA,4CACF;AACF;AAEA,SAAS,gBAAgB,SAAkC;CACzD,OAAO,0BACL,SACA,mDACF;AACF;AAEA,SAAS,0BACP,SACA,SACmB;CACnB,OAAO,OAAO,QAAQ,OAAO,CAAC,CAC3B,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CAAC,CAC1C,KAAK,CAAC,UAAU;EACf,MAAM;EACN,SAAS,yBAAyB;EAClC;CACF,EAAE;AACN"}
|
package/docs/04-azure.mdx
CHANGED
|
@@ -1548,6 +1548,8 @@ The table lists supported DALL-E backing models and Azure MAI image IDs. For Ope
|
|
|
1548
1548
|
| `mai-image-2.5-pro` | Sides must be multiples of 16 and at least 768 pixels. |
|
|
1549
1549
|
| `mai-image-2.6` | Sides must be multiples of 16 and at least 768 pixels. |
|
|
1550
1550
|
| `mai-image-2.6-flash` | Sides must be multiples of 16 and at least 768 pixels. |
|
|
1551
|
+
| `mai-image-2.7` | Sides must be multiples of 16 and at least 768 pixels. |
|
|
1552
|
+
| `mai-image-2.7-flash` | Sides must be multiples of 16 and at least 768 pixels. |
|
|
1551
1553
|
|
|
1552
1554
|
{/* model-capabilities:azure-image:end */}
|
|
1553
1555
|
|
|
@@ -1570,8 +1572,9 @@ capabilities of a deployment, you can advertise them with the
|
|
|
1570
1572
|
|
|
1571
1573
|
### MAI-Image
|
|
1572
1574
|
|
|
1573
|
-
MAI-Image models (`MAI-Image-2.
|
|
1574
|
-
`MAI-Image-2.
|
|
1575
|
+
MAI-Image models (`MAI-Image-2.7`, `MAI-Image-2.7-Flash`, `MAI-Image-2.6`,
|
|
1576
|
+
`MAI-Image-2.6-Flash`, `MAI-Image-2.5`, `MAI-Image-2.5-Flash`,
|
|
1577
|
+
`MAI-Image-2.5-Pro`) use the MAI image API at
|
|
1575
1578
|
`https://{resourceName}.services.ai.azure.com/mai/v1` (override with
|
|
1576
1579
|
`maiBaseURL`). Deployments named after the model are detected automatically,
|
|
1577
1580
|
case-insensitively. For other deployment names, set
|
|
@@ -1593,6 +1596,18 @@ const { image, usage } = await generateImage({
|
|
|
1593
1596
|
});
|
|
1594
1597
|
```
|
|
1595
1598
|
|
|
1599
|
+
MAI-Image-2.7 models can return an image with a transparent background:
|
|
1600
|
+
|
|
1601
|
+
```ts
|
|
1602
|
+
const { image } = await generateImage({
|
|
1603
|
+
model: azure.image('MAI-Image-2.7'),
|
|
1604
|
+
prompt: 'A red apple sticker',
|
|
1605
|
+
providerOptions: {
|
|
1606
|
+
azure: { background: 'transparent' } satisfies AzureImageModelOptions,
|
|
1607
|
+
},
|
|
1608
|
+
});
|
|
1609
|
+
```
|
|
1610
|
+
|
|
1596
1611
|
Pass reference images to edit or combine them (up to five JPEG or PNG
|
|
1597
1612
|
images). Masks are not supported.
|
|
1598
1613
|
|
|
@@ -1608,8 +1623,8 @@ const { image } = await generateImage({
|
|
|
1608
1623
|
|
|
1609
1624
|
Each request returns one PNG image; `generateImage` sends one request per image.
|
|
1610
1625
|
`size` is sent as `width` and `height`. Each side must be at least 768 pixels,
|
|
1611
|
-
and
|
|
1612
|
-
1,048,576 for MAI-Image-2.5 models. Without `size`, `aspectRatio` is mapped to
|
|
1626
|
+
and each output is at most 2048x2048 for MAI-Image-2.7 models, 2,359,296 pixels
|
|
1627
|
+
for MAI-Image-2.6 models, and 1,048,576 pixels for MAI-Image-2.5 models. Without `size`, `aspectRatio` is mapped to
|
|
1613
1628
|
dimensions of about one megapixel; without either, the model returns 1024x1024.
|
|
1614
1629
|
`seed` is not supported. Token usage is returned in `usage`, with the input
|
|
1615
1630
|
text and image token split in `providerMetadata.azure.images`.
|
|
@@ -1623,11 +1638,20 @@ The following provider options are available:
|
|
|
1623
1638
|
- **autoAspectRatio** _boolean_
|
|
1624
1639
|
|
|
1625
1640
|
Let the model choose the output aspect ratio from the prompt and reference
|
|
1626
|
-
images. MAI-Image-2.6 models only.
|
|
1641
|
+
images. MAI-Image-2.6 and MAI-Image-2.7 models only.
|
|
1627
1642
|
|
|
1628
1643
|
- **webGrounding** _boolean_
|
|
1629
1644
|
|
|
1630
|
-
Ground generation in Bing web search results. MAI-Image-2.6
|
|
1645
|
+
Ground generation in Bing web search results. MAI-Image-2.6 and
|
|
1646
|
+
MAI-Image-2.7 models only.
|
|
1647
|
+
|
|
1648
|
+
- **background** _'transparent' | 'opaque'_
|
|
1649
|
+
|
|
1650
|
+
Image background for generations and edits. `transparent` returns a PNG with
|
|
1651
|
+
an alpha channel; the API defaults to `opaque`. MAI-Image-2.7 models only.
|
|
1652
|
+
The same option is passed through to OpenAI image deployments, which also
|
|
1653
|
+
accept `'auto'`; on the MAI image API, `'auto'` is not sent and produces a
|
|
1654
|
+
warning.
|
|
1631
1655
|
|
|
1632
1656
|
## Transcription Models
|
|
1633
1657
|
|
|
@@ -2058,6 +2082,7 @@ The following option definitions are generated from the provider catalog.
|
|
|
2058
2082
|
| image | `api` | Select the OpenAI or MAI image API. |
|
|
2059
2083
|
| image | `autoAspectRatio` | Choose the aspect ratio automatically. |
|
|
2060
2084
|
| image | `webGrounding` | Ground image generation in web search. |
|
|
2085
|
+
| image | `background` | Transparent or opaque image background. |
|
|
2061
2086
|
| speech | `api` | Select the OpenAI or Azure Speech API. |
|
|
2062
2087
|
| speech | `style` | Speaking style supported by the selected voice. |
|
|
2063
2088
|
| speech | `styleDegree` | Intensity of the speaking style. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/azure",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.128",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/deepseek": "3.0.
|
|
33
|
-
"@ai-sdk/openai": "4.0.
|
|
34
|
-
"@ai-sdk/provider": "4.0.
|
|
35
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
32
|
+
"@ai-sdk/deepseek": "3.0.88",
|
|
33
|
+
"@ai-sdk/openai": "4.0.120",
|
|
34
|
+
"@ai-sdk/provider": "4.0.39",
|
|
35
|
+
"@ai-sdk/provider-utils": "5.0.82"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@ai-sdk/test-server": "2.0.4",
|
|
39
39
|
"@types/node": "22.19.19",
|
|
40
40
|
"@vercel/ai-tsconfig": "0.0.0",
|
|
41
41
|
"@vercel/ai-tsdown-config": "0.0.0",
|
|
42
|
-
"ai": "7.0.
|
|
42
|
+
"ai": "7.0.175",
|
|
43
43
|
"tsdown": "^0.23.0",
|
|
44
44
|
"typescript": "6.0.3",
|
|
45
45
|
"zod": "4.6.7"
|
|
@@ -15,6 +15,12 @@ export const azureImageModelOptions = lazySchema(() =>
|
|
|
15
15
|
*/
|
|
16
16
|
api: z.enum(['openai', 'mai']).optional(),
|
|
17
17
|
...azureMaiImageModelOptionsShape(),
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Image background. The MAI image API (MAI-Image-2.7 models) supports
|
|
21
|
+
* `transparent` and `opaque`; OpenAI image deployments also accept `auto`.
|
|
22
|
+
*/
|
|
23
|
+
background: z.enum(['transparent', 'opaque', 'auto']).optional(),
|
|
18
24
|
}),
|
|
19
25
|
),
|
|
20
26
|
);
|
|
@@ -8,14 +8,21 @@ import { z } from 'zod/v4';
|
|
|
8
8
|
export const azureMaiImageModelOptionsShape = () => ({
|
|
9
9
|
/**
|
|
10
10
|
* Let the model pick the output aspect ratio from the prompt and any
|
|
11
|
-
* reference images. MAI-Image-2.6 models only.
|
|
11
|
+
* reference images. MAI-Image-2.6 and MAI-Image-2.7 models only.
|
|
12
12
|
*/
|
|
13
13
|
autoAspectRatio: z.boolean().optional(),
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Ground generation in Bing web search results. MAI-Image-2.6
|
|
16
|
+
* Ground generation in Bing web search results. MAI-Image-2.6 and
|
|
17
|
+
* MAI-Image-2.7 models only.
|
|
17
18
|
*/
|
|
18
19
|
webGrounding: z.boolean().optional(),
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Image background. `transparent` returns a PNG with an alpha channel;
|
|
23
|
+
* the API defaults to `opaque`. MAI-Image-2.7 models only.
|
|
24
|
+
*/
|
|
25
|
+
background: z.enum(['transparent', 'opaque']).optional(),
|
|
19
26
|
});
|
|
20
27
|
|
|
21
28
|
export const azureMaiImageModelOptions = lazySchema(() =>
|
|
@@ -60,7 +60,11 @@ export class AzureMaiImageModel implements ImageModelV4 {
|
|
|
60
60
|
headers,
|
|
61
61
|
abortSignal,
|
|
62
62
|
}: Parameters<ImageModelV4['doGenerate']>[0],
|
|
63
|
-
{
|
|
63
|
+
{
|
|
64
|
+
autoAspectRatio,
|
|
65
|
+
webGrounding,
|
|
66
|
+
background,
|
|
67
|
+
}: AzureImageModelMaiOptions = {},
|
|
64
68
|
): Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>> {
|
|
65
69
|
const currentDate = this.config._internal?.currentDate?.() ?? new Date();
|
|
66
70
|
const warnings: SharedV4Warning[] = [];
|
|
@@ -101,6 +105,7 @@ export class AzureMaiImageModel implements ImageModelV4 {
|
|
|
101
105
|
height: dimensions?.height,
|
|
102
106
|
auto_aspect_ratio: autoAspectRatio,
|
|
103
107
|
web_grounding: webGrounding,
|
|
108
|
+
background,
|
|
104
109
|
};
|
|
105
110
|
const requestOptions = {
|
|
106
111
|
headers: combineHeaders(await resolve(this.config.headers), headers),
|
|
@@ -19,6 +19,7 @@ export const azureProviderOptions = {
|
|
|
19
19
|
api: { description: 'Select the OpenAI or MAI image API.' },
|
|
20
20
|
autoAspectRatio: { description: 'Choose the aspect ratio automatically.' },
|
|
21
21
|
webGrounding: { description: 'Ground image generation in web search.' },
|
|
22
|
+
background: { description: 'Transparent or opaque image background.' },
|
|
22
23
|
} satisfies Record<keyof AzureImageModelOptions, ProviderOptionDefinition>,
|
|
23
24
|
speech: {
|
|
24
25
|
api: { description: 'Select the OpenAI or Azure Speech API.' },
|
|
@@ -55,7 +56,10 @@ type AzureRequestConfig = {
|
|
|
55
56
|
|
|
56
57
|
type AzureModelEntry = ModelEntry<AzureRequestConfig>;
|
|
57
58
|
|
|
58
|
-
function imageEntry(
|
|
59
|
+
function imageEntry({
|
|
60
|
+
webGrounding = false,
|
|
61
|
+
background = false,
|
|
62
|
+
}: { webGrounding?: boolean; background?: boolean } = {}): AzureModelEntry {
|
|
59
63
|
return {
|
|
60
64
|
capabilities: {
|
|
61
65
|
image: {
|
|
@@ -68,7 +72,12 @@ function imageEntry(webGrounding: boolean): AzureModelEntry {
|
|
|
68
72
|
},
|
|
69
73
|
},
|
|
70
74
|
providerOptions: {
|
|
71
|
-
image: {
|
|
75
|
+
image: {
|
|
76
|
+
api: true,
|
|
77
|
+
autoAspectRatio: webGrounding,
|
|
78
|
+
webGrounding,
|
|
79
|
+
background,
|
|
80
|
+
},
|
|
72
81
|
},
|
|
73
82
|
requestConfig: { image: { api: 'mai' } },
|
|
74
83
|
};
|
|
@@ -130,11 +139,13 @@ function transcriptionEntry(
|
|
|
130
139
|
* catalogs; arbitrary deployment names do not declare model-family support.
|
|
131
140
|
*/
|
|
132
141
|
export const azureModelCatalog: Readonly<Record<string, AzureModelEntry>> = {
|
|
133
|
-
'mai-image-2.5': imageEntry(
|
|
134
|
-
'mai-image-2.5-flash': imageEntry(
|
|
135
|
-
'mai-image-2.5-pro': imageEntry(
|
|
136
|
-
'mai-image-2.6': imageEntry(true),
|
|
137
|
-
'mai-image-2.6-flash': imageEntry(true),
|
|
142
|
+
'mai-image-2.5': imageEntry(),
|
|
143
|
+
'mai-image-2.5-flash': imageEntry(),
|
|
144
|
+
'mai-image-2.5-pro': imageEntry(),
|
|
145
|
+
'mai-image-2.6': imageEntry({ webGrounding: true }),
|
|
146
|
+
'mai-image-2.6-flash': imageEntry({ webGrounding: true }),
|
|
147
|
+
'mai-image-2.7': imageEntry({ webGrounding: true, background: true }),
|
|
148
|
+
'mai-image-2.7-flash': imageEntry({ webGrounding: true, background: true }),
|
|
138
149
|
'mai-voice-2.1-flash': speechEntry('MAI-Voice-2.1-Flash'),
|
|
139
150
|
'mai-voice-2.1': speechEntry('MAI-Voice-2.1'),
|
|
140
151
|
'mai-voice-2-flash': speechEntry('MAI-Voice-2-Flash'),
|
|
@@ -800,14 +800,30 @@ class AzureImageModel implements ImageModelV4 {
|
|
|
800
800
|
}
|
|
801
801
|
|
|
802
802
|
async doGenerate(options: Parameters<ImageModelV4['doGenerate']>[0]) {
|
|
803
|
-
|
|
803
|
+
// `background` is shared with the OpenAI API, so it is not MAI-only.
|
|
804
|
+
const { api, background, ...maiOnlyOptions } =
|
|
804
805
|
(await parseProviderOptions({
|
|
805
806
|
provider: 'azure',
|
|
806
807
|
providerOptions: options.providerOptions,
|
|
807
808
|
schema: azureImageModelOptions,
|
|
808
809
|
})) ?? {};
|
|
809
810
|
if ((api ?? (isMAIImageModel(this.modelId) ? 'mai' : 'openai')) === 'mai') {
|
|
810
|
-
|
|
811
|
+
if (background !== 'auto') {
|
|
812
|
+
return this.mai.doGenerate(options, { ...maiOnlyOptions, background });
|
|
813
|
+
}
|
|
814
|
+
const result = await this.mai.doGenerate(options, maiOnlyOptions);
|
|
815
|
+
return {
|
|
816
|
+
...result,
|
|
817
|
+
warnings: [
|
|
818
|
+
...result.warnings,
|
|
819
|
+
{
|
|
820
|
+
type: 'unsupported',
|
|
821
|
+
feature: 'providerOptions.azure.background',
|
|
822
|
+
details:
|
|
823
|
+
"The MAI image API supports 'transparent' and 'opaque' backgrounds.",
|
|
824
|
+
} satisfies SharedV4Warning,
|
|
825
|
+
],
|
|
826
|
+
};
|
|
811
827
|
}
|
|
812
828
|
|
|
813
829
|
const result = await this.openai.doGenerate(
|
|
@@ -826,7 +842,7 @@ class AzureImageModel implements ImageModelV4 {
|
|
|
826
842
|
warnings: [
|
|
827
843
|
...result.warnings,
|
|
828
844
|
...unsupportedOptionWarnings(
|
|
829
|
-
|
|
845
|
+
maiOnlyOptions,
|
|
830
846
|
'This option requires the MAI image API.',
|
|
831
847
|
),
|
|
832
848
|
],
|