@ai-sdk/azure 4.0.82 → 4.0.84

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 CHANGED
@@ -1,5 +1,38 @@
1
1
  # @ai-sdk/azure
2
2
 
3
+ ## 4.0.84
4
+
5
+ ### Patch Changes
6
+
7
+ - 5b9f10b: Reject an Azure `resourceName` that is not a single DNS label, so a malformed value cannot rewrite the request host.
8
+ - c2511c1: fix: use standards-compliant User-Agent header
9
+ - Updated dependencies [c2511c1]
10
+ - @ai-sdk/deepseek@3.0.56
11
+ - @ai-sdk/openai@4.0.80
12
+ - @ai-sdk/provider-utils@5.0.51
13
+
14
+ ## 4.0.83
15
+
16
+ ### Patch Changes
17
+
18
+ - 354af1c: Add MAI-Transcribe-2 file transcription through `azure.transcription()` using the Azure Speech API, with diarization, word/segment timestamps, transcript styles, locale forcing, and phrase lists. Select the API with `providerOptions.azure.api` to override model-based routing, add a `speechBaseURL` setting for the Speech endpoint, and add `azure.transcriptionModel()` as an alias of `azure.transcription()`.
19
+ - 525efc5: feat(provider): advertise image model file and mask input support
20
+
21
+ Use confirmed model IDs for capability declarations so unrecognized model names
22
+ remain unknown. Include Together AI FLUX.2 Pro and Flex single-image editing, and
23
+ allow asynchronous capability lookups and middleware overrides to resolve to
24
+ unknown.
25
+
26
+ Advertise QuiverAI Arrow 2 and Arrow 2 Telos file-input support, and mark Together
27
+ AI Gemini image inputs unsupported by the current single-image request mapping.
28
+
29
+ - Updated dependencies [e3605f6]
30
+ - Updated dependencies [525efc5]
31
+ - @ai-sdk/provider-utils@5.0.50
32
+ - @ai-sdk/openai@4.0.79
33
+ - @ai-sdk/deepseek@3.0.55
34
+ - @ai-sdk/provider@4.0.19
35
+
3
36
  ## 4.0.82
4
37
 
5
38
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { DeepSeekLanguageModelChatOptions } from '@ai-sdk/deepseek';
2
2
  export { OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions, OpenAILanguageModelChatOptions, OpenAILanguageModelResponsesOptions, OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions, OpenAIResponsesSystemMessageOptions } from '@ai-sdk/openai';
3
3
  import { ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4 } from '@ai-sdk/provider';
4
- import { FetchFunction } from '@ai-sdk/provider-utils';
4
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
5
+ import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
5
6
  import { codeInterpreter, fileSearch, imageGeneration, webSearch, webSearchPreview, ResponsesProviderMetadata, ResponsesReasoningProviderMetadata, ResponsesSourceDocumentProviderMetadata, ResponsesTextProviderMetadata } from '@ai-sdk/openai/internal';
6
7
 
7
8
  declare const azureOpenaiTools: {
@@ -59,9 +60,14 @@ interface AzureOpenAIProvider extends ProviderV4 {
59
60
  */
60
61
  imageModel(deploymentId: string): ImageModelV4;
61
62
  /**
62
- * Creates an Azure OpenAI model for audio transcription.
63
+ * Creates an Azure transcription model. MAI-Transcribe-2 uses the Speech API
64
+ * by default; other IDs use OpenAI. Override with providerOptions.azure.api.
63
65
  */
64
66
  transcription(deploymentId: string): TranscriptionModelV4;
67
+ /**
68
+ * Creates an Azure transcription model. Alias of `transcription`.
69
+ */
70
+ transcriptionModel(deploymentId: string): TranscriptionModelV4;
65
71
  /**
66
72
  * Creates an Azure OpenAI model for speech generation.
67
73
  */
@@ -76,6 +82,7 @@ interface AzureOpenAIProviderSettings {
76
82
  * Name of the Azure OpenAI resource. Either this or `baseURL` can be used.
77
83
  *
78
84
  * The resource name is used in the assembled URL: `https://{resourceName}.openai.azure.com/openai/v1{path}`.
85
+ * It must be a single DNS label (letters, digits, and hyphens).
79
86
  */
80
87
  resourceName?: string;
81
88
  /**
@@ -117,6 +124,13 @@ interface AzureOpenAIProviderSettings {
117
124
  * `{baseURL}/v1{path}?api-version={apiVersion}`.
118
125
  */
119
126
  useDeploymentBasedUrls?: boolean;
127
+ /**
128
+ * URL prefix for Azure Speech transcription (MAI-Transcribe-2), e.g. a
129
+ * regional endpoint like `https://eastus.api.cognitive.microsoft.com`.
130
+ * Defaults to `https://{resourceName}.cognitiveservices.azure.com`.
131
+ * Speech requests do not use `baseURL` or `apiVersion`.
132
+ */
133
+ speechBaseURL?: string;
120
134
  }
121
135
  /**
122
136
  * Create an Azure OpenAI provider instance.
@@ -142,8 +156,40 @@ type AzureResponsesSourceDocumentProviderMetadata = {
142
156
 
143
157
  declare const VERSION: string;
144
158
 
159
+ declare const azureTranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema<{
160
+ timestamps?: "word" | "segment" | "none" | undefined;
161
+ transcribeStyle?: "verbatim" | "clean" | undefined;
162
+ locales?: string[] | undefined;
163
+ diarization?: {
164
+ enabled: boolean;
165
+ } | undefined;
166
+ phraseList?: {
167
+ phrases: string[];
168
+ } | undefined;
169
+ api?: "openai" | "speech" | undefined;
170
+ }>;
171
+ type AzureTranscriptionModelOptions = InferSchema<typeof azureTranscriptionModelOptions>;
172
+
173
+ type AzureTranscriptionProviderMetadata = {
174
+ azure: {
175
+ phrases: Array<{
176
+ text: string;
177
+ offsetMilliseconds?: number | null;
178
+ durationMilliseconds?: number | null;
179
+ locale?: string | null;
180
+ speaker?: number | null;
181
+ confidence?: number | null;
182
+ words?: Array<{
183
+ text: string;
184
+ offsetMilliseconds?: number | null;
185
+ durationMilliseconds?: number | null;
186
+ }> | null;
187
+ }>;
188
+ };
189
+ };
190
+
145
191
  type AzureDeepSeekLanguageModelOptions = Omit<DeepSeekLanguageModelChatOptions, 'thinking'>;
146
192
  /** @deprecated Use `AzureDeepSeekLanguageModelOptions` instead. */
147
193
  type AzureDeepSeekChatOptions = AzureDeepSeekLanguageModelOptions;
148
194
 
149
- export { type AzureDeepSeekChatOptions, type AzureDeepSeekLanguageModelOptions, type AzureOpenAIProvider, type AzureOpenAIProviderSettings, type AzureResponsesProviderMetadata, type AzureResponsesReasoningProviderMetadata, type AzureResponsesSourceDocumentProviderMetadata, type AzureResponsesTextProviderMetadata, VERSION, azure, createAzure };
195
+ export { type AzureDeepSeekChatOptions, type AzureDeepSeekLanguageModelOptions, type AzureOpenAIProvider, type AzureOpenAIProviderSettings, type AzureResponsesProviderMetadata, type AzureResponsesReasoningProviderMetadata, type AzureResponsesSourceDocumentProviderMetadata, type AzureResponsesTextProviderMetadata, type AzureTranscriptionModelOptions, type AzureTranscriptionProviderMetadata, VERSION, azure, createAzure };
package/dist/index.js CHANGED
@@ -10,12 +10,17 @@ import {
10
10
  } from "@ai-sdk/openai/internal";
11
11
  import { DeepSeekChatLanguageModel } from "@ai-sdk/deepseek/internal";
12
12
  import {
13
- InvalidArgumentError
13
+ InvalidArgumentError,
14
+ UnsupportedFunctionalityError
14
15
  } from "@ai-sdk/provider";
15
16
  import {
16
17
  loadApiKey,
17
18
  loadSetting,
18
19
  normalizeHeaders,
20
+ parseProviderOptions,
21
+ serializeModelOptions,
22
+ WORKFLOW_DESERIALIZE,
23
+ WORKFLOW_SERIALIZE,
19
24
  withoutTrailingSlash,
20
25
  withUserAgentSuffix
21
26
  } from "@ai-sdk/provider-utils";
@@ -36,8 +41,185 @@ var azureOpenaiTools = {
36
41
  webSearchPreview
37
42
  };
38
43
 
44
+ // src/azure-speech-transcription-model.ts
45
+ import {
46
+ combineHeaders,
47
+ convertBase64ToUint8Array,
48
+ createJsonErrorResponseHandler,
49
+ createJsonResponseHandler,
50
+ mediaTypeToExtension,
51
+ postFormDataToApi
52
+ } from "@ai-sdk/provider-utils";
53
+ import { z as z3 } from "zod/v4";
54
+
55
+ // src/azure-transcription-model-options.ts
56
+ import {
57
+ lazySchema as lazySchema2,
58
+ zodSchema as zodSchema2
59
+ } from "@ai-sdk/provider-utils";
60
+ import { z as z2 } from "zod/v4";
61
+
62
+ // src/azure-speech-transcription-model-options.ts
63
+ import {
64
+ lazySchema,
65
+ zodSchema
66
+ } from "@ai-sdk/provider-utils";
67
+ import { z } from "zod/v4";
68
+ var azureSpeechTranscriptionModelOptionsShape = () => ({
69
+ /**
70
+ * Timing granularity. Defaults to `segment` so that transcription results
71
+ * include timed segments (Azure's own default is `none`).
72
+ */
73
+ timestamps: z.enum(["word", "segment", "none"]).optional(),
74
+ /**
75
+ * `verbatim` keeps fillers and false starts, `clean` removes them.
76
+ * Azure defaults to `verbatim`.
77
+ */
78
+ transcribeStyle: z.enum(["verbatim", "clean"]).optional(),
79
+ /**
80
+ * Forces a single language, e.g. `['en']`. Omit for automatic language
81
+ * detection and code switching.
82
+ */
83
+ locales: z.array(z.string()).length(1).optional(),
84
+ /**
85
+ * Speaker diarization. Speaker IDs are available in provider metadata.
86
+ */
87
+ diarization: z.strictObject({ enabled: z.boolean() }).optional(),
88
+ /**
89
+ * Keyword biasing for names and domain terminology.
90
+ */
91
+ phraseList: z.strictObject({ phrases: z.array(z.string()) }).optional()
92
+ });
93
+ var azureSpeechTranscriptionModelOptions = lazySchema(
94
+ () => zodSchema(z.strictObject(azureSpeechTranscriptionModelOptionsShape()))
95
+ );
96
+
97
+ // src/azure-transcription-model-options.ts
98
+ var azureTranscriptionModelOptions = lazySchema2(
99
+ () => zodSchema2(
100
+ z2.strictObject({
101
+ /**
102
+ * API to use. Defaults to Speech for MAI-Transcribe-2, OpenAI otherwise.
103
+ */
104
+ api: z2.enum(["openai", "speech"]).optional(),
105
+ ...azureSpeechTranscriptionModelOptionsShape()
106
+ })
107
+ )
108
+ );
109
+ function isMAITranscribe2(modelId) {
110
+ return modelId.toLowerCase() === "mai-transcribe-2";
111
+ }
112
+
113
+ // src/azure-speech-transcription-model.ts
114
+ var AzureSpeechTranscriptionModel = class {
115
+ constructor(modelId, config) {
116
+ this.modelId = modelId;
117
+ this.config = config;
118
+ this.specificationVersion = "v4";
119
+ this.provider = "azure.transcription";
120
+ }
121
+ async doGenerate(options, azureOptions = {}) {
122
+ const timestamp = /* @__PURE__ */ new Date();
123
+ const formData = new FormData();
124
+ formData.append(
125
+ "audio",
126
+ new Blob(
127
+ [
128
+ typeof options.audio === "string" ? convertBase64ToUint8Array(options.audio) : options.audio
129
+ ],
130
+ { type: options.mediaType }
131
+ ),
132
+ `audio.${mediaTypeToExtension(options.mediaType)}`
133
+ );
134
+ formData.append(
135
+ "definition",
136
+ JSON.stringify({
137
+ enhancedMode: {
138
+ enabled: true,
139
+ model: isMAITranscribe2(this.modelId) ? "MAI-Transcribe-2" : this.modelId,
140
+ modelOptions: {
141
+ timestamps: azureOptions.timestamps ?? "segment",
142
+ transcribeStyle: azureOptions.transcribeStyle
143
+ }
144
+ },
145
+ locales: azureOptions.locales,
146
+ diarization: azureOptions.diarization,
147
+ phraseList: azureOptions.phraseList
148
+ })
149
+ );
150
+ const { value, rawValue, responseHeaders } = await postFormDataToApi({
151
+ url: this.config.url(),
152
+ headers: combineHeaders(this.config.headers(), options.headers),
153
+ formData,
154
+ abortSignal: options.abortSignal,
155
+ fetch: this.config.fetch,
156
+ failedResponseHandler: createJsonErrorResponseHandler({
157
+ errorSchema: z3.union([
158
+ z3.object({ error: z3.object({ message: z3.string() }) }),
159
+ z3.object({ message: z3.string() })
160
+ ]),
161
+ errorToMessage: (data) => "error" in data ? data.error.message : data.message
162
+ }),
163
+ successfulResponseHandler: createJsonResponseHandler(responseSchema)
164
+ });
165
+ const phrases = value.phrases ?? [];
166
+ const languages = new Set(
167
+ phrases.flatMap(
168
+ (phrase) => phrase.locale ? [phrase.locale.split("-")[0].toLowerCase()] : []
169
+ )
170
+ );
171
+ const [language] = languages;
172
+ const reportedLanguage = languages.size === 1 && /^[a-z]{2}$/.test(language) ? language : void 0;
173
+ return {
174
+ text: value.combinedPhrases.map((phrase) => phrase.text).join(" "),
175
+ segments: phrases.flatMap(
176
+ (phrase) => phrase.offsetMilliseconds != null && phrase.durationMilliseconds != null ? [
177
+ {
178
+ text: phrase.text,
179
+ startSecond: phrase.offsetMilliseconds / 1e3,
180
+ endSecond: (phrase.offsetMilliseconds + phrase.durationMilliseconds) / 1e3
181
+ }
182
+ ] : []
183
+ ),
184
+ language: reportedLanguage,
185
+ durationInSeconds: value.durationMilliseconds != null ? value.durationMilliseconds / 1e3 : void 0,
186
+ warnings: [],
187
+ providerMetadata: {
188
+ azure: { phrases }
189
+ },
190
+ response: {
191
+ timestamp,
192
+ modelId: this.modelId,
193
+ headers: responseHeaders,
194
+ body: rawValue
195
+ }
196
+ };
197
+ }
198
+ };
199
+ var responseSchema = z3.object({
200
+ combinedPhrases: z3.array(z3.object({ text: z3.string() })),
201
+ durationMilliseconds: z3.number().nullish(),
202
+ phrases: z3.array(
203
+ z3.object({
204
+ text: z3.string(),
205
+ offsetMilliseconds: z3.number().nullish(),
206
+ durationMilliseconds: z3.number().nullish(),
207
+ locale: z3.string().nullish(),
208
+ speaker: z3.number().nullish(),
209
+ confidence: z3.number().nullish(),
210
+ words: z3.array(
211
+ z3.object({
212
+ text: z3.string(),
213
+ offsetMilliseconds: z3.number().nullish(),
214
+ durationMilliseconds: z3.number().nullish()
215
+ })
216
+ ).nullish()
217
+ })
218
+ ).nullish()
219
+ });
220
+
39
221
  // src/version.ts
40
- var VERSION = true ? "4.0.82" : "0.0.0-test";
222
+ var VERSION = true ? "4.0.84" : "0.0.0-test";
41
223
 
42
224
  // src/azure-openai-provider.ts
43
225
  function getAzureOpenAIBaseURLInfo(baseURL) {
@@ -66,12 +248,12 @@ function createAzure(options = {}) {
66
248
  message: "Both apiKey and tokenProvider were provided. Please use only one authentication method."
67
249
  });
68
250
  }
69
- const getHeaders = () => {
251
+ const getHeaders = (api = "openai") => {
70
252
  const authHeaders = tokenProvider ? {} : {
71
- "api-key": loadApiKey({
253
+ [api === "speech" ? "Ocp-Apim-Subscription-Key" : "api-key"]: loadApiKey({
72
254
  apiKey: options.apiKey,
73
255
  environmentVariableName: "AZURE_API_KEY",
74
- description: "Azure OpenAI"
256
+ description: api === "speech" ? "Azure Speech" : "Azure OpenAI"
75
257
  })
76
258
  };
77
259
  return withUserAgentSuffix(
@@ -79,7 +261,7 @@ function createAzure(options = {}) {
79
261
  ...authHeaders,
80
262
  ...options.headers
81
263
  },
82
- `ai-sdk/azure/${VERSION}`
264
+ `ai-sdk-azure/${VERSION}`
83
265
  );
84
266
  };
85
267
  const fetch = tokenProvider ? async (input, init) => {
@@ -92,12 +274,21 @@ function createAzure(options = {}) {
92
274
  headers
93
275
  });
94
276
  } : options.fetch;
95
- const getResourceName = () => loadSetting({
96
- settingValue: options.resourceName,
97
- settingName: "resourceName",
98
- environmentVariableName: "AZURE_RESOURCE_NAME",
99
- description: "Azure OpenAI resource name"
100
- });
277
+ const getResourceName = () => {
278
+ const resourceName = loadSetting({
279
+ settingValue: options.resourceName,
280
+ settingName: "resourceName",
281
+ environmentVariableName: "AZURE_RESOURCE_NAME",
282
+ description: "Azure OpenAI resource name"
283
+ });
284
+ if (!/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.test(resourceName)) {
285
+ throw new InvalidArgumentError({
286
+ argument: "resourceName",
287
+ message: "Invalid Azure resource name. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints."
288
+ });
289
+ }
290
+ return resourceName;
291
+ };
101
292
  const apiVersion = options.apiVersion ?? "v1";
102
293
  const {
103
294
  isAzureOpenAI,
@@ -162,14 +353,29 @@ function createAzure(options = {}) {
162
353
  provider: "azure.image",
163
354
  url,
164
355
  headers: getHeaders,
165
- fetch
166
- });
167
- const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
168
- provider: "azure.transcription",
169
- url,
170
- headers: getHeaders,
171
- fetch
356
+ fetch,
357
+ // Azure model IDs are user-defined deployment names, so OpenAI model
358
+ // family capabilities cannot be inferred from them.
359
+ imageInputCapabilities: {
360
+ supportsFileInputs: void 0,
361
+ supportsMaskInputs: void 0
362
+ }
172
363
  });
364
+ const createTranscriptionModel = (modelId) => new AzureTranscriptionModel(
365
+ modelId,
366
+ options,
367
+ new OpenAITranscriptionModel(modelId, {
368
+ provider: "azure.transcription",
369
+ url,
370
+ headers: getHeaders,
371
+ fetch
372
+ }),
373
+ new AzureSpeechTranscriptionModel(modelId, {
374
+ url: () => `${withoutTrailingSlash(options.speechBaseURL) ?? `https://${getResourceName()}.cognitiveservices.azure.com`}/speechtotext/transcriptions:transcribe?api-version=2025-10-15`,
375
+ headers: () => getHeaders("speech"),
376
+ fetch
377
+ })
378
+ );
173
379
  const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
174
380
  provider: "azure.speech",
175
381
  url,
@@ -197,11 +403,71 @@ function createAzure(options = {}) {
197
403
  provider.imageModel = createImageModel;
198
404
  provider.responses = createResponsesModel;
199
405
  provider.transcription = createTranscriptionModel;
406
+ provider.transcriptionModel = createTranscriptionModel;
200
407
  provider.speech = createSpeechModel;
201
408
  provider.tools = azureOpenaiTools;
202
409
  return provider;
203
410
  }
204
411
  var azure = createAzure();
412
+ var AzureTranscriptionModel = class {
413
+ constructor(modelId, config, openai, speech) {
414
+ this.modelId = modelId;
415
+ this.config = config;
416
+ this.openai = openai;
417
+ this.speech = speech;
418
+ this.specificationVersion = "v4";
419
+ this.provider = "azure.transcription";
420
+ }
421
+ static [WORKFLOW_SERIALIZE](model) {
422
+ return serializeModelOptions({
423
+ modelId: model.modelId,
424
+ config: model.config
425
+ });
426
+ }
427
+ static [WORKFLOW_DESERIALIZE](options) {
428
+ return createAzure(options.config).transcription(options.modelId);
429
+ }
430
+ async doGenerate(options) {
431
+ const { api, ...speechOptions } = await this.getOptions(
432
+ options.providerOptions
433
+ );
434
+ if (api === "speech") {
435
+ return this.speech.doGenerate(options, speechOptions);
436
+ }
437
+ const result = await this.openai.doGenerate(options);
438
+ return {
439
+ ...result,
440
+ warnings: [
441
+ ...result.warnings,
442
+ ...Object.keys(speechOptions).map((key) => ({
443
+ type: "unsupported",
444
+ feature: `providerOptions.azure.${key}`,
445
+ details: "This option requires the Azure Speech API."
446
+ }))
447
+ ]
448
+ };
449
+ }
450
+ async doStream(options) {
451
+ const { api } = await this.getOptions(options.providerOptions);
452
+ if (api === "speech") {
453
+ throw new UnsupportedFunctionalityError({
454
+ functionality: "streaming transcription with the Azure Speech API"
455
+ });
456
+ }
457
+ return this.openai.doStream(options);
458
+ }
459
+ async getOptions(providerOptions) {
460
+ const options = await parseProviderOptions({
461
+ provider: "azure",
462
+ providerOptions,
463
+ schema: azureTranscriptionModelOptions
464
+ });
465
+ return {
466
+ ...options,
467
+ api: options?.api ?? (isMAITranscribe2(this.modelId) ? "speech" : "openai")
468
+ };
469
+ }
470
+ };
205
471
  export {
206
472
  VERSION,
207
473
  azure,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/azure-openai-provider.ts","../src/azure-openai-tools.ts","../src/version.ts"],"sourcesContent":["import {\n OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAISpeechModel,\n OpenAITranscriptionModel,\n} from '@ai-sdk/openai/internal';\nimport { DeepSeekChatLanguageModel } from '@ai-sdk/deepseek/internal';\nimport {\n InvalidArgumentError,\n type EmbeddingModelV4,\n type LanguageModelV4,\n type ProviderV4,\n type ImageModelV4,\n type SpeechModelV4,\n type TranscriptionModelV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n loadSetting,\n normalizeHeaders,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { azureOpenaiTools } from './azure-openai-tools';\nimport { VERSION } from './version';\n\nexport interface AzureOpenAIProvider extends ProviderV4 {\n (deploymentId: string): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI responses API model for text generation.\n */\n languageModel(deploymentId: string): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI chat model for text generation.\n */\n chat(deploymentId: string): 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 */\n responses(deploymentId: string): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI completion model for text generation.\n */\n completion(deploymentId: string): 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 OpenAI DALL-E model for image generation.\n */\n image(deploymentId: string): ImageModelV4;\n\n /**\n * Creates an Azure OpenAI DALL-E model for image generation.\n */\n imageModel(deploymentId: string): ImageModelV4;\n\n /**\n * Creates an Azure OpenAI model for audio transcription.\n */\n transcription(deploymentId: string): TranscriptionModelV4;\n\n /**\n * Creates an Azure OpenAI model for speech generation.\n */\n speech(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 */\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.\n */\n apiKey?: 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\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 = () => {\n const authHeaders = tokenProvider\n ? {}\n : {\n 'api-key': loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AZURE_API_KEY',\n description: '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 loadSetting({\n settingValue: options.resourceName,\n settingName: 'resourceName',\n environmentVariableName: 'AZURE_RESOURCE_NAME',\n description: 'Azure OpenAI resource name',\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 = (deploymentName: string) =>\n new OpenAIChatLanguageModel(deploymentName, {\n provider: 'azure.chat',\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 = (modelId: string) =>\n new OpenAICompletionLanguageModel(modelId, {\n provider: 'azure.completion',\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 = (modelId: string) =>\n new OpenAIResponsesLanguageModel(modelId, {\n provider: 'azure.responses',\n url,\n headers: getHeaders,\n fetch,\n explicitMessageItemType: isFoundryProject,\n // Soft-deprecated. TODO: remove in v8\n fileIdPrefixes: ['assistant-'],\n });\n\n const createImageModel = (modelId: string) =>\n new OpenAIImageModel(modelId, {\n provider: 'azure.image',\n url,\n headers: getHeaders,\n fetch,\n });\n\n const createTranscriptionModel = (modelId: string) =>\n new OpenAITranscriptionModel(modelId, {\n provider: 'azure.transcription',\n url,\n headers: getHeaders,\n fetch,\n });\n\n const createSpeechModel = (modelId: string) =>\n new OpenAISpeechModel(modelId, {\n provider: 'azure.speech',\n url,\n headers: getHeaders,\n fetch,\n });\n\n const provider = function (deploymentId: string) {\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);\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.speech = createSpeechModel;\n provider.tools = azureOpenaiTools;\n return provider;\n}\n\n/**\n * Default Azure OpenAI provider instance.\n */\nexport const azure = createAzure();\n","import {\n codeInterpreter,\n fileSearch,\n imageGeneration,\n webSearch,\n webSearchPreview,\n} from '@ai-sdk/openai/internal';\n\nexport const azureOpenaiTools: {\n codeInterpreter: typeof codeInterpreter;\n fileSearch: typeof fileSearch;\n imageGeneration: typeof imageGeneration;\n webSearch: typeof webSearch;\n webSearchPreview: typeof webSearchPreview;\n} = {\n codeInterpreter,\n fileSearch,\n imageGeneration,\n webSearch,\n webSearchPreview,\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"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iCAAiC;AAC1C;AAAA,EACE;AAAA,OAOK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;AC1BP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,mBAMT;AAAA,EACF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;AClBO,IAAM,UACX,OACI,WACA;;;AF0JN,SAAS,0BAA0B,SAA6B;AAC9D,MAAI,WAAW,MAAM;AACnB,WAAO;AAAA,MACL,eAAe;AAAA,MACf,kBAAkB;AAAA,MAClB,aAAa;AAAA,IACf;AAAA,EACF;AAEA,QAAM,MAAM,IAAI,IAAI,OAAO;AAC3B,QAAM,WAAW,IAAI;AACrB,QAAM,gBACJ,SAAS,SAAS,mBAAmB,KACrC,SAAS,SAAS,wBAAwB,KAC1C,SAAS,SAAS,8BAA8B;AAClD,QAAM,WAAW,IAAI,SAAS,QAAQ,QAAQ,EAAE;AAEhD,S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AAyB;AAAA;AAAA,IAEzB,gBAAgB,CAAC,YAAY;AAAA,EAC/B,CAAC;AAEH,QAAM,mBAAmB,CAAC,YACxB,IAAI,iBAAiB,SAAS;AAAA,IAC5B,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EACF,CAAC;AAEH,QAAM,2BAA2B,CAAC,YAChC,IAAI,yBAAyB,SAAS;AAAA,IACpC,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EACF,CAAC;AAEH,QAAM,oBAAoB,CAAC,YACzB,IAAI,kBAAkB,SAAS;AAAA,IAC7B,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EACF,CAAC;AAEH,QAAM,WAAW,SAAU,cAAsB;AAC/C,QAAI,YAAY;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,qBAAqB,YAAY;AAAA,EAC1C;AAEA,WAAS,uBAAuB;AAChC,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAChB,WAAS,WAAW;AACpB,WAAS,aAAa;AACtB,WAAS,YAAY;AACrB,WAAS,iBAAiB;AAC1B,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAC9B,WAAS,QAAQ;AACjB,WAAS,aAAa;AACtB,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,SAAS;AAClB,WAAS,QAAQ;AACjB,SAAO;AACT;AAKO,IAAM,QAAQ,YAAY;","names":[]}
1
+ {"version":3,"sources":["../src/azure-openai-provider.ts","../src/azure-openai-tools.ts","../src/azure-speech-transcription-model.ts","../src/azure-transcription-model-options.ts","../src/azure-speech-transcription-model-options.ts","../src/version.ts"],"sourcesContent":["import {\n OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAISpeechModel,\n OpenAITranscriptionModel,\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 SpeechModelV4,\n type TranscriptionModelV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n loadSetting,\n normalizeHeaders,\n parseProviderOptions,\n serializeModelOptions,\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { azureOpenaiTools } from './azure-openai-tools';\nimport { AzureSpeechTranscriptionModel } from './azure-speech-transcription-model';\nimport {\n azureTranscriptionModelOptions,\n isMAITranscribe2,\n} from './azure-transcription-model-options';\nimport { VERSION } from './version';\n\nexport interface AzureOpenAIProvider extends ProviderV4 {\n (deploymentId: string): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI responses API model for text generation.\n */\n languageModel(deploymentId: string): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI chat model for text generation.\n */\n chat(deploymentId: string): 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 */\n responses(deploymentId: string): LanguageModelV4;\n\n /**\n * Creates an Azure OpenAI completion model for text generation.\n */\n completion(deploymentId: string): 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 OpenAI DALL-E model for image generation.\n */\n image(deploymentId: string): ImageModelV4;\n\n /**\n * Creates an Azure OpenAI DALL-E model for image generation.\n */\n imageModel(deploymentId: string): ImageModelV4;\n\n /**\n * Creates an Azure transcription model. MAI-Transcribe-2 uses the Speech API\n * by default; other 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 OpenAI model for speech generation.\n */\n speech(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.\n */\n apiKey?: 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 transcription (MAI-Transcribe-2), e.g. a\n * regional endpoint like `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\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' = 'openai') => {\n const authHeaders = tokenProvider\n ? {}\n : {\n [api === 'speech' ? 'Ocp-Apim-Subscription-Key' : 'api-key']:\n loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AZURE_API_KEY',\n description: api === 'speech' ? 'Azure Speech' : '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 (!/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.test(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 = (deploymentName: string) =>\n new OpenAIChatLanguageModel(deploymentName, {\n provider: 'azure.chat',\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 = (modelId: string) =>\n new OpenAICompletionLanguageModel(modelId, {\n provider: 'azure.completion',\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 = (modelId: string) =>\n new OpenAIResponsesLanguageModel(modelId, {\n provider: 'azure.responses',\n url,\n headers: getHeaders,\n fetch,\n explicitMessageItemType: isFoundryProject,\n // Soft-deprecated. TODO: remove in v8\n fileIdPrefixes: ['assistant-'],\n });\n\n const createImageModel = (modelId: string) =>\n new OpenAIImageModel(modelId, {\n provider: 'azure.image',\n url,\n headers: getHeaders,\n fetch,\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\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 `${\n withoutTrailingSlash(options.speechBaseURL) ??\n `https://${getResourceName()}.cognitiveservices.azure.com`\n }/speechtotext/transcriptions:transcribe?api-version=2025-10-15`,\n headers: () => getHeaders('speech'),\n fetch,\n }),\n );\n\n const createSpeechModel = (modelId: string) =>\n new OpenAISpeechModel(modelId, {\n provider: 'azure.speech',\n url,\n headers: getHeaders,\n fetch,\n });\n\n const provider = function (deploymentId: string) {\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);\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.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 ) {}\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 } = await this.getOptions(\n options.providerOptions,\n );\n if (api === 'speech') {\n return this.speech.doGenerate(options, speechOptions);\n }\n\n const result = await this.openai.doGenerate(options);\n return {\n ...result,\n warnings: [\n ...result.warnings,\n ...Object.keys(speechOptions).map(key => ({\n type: 'unsupported' as const,\n feature: `providerOptions.azure.${key}`,\n details: 'This option requires the Azure Speech API.',\n })),\n ],\n };\n }\n\n async doStream(\n options: Parameters<NonNullable<TranscriptionModelV4['doStream']>>[0],\n ) {\n const { api } = 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 return this.openai.doStream(options);\n }\n\n private async getOptions(\n providerOptions: Parameters<\n TranscriptionModelV4['doGenerate']\n >[0]['providerOptions'],\n ) {\n const options = await parseProviderOptions({\n provider: 'azure',\n providerOptions,\n schema: azureTranscriptionModelOptions,\n });\n return {\n ...options,\n api:\n options?.api ?? (isMAITranscribe2(this.modelId) ? 'speech' : 'openai'),\n };\n }\n}\n","import {\n codeInterpreter,\n fileSearch,\n imageGeneration,\n webSearch,\n webSearchPreview,\n} from '@ai-sdk/openai/internal';\n\nexport const azureOpenaiTools: {\n codeInterpreter: typeof codeInterpreter;\n fileSearch: typeof fileSearch;\n imageGeneration: typeof imageGeneration;\n webSearch: typeof webSearch;\n webSearchPreview: typeof webSearchPreview;\n} = {\n codeInterpreter,\n fileSearch,\n imageGeneration,\n webSearch,\n webSearchPreview,\n};\n","import type { TranscriptionModelV4 } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertBase64ToUint8Array,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n mediaTypeToExtension,\n postFormDataToApi,\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 { isMAITranscribe2 } 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: () => 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 formData = new FormData();\n formData.append(\n 'audio',\n new Blob(\n [\n typeof options.audio === 'string'\n ? convertBase64ToUint8Array(options.audio)\n : options.audio,\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: isMAITranscribe2(this.modelId)\n ? 'MAI-Transcribe-2'\n : this.modelId,\n modelOptions: {\n timestamps: azureOptions.timestamps ?? '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(this.config.headers(), options.headers),\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 return {\n text: value.combinedPhrases.map(phrase => phrase.text).join(' '),\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 = 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","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\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-2, OpenAI otherwise.\n */\n api: z.enum(['openai', 'speech']).optional(),\n ...azureSpeechTranscriptionModelOptionsShape(),\n }),\n ),\n);\n\nexport type AzureTranscriptionModelOptions = InferSchema<\n typeof azureTranscriptionModelOptions\n>;\n\nexport function isMAITranscribe2(modelId: string): boolean {\n return modelId.toLowerCase() === 'mai-transcribe-2';\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","// 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"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iCAAiC;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,OAOK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;AC/BP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,mBAMT;AAAA,EACF;AAAA,EACA;AAAA,EACA;AAAA,EACA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AAA,MACH,KACE,SAAS,QAAQ,iBAAiB,KAAK,OAAO,IAAI,WAAW;AAAA,IACjE;AAAA,EACF;AACF;","names":["z","lazySchema","zodSchema","z","lazySchema","zodSchema","z","z"]}
package/docs/04-azure.mdx CHANGED
@@ -69,6 +69,7 @@ You can use the following optional settings to customize the OpenAI provider ins
69
69
  It defaults to the `AZURE_RESOURCE_NAME` environment variable.
70
70
 
71
71
  The resource name is used in the assembled URL: `https://{resourceName}.openai.azure.com/openai/v1{path}`.
72
+ It must be a single DNS label (letters, digits, and hyphens).
72
73
  You can use `baseURL` instead to specify the URL prefix.
73
74
 
74
75
  - **apiKey** _string_
@@ -131,6 +132,13 @@ You can use the following optional settings to customize the OpenAI provider ins
131
132
  This option is useful for compatibility with certain Azure OpenAI models or deployments
132
133
  that require the legacy endpoint format.
133
134
 
135
+ - **speechBaseURL** _string_
136
+
137
+ URL prefix for Azure Speech transcription requests (MAI-Transcribe-2), for example
138
+ a regional endpoint such as `https://eastus.api.cognitive.microsoft.com`.
139
+ Defaults to `https://{resourceName}.cognitiveservices.azure.com`.
140
+ Speech requests do not use `baseURL` or `apiVersion`.
141
+
134
142
  ## Language Models
135
143
 
136
144
  The Azure OpenAI provider instance is a function that you can invoke to create a language model:
@@ -1079,6 +1087,13 @@ Azure OpenAI supports DALL-E 2 and DALL-E 3 models through deployments. The capa
1079
1087
  | DALL-E 3 | 1024x1024, 1792x1024, 1024x1792 |
1080
1088
  | DALL-E 2 | 256x256, 512x512, 1024x1024 |
1081
1089
 
1090
+ Azure deployment names are user-defined and do not identify the backing model.
1091
+ Consequently, `supportsFileInputs` and `supportsMaskInputs` are `undefined`
1092
+ (unknown) for Azure image model instances. If your application knows the
1093
+ capabilities of a deployment, you can advertise them with the
1094
+ `overrideSupportsFileInputs` and `overrideSupportsMaskInputs` options of
1095
+ [`wrapImageModel`](/docs/reference/ai-sdk-core/wrap-image-model).
1096
+
1082
1097
  <Note>
1083
1098
  DALL-E models do not support the `aspectRatio` parameter. Use the `size`
1084
1099
  parameter instead.
@@ -1091,7 +1106,7 @@ Azure OpenAI supports DALL-E 2 and DALL-E 3 models through deployments. The capa
1091
1106
 
1092
1107
  ## Transcription Models
1093
1108
 
1094
- You can create models that call the Azure OpenAI transcription API using the `.transcription()` factory method.
1109
+ You can create models that call the Azure OpenAI or Azure Speech transcription API using the `.transcription()` factory method.
1095
1110
 
1096
1111
  The first argument is the model id e.g. `whisper-1`.
1097
1112
 
@@ -1099,6 +1114,105 @@ The first argument is the model id e.g. `whisper-1`.
1099
1114
  const model = azure.transcription('whisper-1');
1100
1115
  ```
1101
1116
 
1117
+ ### MAI-Transcribe-2
1118
+
1119
+ MAI-Transcribe-2 is a multilingual speech-to-text model from Microsoft AI, served through Azure.
1120
+ `azure.transcription('mai-transcribe-2')` uses the Azure Speech API.
1121
+ The model ID is matched case-insensitively and sent to Azure as `MAI-Transcribe-2`.
1122
+ All other IDs use the OpenAI API by default, including custom deployment names.
1123
+
1124
+ ```ts
1125
+ import { azure, type AzureTranscriptionModelOptions } from '@ai-sdk/azure';
1126
+ import { transcribe } from 'ai';
1127
+ import { readFile } from 'fs/promises';
1128
+
1129
+ const result = await transcribe({
1130
+ model: azure.transcription('mai-transcribe-2'),
1131
+ audio: await readFile('audio.wav'),
1132
+ providerOptions: {
1133
+ azure: {
1134
+ timestamps: 'word',
1135
+ diarization: { enabled: true },
1136
+ transcribeStyle: 'clean',
1137
+ } satisfies AzureTranscriptionModelOptions,
1138
+ },
1139
+ });
1140
+ ```
1141
+
1142
+ MAI-Transcribe-2 requires a Microsoft Foundry (Speech) resource in a region where it is available:
1143
+ `centralindia`, `eastus`, `northeurope`, `southeastasia`, `westus`, or `westus2`
1144
+ (see [Speech service regions](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/regions?tabs=llmspeech)).
1145
+ Resources in other regions reject the request.
1146
+ Set `AZURE_RESOURCE_NAME` and `AZURE_API_KEY` to that resource's name and key,
1147
+ or pass `resourceName` and `apiKey` to `createAzure`. `tokenProvider`, custom headers,
1148
+ and custom fetch are also supported. Keys are sent as `Ocp-Apim-Subscription-Key`.
1149
+
1150
+ Speech requests use `https://{resourceName}.cognitiveservices.azure.com/speechtotext/transcriptions:transcribe`
1151
+ with API version `2025-10-15`. Use `speechBaseURL` to supply a different Speech URL prefix
1152
+ (without `/speechtotext/transcriptions:transcribe`), for example a regional endpoint:
1153
+
1154
+ ```ts
1155
+ import { createAzure } from '@ai-sdk/azure';
1156
+
1157
+ const azure = createAzure({
1158
+ speechBaseURL: 'https://eastus.api.cognitive.microsoft.com',
1159
+ apiKey: process.env.AZURE_SPEECH_API_KEY,
1160
+ });
1161
+ ```
1162
+
1163
+ Speech requests do not use `baseURL`, `apiVersion`, or `useDeploymentBasedUrls`;
1164
+ those settings only apply to Azure OpenAI models.
1165
+
1166
+ The following options are available through `providerOptions.azure`:
1167
+
1168
+ - **api** _'openai' | 'speech'_
1169
+ Overrides model-based API selection for this request.
1170
+ Set `openai` for an OpenAI deployment named `mai-transcribe-2`, or `speech` to
1171
+ send another model ID to Speech. Other Speech model IDs are sent unchanged.
1172
+
1173
+ - **timestamps** _'word' | 'segment' | 'none'_
1174
+ Timing granularity. The AI SDK defaults to `segment` so that results include
1175
+ timed segments (Azure's own default is `none`). `segment` returns one segment
1176
+ per sentence or speaker turn, `word` additionally returns word timing in provider
1177
+ metadata, and `none` returns a single segment that spans the whole audio.
1178
+
1179
+ - **transcribeStyle** _'verbatim' | 'clean'_
1180
+ `verbatim` keeps fillers and false starts, `clean` removes them. Defaults to `verbatim`.
1181
+
1182
+ - **locales** _string[]_
1183
+ Exactly one language code, such as `['en']`. This is a strong hint; omit it for
1184
+ automatic language detection and code switching.
1185
+
1186
+ - **diarization** _object_
1187
+ Set `enabled` to `true` to identify speakers. Speaker IDs are returned in
1188
+ provider metadata. `maxSpeakers` is not supported by MAI-Transcribe-2.
1189
+
1190
+ - **phraseList** _object_
1191
+ Set `phrases` to a list of names and domain terms to bias recognition toward them.
1192
+
1193
+ Explicit `api` takes precedence over the model ID. Existing OpenAI transcription
1194
+ options remain under `providerOptions.openai`. Speech-only Azure options produce
1195
+ warnings when used with the OpenAI API. Unknown or unsupported `providerOptions.azure`
1196
+ keys (for example `diarization.maxSpeakers`) are rejected before the request is sent.
1197
+
1198
+ Results include transcript text, timed segments, duration, and an ISO-639-1
1199
+ language code when the reported phrase locales identify one language. Mixed-language
1200
+ results, and languages without an ISO-639-1 code such as Filipino (`fil`) or
1201
+ Cantonese (`yue`), leave `language` undefined. Speaker IDs, exact locales, and word
1202
+ timing are preserved in `providerMetadata.azure.phrases`; use the exported
1203
+ `AzureTranscriptionProviderMetadata` type to access them. Phrase timing is in
1204
+ milliseconds in metadata and seconds in normalized `segments`.
1205
+
1206
+ MAI-Transcribe-2 is a file transcription model: it accepts WAV, MP3, or FLAC files
1207
+ shorter than 2 hours and smaller than 250 MB, and does not support streaming
1208
+ transcription. The model is in public preview. See
1209
+ [Azure's MAI-Transcribe guide](https://learn.microsoft.com/en-us/azure/ai-services/speech-service/mai-transcribe)
1210
+ for supported languages and diarization limits.
1211
+
1212
+ AI Gateway forwards these provider options, including `azure.api`.
1213
+
1214
+ ### OpenAI transcription
1215
+
1102
1216
  <Note>
1103
1217
  If you encounter a "DeploymentNotFound" error with transcription models,
1104
1218
  try enabling deployment-based URLs:
@@ -1164,6 +1278,7 @@ The following provider options are available:
1164
1278
  | `whisper-1` | <Check /> | <Check /> | <Check /> | <Check /> |
1165
1279
  | `gpt-4o-mini-transcribe` | <Check /> | <Cross /> | <Cross /> | <Cross /> |
1166
1280
  | `gpt-4o-transcribe` | <Check /> | <Cross /> | <Cross /> | <Cross /> |
1281
+ | `mai-transcribe-2` | <Check /> | <Check /> | <Check /> | <Check /> |
1167
1282
 
1168
1283
  ## Speech Models
1169
1284
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/azure",
3
- "version": "4.0.82",
3
+ "version": "4.0.84",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -29,10 +29,10 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/deepseek": "3.0.54",
33
- "@ai-sdk/openai": "4.0.78",
34
- "@ai-sdk/provider": "4.0.18",
35
- "@ai-sdk/provider-utils": "5.0.49"
32
+ "@ai-sdk/deepseek": "3.0.56",
33
+ "@ai-sdk/openai": "4.0.80",
34
+ "@ai-sdk/provider": "4.0.19",
35
+ "@ai-sdk/provider-utils": "5.0.51"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@ai-sdk/test-server": "2.0.2",
@@ -10,6 +10,7 @@ import {
10
10
  import { DeepSeekChatLanguageModel } from '@ai-sdk/deepseek/internal';
11
11
  import {
12
12
  InvalidArgumentError,
13
+ UnsupportedFunctionalityError,
13
14
  type EmbeddingModelV4,
14
15
  type LanguageModelV4,
15
16
  type ProviderV4,
@@ -21,11 +22,20 @@ import {
21
22
  loadApiKey,
22
23
  loadSetting,
23
24
  normalizeHeaders,
25
+ parseProviderOptions,
26
+ serializeModelOptions,
27
+ WORKFLOW_DESERIALIZE,
28
+ WORKFLOW_SERIALIZE,
24
29
  withoutTrailingSlash,
25
30
  withUserAgentSuffix,
26
31
  type FetchFunction,
27
32
  } from '@ai-sdk/provider-utils';
28
33
  import { azureOpenaiTools } from './azure-openai-tools';
34
+ import { AzureSpeechTranscriptionModel } from './azure-speech-transcription-model';
35
+ import {
36
+ azureTranscriptionModelOptions,
37
+ isMAITranscribe2,
38
+ } from './azure-transcription-model-options';
29
39
  import { VERSION } from './version';
30
40
 
31
41
  export interface AzureOpenAIProvider extends ProviderV4 {
@@ -87,10 +97,16 @@ export interface AzureOpenAIProvider extends ProviderV4 {
87
97
  imageModel(deploymentId: string): ImageModelV4;
88
98
 
89
99
  /**
90
- * Creates an Azure OpenAI model for audio transcription.
100
+ * Creates an Azure transcription model. MAI-Transcribe-2 uses the Speech API
101
+ * by default; other IDs use OpenAI. Override with providerOptions.azure.api.
91
102
  */
92
103
  transcription(deploymentId: string): TranscriptionModelV4;
93
104
 
105
+ /**
106
+ * Creates an Azure transcription model. Alias of `transcription`.
107
+ */
108
+ transcriptionModel(deploymentId: string): TranscriptionModelV4;
109
+
94
110
  /**
95
111
  * Creates an Azure OpenAI model for speech generation.
96
112
  */
@@ -107,6 +123,7 @@ export interface AzureOpenAIProviderSettings {
107
123
  * Name of the Azure OpenAI resource. Either this or `baseURL` can be used.
108
124
  *
109
125
  * The resource name is used in the assembled URL: `https://{resourceName}.openai.azure.com/openai/v1{path}`.
126
+ * It must be a single DNS label (letters, digits, and hyphens).
110
127
  */
111
128
  resourceName?: string;
112
129
 
@@ -155,6 +172,14 @@ export interface AzureOpenAIProviderSettings {
155
172
  * `{baseURL}/v1{path}?api-version={apiVersion}`.
156
173
  */
157
174
  useDeploymentBasedUrls?: boolean;
175
+
176
+ /**
177
+ * URL prefix for Azure Speech transcription (MAI-Transcribe-2), e.g. a
178
+ * regional endpoint like `https://eastus.api.cognitive.microsoft.com`.
179
+ * Defaults to `https://{resourceName}.cognitiveservices.azure.com`.
180
+ * Speech requests do not use `baseURL` or `apiVersion`.
181
+ */
182
+ speechBaseURL?: string;
158
183
  }
159
184
 
160
185
  function getAzureOpenAIBaseURLInfo(baseURL: string | undefined) {
@@ -199,15 +224,16 @@ export function createAzure(
199
224
  });
200
225
  }
201
226
 
202
- const getHeaders = () => {
227
+ const getHeaders = (api: 'openai' | 'speech' = 'openai') => {
203
228
  const authHeaders = tokenProvider
204
229
  ? {}
205
230
  : {
206
- 'api-key': loadApiKey({
207
- apiKey: options.apiKey,
208
- environmentVariableName: 'AZURE_API_KEY',
209
- description: 'Azure OpenAI',
210
- }),
231
+ [api === 'speech' ? 'Ocp-Apim-Subscription-Key' : 'api-key']:
232
+ loadApiKey({
233
+ apiKey: options.apiKey,
234
+ environmentVariableName: 'AZURE_API_KEY',
235
+ description: api === 'speech' ? 'Azure Speech' : 'Azure OpenAI',
236
+ }),
211
237
  };
212
238
 
213
239
  return withUserAgentSuffix(
@@ -215,7 +241,7 @@ export function createAzure(
215
241
  ...authHeaders,
216
242
  ...options.headers,
217
243
  },
218
- `ai-sdk/azure/${VERSION}`,
244
+ `ai-sdk-azure/${VERSION}`,
219
245
  );
220
246
  };
221
247
 
@@ -234,14 +260,27 @@ export function createAzure(
234
260
  }
235
261
  : options.fetch;
236
262
 
237
- const getResourceName = () =>
238
- loadSetting({
263
+ const getResourceName = () => {
264
+ const resourceName = loadSetting({
239
265
  settingValue: options.resourceName,
240
266
  settingName: 'resourceName',
241
267
  environmentVariableName: 'AZURE_RESOURCE_NAME',
242
268
  description: 'Azure OpenAI resource name',
243
269
  });
244
270
 
271
+ // The resource name becomes part of the request host, so only a DNS label
272
+ // is accepted (e.g. `user@internal:8080/#` would rewrite the host).
273
+ if (!/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.test(resourceName)) {
274
+ throw new InvalidArgumentError({
275
+ argument: 'resourceName',
276
+ message:
277
+ 'Invalid Azure resource name. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',
278
+ });
279
+ }
280
+
281
+ return resourceName;
282
+ };
283
+
245
284
  const apiVersion = options.apiVersion ?? 'v1';
246
285
  const {
247
286
  isAzureOpenAI,
@@ -330,15 +369,34 @@ export function createAzure(
330
369
  url,
331
370
  headers: getHeaders,
332
371
  fetch,
372
+ // Azure model IDs are user-defined deployment names, so OpenAI model
373
+ // family capabilities cannot be inferred from them.
374
+ imageInputCapabilities: {
375
+ supportsFileInputs: undefined,
376
+ supportsMaskInputs: undefined,
377
+ },
333
378
  });
334
379
 
335
380
  const createTranscriptionModel = (modelId: string) =>
336
- new OpenAITranscriptionModel(modelId, {
337
- provider: 'azure.transcription',
338
- url,
339
- headers: getHeaders,
340
- fetch,
341
- });
381
+ new AzureTranscriptionModel(
382
+ modelId,
383
+ options,
384
+ new OpenAITranscriptionModel(modelId, {
385
+ provider: 'azure.transcription',
386
+ url,
387
+ headers: getHeaders,
388
+ fetch,
389
+ }),
390
+ new AzureSpeechTranscriptionModel(modelId, {
391
+ url: () =>
392
+ `${
393
+ withoutTrailingSlash(options.speechBaseURL) ??
394
+ `https://${getResourceName()}.cognitiveservices.azure.com`
395
+ }/speechtotext/transcriptions:transcribe?api-version=2025-10-15`,
396
+ headers: () => getHeaders('speech'),
397
+ fetch,
398
+ }),
399
+ );
342
400
 
343
401
  const createSpeechModel = (modelId: string) =>
344
402
  new OpenAISpeechModel(modelId, {
@@ -371,6 +429,7 @@ export function createAzure(
371
429
  provider.imageModel = createImageModel;
372
430
  provider.responses = createResponsesModel;
373
431
  provider.transcription = createTranscriptionModel;
432
+ provider.transcriptionModel = createTranscriptionModel;
374
433
  provider.speech = createSpeechModel;
375
434
  provider.tools = azureOpenaiTools;
376
435
  return provider;
@@ -380,3 +439,81 @@ export function createAzure(
380
439
  * Default Azure OpenAI provider instance.
381
440
  */
382
441
  export const azure = createAzure();
442
+
443
+ // Resolves the API per request: providerOptions also reach this model via Gateway.
444
+ class AzureTranscriptionModel implements TranscriptionModelV4 {
445
+ readonly specificationVersion = 'v4';
446
+ readonly provider = 'azure.transcription';
447
+
448
+ constructor(
449
+ readonly modelId: string,
450
+ private readonly config: AzureOpenAIProviderSettings,
451
+ private readonly openai: OpenAITranscriptionModel,
452
+ private readonly speech: AzureSpeechTranscriptionModel,
453
+ ) {}
454
+
455
+ static [WORKFLOW_SERIALIZE](model: AzureTranscriptionModel) {
456
+ return serializeModelOptions({
457
+ modelId: model.modelId,
458
+ config: model.config,
459
+ });
460
+ }
461
+
462
+ static [WORKFLOW_DESERIALIZE](options: {
463
+ modelId: string;
464
+ config: AzureOpenAIProviderSettings;
465
+ }) {
466
+ return createAzure(options.config).transcription(options.modelId);
467
+ }
468
+
469
+ async doGenerate(options: Parameters<TranscriptionModelV4['doGenerate']>[0]) {
470
+ const { api, ...speechOptions } = await this.getOptions(
471
+ options.providerOptions,
472
+ );
473
+ if (api === 'speech') {
474
+ return this.speech.doGenerate(options, speechOptions);
475
+ }
476
+
477
+ const result = await this.openai.doGenerate(options);
478
+ return {
479
+ ...result,
480
+ warnings: [
481
+ ...result.warnings,
482
+ ...Object.keys(speechOptions).map(key => ({
483
+ type: 'unsupported' as const,
484
+ feature: `providerOptions.azure.${key}`,
485
+ details: 'This option requires the Azure Speech API.',
486
+ })),
487
+ ],
488
+ };
489
+ }
490
+
491
+ async doStream(
492
+ options: Parameters<NonNullable<TranscriptionModelV4['doStream']>>[0],
493
+ ) {
494
+ const { api } = await this.getOptions(options.providerOptions);
495
+ if (api === 'speech') {
496
+ throw new UnsupportedFunctionalityError({
497
+ functionality: 'streaming transcription with the Azure Speech API',
498
+ });
499
+ }
500
+ return this.openai.doStream(options);
501
+ }
502
+
503
+ private async getOptions(
504
+ providerOptions: Parameters<
505
+ TranscriptionModelV4['doGenerate']
506
+ >[0]['providerOptions'],
507
+ ) {
508
+ const options = await parseProviderOptions({
509
+ provider: 'azure',
510
+ providerOptions,
511
+ schema: azureTranscriptionModelOptions,
512
+ });
513
+ return {
514
+ ...options,
515
+ api:
516
+ options?.api ?? (isMAITranscribe2(this.modelId) ? 'speech' : 'openai'),
517
+ };
518
+ }
519
+ }
@@ -0,0 +1,46 @@
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+
8
+ // Strict objects reject unknown keys (e.g. `diarization.maxSpeakers`, which
9
+ // MAI-Transcribe-2 does not support) instead of silently dropping them.
10
+ export const azureSpeechTranscriptionModelOptionsShape = () => ({
11
+ /**
12
+ * Timing granularity. Defaults to `segment` so that transcription results
13
+ * include timed segments (Azure's own default is `none`).
14
+ */
15
+ timestamps: z.enum(['word', 'segment', 'none']).optional(),
16
+
17
+ /**
18
+ * `verbatim` keeps fillers and false starts, `clean` removes them.
19
+ * Azure defaults to `verbatim`.
20
+ */
21
+ transcribeStyle: z.enum(['verbatim', 'clean']).optional(),
22
+
23
+ /**
24
+ * Forces a single language, e.g. `['en']`. Omit for automatic language
25
+ * detection and code switching.
26
+ */
27
+ locales: z.array(z.string()).length(1).optional(),
28
+
29
+ /**
30
+ * Speaker diarization. Speaker IDs are available in provider metadata.
31
+ */
32
+ diarization: z.strictObject({ enabled: z.boolean() }).optional(),
33
+
34
+ /**
35
+ * Keyword biasing for names and domain terminology.
36
+ */
37
+ phraseList: z.strictObject({ phrases: z.array(z.string()) }).optional(),
38
+ });
39
+
40
+ export const azureSpeechTranscriptionModelOptions = lazySchema(() =>
41
+ zodSchema(z.strictObject(azureSpeechTranscriptionModelOptionsShape())),
42
+ );
43
+
44
+ export type AzureTranscriptionModelSpeechOptions = InferSchema<
45
+ typeof azureSpeechTranscriptionModelOptions
46
+ >;
@@ -0,0 +1,155 @@
1
+ import type { TranscriptionModelV4 } from '@ai-sdk/provider';
2
+ import {
3
+ combineHeaders,
4
+ convertBase64ToUint8Array,
5
+ createJsonErrorResponseHandler,
6
+ createJsonResponseHandler,
7
+ mediaTypeToExtension,
8
+ postFormDataToApi,
9
+ type FetchFunction,
10
+ } from '@ai-sdk/provider-utils';
11
+ import { z } from 'zod/v4';
12
+ import type { AzureTranscriptionProviderMetadata } from './azure-transcription-provider-metadata';
13
+ import type { AzureTranscriptionModelSpeechOptions } from './azure-speech-transcription-model-options';
14
+ import { isMAITranscribe2 } from './azure-transcription-model-options';
15
+
16
+ export class AzureSpeechTranscriptionModel implements TranscriptionModelV4 {
17
+ readonly specificationVersion = 'v4';
18
+ readonly provider = 'azure.transcription';
19
+
20
+ constructor(
21
+ readonly modelId: string,
22
+ private readonly config: {
23
+ url: () => string;
24
+ headers: () => Record<string, string | undefined>;
25
+ fetch?: FetchFunction;
26
+ },
27
+ ) {}
28
+
29
+ async doGenerate(
30
+ options: Parameters<TranscriptionModelV4['doGenerate']>[0],
31
+ azureOptions: AzureTranscriptionModelSpeechOptions = {},
32
+ ): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {
33
+ const timestamp = new Date();
34
+ const formData = new FormData();
35
+ formData.append(
36
+ 'audio',
37
+ new Blob(
38
+ [
39
+ typeof options.audio === 'string'
40
+ ? convertBase64ToUint8Array(options.audio)
41
+ : options.audio,
42
+ ],
43
+ { type: options.mediaType },
44
+ ),
45
+ `audio.${mediaTypeToExtension(options.mediaType)}`,
46
+ );
47
+ formData.append(
48
+ 'definition',
49
+ JSON.stringify({
50
+ enhancedMode: {
51
+ enabled: true,
52
+ model: isMAITranscribe2(this.modelId)
53
+ ? 'MAI-Transcribe-2'
54
+ : this.modelId,
55
+ modelOptions: {
56
+ timestamps: azureOptions.timestamps ?? 'segment',
57
+ transcribeStyle: azureOptions.transcribeStyle,
58
+ },
59
+ },
60
+ locales: azureOptions.locales,
61
+ diarization: azureOptions.diarization,
62
+ phraseList: azureOptions.phraseList,
63
+ }),
64
+ );
65
+
66
+ const { value, rawValue, responseHeaders } = await postFormDataToApi({
67
+ url: this.config.url(),
68
+ headers: combineHeaders(this.config.headers(), options.headers),
69
+ formData,
70
+ abortSignal: options.abortSignal,
71
+ fetch: this.config.fetch,
72
+ failedResponseHandler: createJsonErrorResponseHandler({
73
+ errorSchema: z.union([
74
+ z.object({ error: z.object({ message: z.string() }) }),
75
+ z.object({ message: z.string() }),
76
+ ]),
77
+ errorToMessage: data =>
78
+ 'error' in data ? data.error.message : data.message,
79
+ }),
80
+ successfulResponseHandler: createJsonResponseHandler(responseSchema),
81
+ });
82
+
83
+ const phrases = value.phrases ?? [];
84
+ // Consider every reported locale so mixed results (e.g. en + fil) are not
85
+ // collapsed to one language; only ISO-639-1 codes are reported.
86
+ const languages = new Set(
87
+ phrases.flatMap(phrase =>
88
+ phrase.locale ? [phrase.locale.split('-')[0].toLowerCase()] : [],
89
+ ),
90
+ );
91
+ const [language] = languages;
92
+ const reportedLanguage =
93
+ languages.size === 1 && /^[a-z]{2}$/.test(language)
94
+ ? language
95
+ : undefined;
96
+
97
+ return {
98
+ text: value.combinedPhrases.map(phrase => phrase.text).join(' '),
99
+ segments: phrases.flatMap(phrase =>
100
+ phrase.offsetMilliseconds != null && phrase.durationMilliseconds != null
101
+ ? [
102
+ {
103
+ text: phrase.text,
104
+ startSecond: phrase.offsetMilliseconds / 1000,
105
+ endSecond:
106
+ (phrase.offsetMilliseconds + phrase.durationMilliseconds) /
107
+ 1000,
108
+ },
109
+ ]
110
+ : [],
111
+ ),
112
+ language: reportedLanguage,
113
+ durationInSeconds:
114
+ value.durationMilliseconds != null
115
+ ? value.durationMilliseconds / 1000
116
+ : undefined,
117
+ warnings: [],
118
+ providerMetadata: {
119
+ azure: { phrases },
120
+ } satisfies AzureTranscriptionProviderMetadata,
121
+ response: {
122
+ timestamp,
123
+ modelId: this.modelId,
124
+ headers: responseHeaders,
125
+ body: rawValue,
126
+ },
127
+ };
128
+ }
129
+ }
130
+
131
+ const responseSchema = z.object({
132
+ combinedPhrases: z.array(z.object({ text: z.string() })),
133
+ durationMilliseconds: z.number().nullish(),
134
+ phrases: z
135
+ .array(
136
+ z.object({
137
+ text: z.string(),
138
+ offsetMilliseconds: z.number().nullish(),
139
+ durationMilliseconds: z.number().nullish(),
140
+ locale: z.string().nullish(),
141
+ speaker: z.number().nullish(),
142
+ confidence: z.number().nullish(),
143
+ words: z
144
+ .array(
145
+ z.object({
146
+ text: z.string(),
147
+ offsetMilliseconds: z.number().nullish(),
148
+ durationMilliseconds: z.number().nullish(),
149
+ }),
150
+ )
151
+ .nullish(),
152
+ }),
153
+ )
154
+ .nullish(),
155
+ });
@@ -0,0 +1,27 @@
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ } from '@ai-sdk/provider-utils';
6
+ import { z } from 'zod/v4';
7
+ import { azureSpeechTranscriptionModelOptionsShape } from './azure-speech-transcription-model-options';
8
+
9
+ export const azureTranscriptionModelOptions = lazySchema(() =>
10
+ zodSchema(
11
+ z.strictObject({
12
+ /**
13
+ * API to use. Defaults to Speech for MAI-Transcribe-2, OpenAI otherwise.
14
+ */
15
+ api: z.enum(['openai', 'speech']).optional(),
16
+ ...azureSpeechTranscriptionModelOptionsShape(),
17
+ }),
18
+ ),
19
+ );
20
+
21
+ export type AzureTranscriptionModelOptions = InferSchema<
22
+ typeof azureTranscriptionModelOptions
23
+ >;
24
+
25
+ export function isMAITranscribe2(modelId: string): boolean {
26
+ return modelId.toLowerCase() === 'mai-transcribe-2';
27
+ }
@@ -0,0 +1,17 @@
1
+ export type AzureTranscriptionProviderMetadata = {
2
+ azure: {
3
+ phrases: Array<{
4
+ text: string;
5
+ offsetMilliseconds?: number | null;
6
+ durationMilliseconds?: number | null;
7
+ locale?: string | null;
8
+ speaker?: number | null;
9
+ confidence?: number | null;
10
+ words?: Array<{
11
+ text: string;
12
+ offsetMilliseconds?: number | null;
13
+ durationMilliseconds?: number | null;
14
+ }> | null;
15
+ }>;
16
+ };
17
+ };
package/src/index.ts CHANGED
@@ -28,3 +28,5 @@ export type {
28
28
  AzureResponsesSourceDocumentProviderMetadata,
29
29
  } from './azure-openai-provider-metadata';
30
30
  export { VERSION } from './version';
31
+ export type { AzureTranscriptionModelOptions } from './azure-transcription-model-options';
32
+ export type { AzureTranscriptionProviderMetadata } from './azure-transcription-provider-metadata';