@ai-sdk/azure 4.0.117 → 4.0.119

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/docs/04-azure.mdx CHANGED
@@ -279,6 +279,8 @@ and support structured data generation with [`Output`](/docs/reference/ai-sdk-co
279
279
 
280
280
  When using OpenAI language models on Azure, you can configure provider-specific options using `providerOptions.openai`. More information on available configuration options are on [the OpenAI provider page](/providers/ai-sdk-providers/openai#language-models).
281
281
 
282
+ The same options are also accepted under `providerOptions.azure`. Responses models use `providerOptions.azure` when it is present and `providerOptions.openai` otherwise. Chat and completion models merge both, and `providerOptions.azure` wins when both set the same option.
283
+
282
284
  ```ts highlight="12-14,24-26"
283
285
  import { azure, type OpenAILanguageModelResponsesOptions } from '@ai-sdk/azure';
284
286
 
@@ -1486,7 +1488,7 @@ MAI-Image models use the [MAI image API](#mai-image) instead.
1486
1488
  const model = azure.image('your-dalle-deployment-name');
1487
1489
  ```
1488
1490
 
1489
- Azure OpenAI image models support several additional settings. You can pass them as `providerOptions.openai` when generating the image:
1491
+ Azure OpenAI image models support several additional settings. You can pass them as `providerOptions.openai` or `providerOptions.azure` when generating the image (`azure` wins when both set the same option):
1490
1492
 
1491
1493
  ```ts
1492
1494
  import { azure } from '@ai-sdk/azure';
@@ -1525,12 +1527,21 @@ console.log(image);
1525
1527
 
1526
1528
  ### Model Capabilities
1527
1529
 
1528
- Azure OpenAI supports DALL-E 2 and DALL-E 3 models through deployments. The capabilities depend on which model version your deployment is using:
1530
+ The table lists supported DALL-E backing models and Azure MAI image IDs. For OpenAI-backed deployments, the supported sizes depend on the model version behind your deployment.
1531
+
1532
+ {/* model-capabilities:azure-image:start */}
1533
+
1534
+ | Model | Sizes |
1535
+ | --------------------- | ------------------------------------------------------ |
1536
+ | `dall-e-3` | 1024x1024, 1792x1024, 1024x1792 |
1537
+ | `dall-e-2` | 256x256, 512x512, 1024x1024 |
1538
+ | `mai-image-2.5` | Sides must be multiples of 16 and at least 768 pixels. |
1539
+ | `mai-image-2.5-flash` | Sides must be multiples of 16 and at least 768 pixels. |
1540
+ | `mai-image-2.5-pro` | Sides must be multiples of 16 and at least 768 pixels. |
1541
+ | `mai-image-2.6` | Sides must be multiples of 16 and at least 768 pixels. |
1542
+ | `mai-image-2.6-flash` | Sides must be multiples of 16 and at least 768 pixels. |
1529
1543
 
1530
- | Model Version | Sizes |
1531
- | ------------- | ------------------------------- |
1532
- | DALL-E 3 | 1024x1024, 1792x1024, 1024x1792 |
1533
- | DALL-E 2 | 256x256, 512x512, 1024x1024 |
1544
+ {/* model-capabilities:azure-image:end */}
1534
1545
 
1535
1546
  Azure deployment names are user-defined and do not identify the backing model.
1536
1547
  Consequently, `supportsFileInputs` and `supportsMaskInputs` are `undefined`
@@ -1706,9 +1717,11 @@ The following options are available through `providerOptions.azure`:
1706
1717
  - **phraseList** _object_
1707
1718
  Set `phrases` to a list of names and domain terms to bias recognition toward them.
1708
1719
 
1709
- Explicit `api` takes precedence over the model ID. Existing OpenAI transcription
1710
- options remain under `providerOptions.openai`. Speech-only Azure options produce
1711
- warnings when used with the OpenAI API. Unknown `providerOptions.azure` keys
1720
+ Explicit `api` takes precedence over the model ID. OpenAI transcription options,
1721
+ such as `language` and `prompt`, can be passed under `providerOptions.openai` or
1722
+ `providerOptions.azure`; `azure` wins when both set the same option. Speech-only
1723
+ Azure options produce warnings when used with the OpenAI API, and OpenAI-only
1724
+ options produce warnings when used with the Speech or MAI APIs. Unknown `providerOptions.azure` keys
1712
1725
  (for example `diarization.maxSpeakers`) are rejected before the request is sent.
1713
1726
  Options that a model does not support, such as `timestamps: 'word'` with
1714
1727
  MAI-Transcribe-1.5, are sent unchanged, and Azure rejects the request with an
@@ -1862,14 +1875,18 @@ The following provider options are available:
1862
1875
 
1863
1876
  ### Model Capabilities
1864
1877
 
1865
- | Model | Transcription | Duration | Segments | Language |
1866
- | ---------------------------- | --------------------- | --------- | --------- | --------- |
1867
- | `whisper-1` | <Check /> | <Check /> | <Check /> | <Check /> |
1868
- | `gpt-4o-mini-transcribe` | <Check /> | <Cross /> | <Cross /> | <Cross /> |
1869
- | `gpt-4o-transcribe` | <Check /> | <Cross /> | <Cross /> | <Cross /> |
1870
- | `mai-transcribe-2` | <Check /> | <Check /> | <Check /> | <Check /> |
1871
- | `mai-transcribe-1.5` | <Check /> | <Check /> | <Check /> | <Check /> |
1872
- | `mai-transcribe-2-streaming` | <Check /> (streaming) | <Check /> | <Cross /> | <Cross /> |
1878
+ {/* model-capabilities:azure-transcription:start */}
1879
+
1880
+ | Model | Transcription | Streaming | Duration | Segments | Language |
1881
+ | ---------------------------- | ------------- | --------- | ------------------------------------------------------------- | --------- | -------------------------------------------------- |
1882
+ | `whisper-1` | <Check /> | <Cross /> | <Check /> | <Check /> | <Check /> |
1883
+ | `gpt-4o-mini-transcribe` | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> |
1884
+ | `gpt-4o-transcribe` | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> |
1885
+ | `mai-transcribe-2` | <Check /> | <Cross /> | <Check /> | <Check /> | <Check /> |
1886
+ | `mai-transcribe-1.5` | <Check /> | <Cross /> | <Check /> | <Cross /> | <Check /> |
1887
+ | `mai-transcribe-2-streaming` | <Cross /> | <Check /> | Conditional: Requires an audio format with a known byte rate. | <Cross /> | Conditional: Reports the configured language hint. |
1888
+
1889
+ {/* model-capabilities:azure-transcription:end */}
1873
1890
 
1874
1891
  ## Speech Models
1875
1892
 
@@ -1928,13 +1945,21 @@ The following provider options are available:
1928
1945
 
1929
1946
  ### Model Capabilities
1930
1947
 
1931
- Azure OpenAI supports TTS models through deployments. The capabilities depend on which model version your deployment is using:
1948
+ The table lists OpenAI TTS backing models and Azure MAI voice IDs. For OpenAI-backed deployments, instruction support depends on the model version behind your deployment.
1932
1949
 
1933
- | Model Version | Instructions |
1934
- | ----------------- | ------------ |
1935
- | `tts-1` | <Cross /> |
1936
- | `tts-1-hd` | <Cross /> |
1937
- | `gpt-4o-mini-tts` | <Check /> |
1950
+ {/* model-capabilities:azure-speech:start */}
1951
+
1952
+ | Model | Instructions |
1953
+ | --------------------- | ------------ |
1954
+ | `tts-1` | <Cross /> |
1955
+ | `tts-1-hd` | <Cross /> |
1956
+ | `gpt-4o-mini-tts` | <Check /> |
1957
+ | `mai-voice-2.1-flash` | <Cross /> |
1958
+ | `mai-voice-2.1` | <Cross /> |
1959
+ | `mai-voice-2-flash` | <Cross /> |
1960
+ | `mai-voice-2` | <Cross /> |
1961
+
1962
+ {/* model-capabilities:azure-speech:end */}
1938
1963
 
1939
1964
  ### MAI-Voice
1940
1965
 
@@ -2007,5 +2032,33 @@ The following options are available through `providerOptions.azure`:
2007
2032
  - **styleDegree** _number_
2008
2033
  Style intensity from 0.01 to 2. Azure defaults to 1. Requires `style`.
2009
2034
 
2035
+ OpenAI speech options (`instructions` and `speed`) can be passed under
2036
+ `providerOptions.openai` or `providerOptions.azure`; `azure` wins when both set
2037
+ the same option. They produce warnings when used with the Speech API.
2038
+
2010
2039
  Text is always spoken as plain text; SSML input is not supported.
2011
2040
  The models are in public preview. AI Gateway forwards these provider options, including `azure.api`.
2041
+
2042
+ ## Provider Option Reference
2043
+
2044
+ The following option definitions are generated from the provider catalog.
2045
+
2046
+ {/* model-capabilities:azure-provider-options:start */}
2047
+
2048
+ | Operation | Option | Description |
2049
+ | ------------- | ----------------- | ----------------------------------------------- |
2050
+ | image | `api` | Select the OpenAI or MAI image API. |
2051
+ | image | `autoAspectRatio` | Choose the aspect ratio automatically. |
2052
+ | image | `webGrounding` | Ground image generation in web search. |
2053
+ | speech | `api` | Select the OpenAI or Azure Speech API. |
2054
+ | speech | `style` | Speaking style supported by the selected voice. |
2055
+ | speech | `styleDegree` | Intensity of the speaking style. |
2056
+ | transcription | `api` | Select the OpenAI, Azure Speech, or MAI API. |
2057
+ | transcription | `language` | Language hint for MAI streaming transcription. |
2058
+ | transcription | `timestamps` | Word, segment, or no timestamps. |
2059
+ | transcription | `transcribeStyle` | Verbatim or cleaned transcription. |
2060
+ | transcription | `locales` | Language to use for transcription. |
2061
+ | transcription | `diarization` | Enable speaker diarization. |
2062
+ | transcription | `phraseList` | Phrases to bias transcription toward. |
2063
+
2064
+ {/* model-capabilities:azure-provider-options:end */}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/azure",
3
- "version": "4.0.117",
3
+ "version": "4.0.119",
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.80",
33
- "@ai-sdk/openai": "4.0.109",
34
- "@ai-sdk/provider": "4.0.36",
35
- "@ai-sdk/provider-utils": "5.0.75"
32
+ "@ai-sdk/deepseek": "3.0.81",
33
+ "@ai-sdk/openai": "4.0.111",
34
+ "@ai-sdk/provider": "4.0.37",
35
+ "@ai-sdk/provider-utils": "5.0.76"
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.163",
42
+ "ai": "7.0.165",
43
43
  "tsdown": "^0.23.0",
44
44
  "typescript": "6.0.3",
45
45
  "zod": "3.25.76"
@@ -0,0 +1,21 @@
1
+ import { openaiModelCatalog } from '@ai-sdk/openai/internal';
2
+ import { azureModelCatalog } from './azure-model-catalog';
3
+ export { azureProviderOptions } from './azure-model-catalog';
4
+
5
+ /** Backing-model metadata for documented Azure OpenAI deployments and MAI IDs.
6
+ * Deployment names remain opaque at runtime; OpenAI adapters own their policies. */
7
+ export const azureDeploymentModelCatalog = {
8
+ ...Object.fromEntries(
9
+ [
10
+ 'dall-e-3',
11
+ 'dall-e-2',
12
+ 'tts-1',
13
+ 'tts-1-hd',
14
+ 'gpt-4o-mini-tts',
15
+ 'whisper-1',
16
+ 'gpt-4o-mini-transcribe',
17
+ 'gpt-4o-transcribe',
18
+ ].map(id => [id, openaiModelCatalog[id]]),
19
+ ),
20
+ ...azureModelCatalog,
21
+ };
@@ -4,6 +4,7 @@ import {
4
4
  type InferSchema,
5
5
  } from '@ai-sdk/provider-utils';
6
6
  import { z } from 'zod/v4';
7
+ import { getAzureModelEntry } from './azure-model-catalog';
7
8
  import { azureMaiImageModelOptionsShape } from './azure-mai-image-model-options';
8
9
 
9
10
  export const azureImageModelOptions = lazySchema(() =>
@@ -20,15 +21,6 @@ export const azureImageModelOptions = lazySchema(() =>
20
21
 
21
22
  export type AzureImageModelOptions = InferSchema<typeof azureImageModelOptions>;
22
23
 
23
- // Lowercase model IDs served by the MAI image API.
24
- const maiImageModels = new Set([
25
- 'mai-image-2.5',
26
- 'mai-image-2.5-flash',
27
- 'mai-image-2.5-pro',
28
- 'mai-image-2.6',
29
- 'mai-image-2.6-flash',
30
- ]);
31
-
32
24
  export function isMAIImageModel(modelId: string) {
33
- return maiImageModels.has(modelId.toLowerCase());
25
+ return getAzureModelEntry(modelId)?.requestConfig?.image?.api === 'mai';
34
26
  }
@@ -0,0 +1,178 @@
1
+ import type {
2
+ ModelEntry,
3
+ ProviderOptionDefinition,
4
+ ProviderOptionDefinitions,
5
+ } from '@ai-sdk/provider';
6
+ import type { AzureImageModelOptions } from './azure-image-model-options';
7
+ import type { AzureTranscriptionModelMaiOptions } from './azure-mai-transcription-model-options';
8
+ import type { AzureSpeechModelOptions } from './azure-speech-model-options';
9
+ import type { AzureSpeechModelSpeechOptions } from './azure-speech-speech-model-options';
10
+ import type { AzureTranscriptionModelSpeechOptions } from './azure-speech-transcription-model-options';
11
+ import type { AzureTranscriptionModelOptions } from './azure-transcription-model-options';
12
+
13
+ /**
14
+ * Azure-specific options; OpenAI-backed operations retain OpenAI's options,
15
+ * which they also accept under `azure`.
16
+ */
17
+ export const azureProviderOptions = {
18
+ image: {
19
+ api: { description: 'Select the OpenAI or MAI image API.' },
20
+ autoAspectRatio: { description: 'Choose the aspect ratio automatically.' },
21
+ webGrounding: { description: 'Ground image generation in web search.' },
22
+ } satisfies Record<keyof AzureImageModelOptions, ProviderOptionDefinition>,
23
+ speech: {
24
+ api: { description: 'Select the OpenAI or Azure Speech API.' },
25
+ style: { description: 'Speaking style supported by the selected voice.' },
26
+ styleDegree: { description: 'Intensity of the speaking style.' },
27
+ } satisfies Record<
28
+ | ('api' & keyof AzureSpeechModelOptions)
29
+ | keyof AzureSpeechModelSpeechOptions,
30
+ ProviderOptionDefinition
31
+ >,
32
+ transcription: {
33
+ api: { description: 'Select the OpenAI, Azure Speech, or MAI API.' },
34
+ language: { description: 'Language hint for MAI streaming transcription.' },
35
+ timestamps: { description: 'Word, segment, or no timestamps.' },
36
+ transcribeStyle: { description: 'Verbatim or cleaned transcription.' },
37
+ locales: { description: 'Language to use for transcription.' },
38
+ diarization: { description: 'Enable speaker diarization.' },
39
+ phraseList: { description: 'Phrases to bias transcription toward.' },
40
+ } satisfies Record<
41
+ | ('api' & keyof AzureTranscriptionModelOptions)
42
+ | keyof AzureTranscriptionModelSpeechOptions
43
+ | keyof AzureTranscriptionModelMaiOptions,
44
+ ProviderOptionDefinition
45
+ >,
46
+ } as const satisfies ProviderOptionDefinitions;
47
+
48
+ type AzureRequestConfig = {
49
+ image?: { api: 'mai' };
50
+ speech?: { api: 'speech'; voiceModel: string };
51
+ transcription?:
52
+ | { api: 'speech'; name: string; supportsTimestamps: boolean }
53
+ | { api: 'mai' };
54
+ };
55
+
56
+ type AzureModelEntry = ModelEntry<AzureRequestConfig>;
57
+
58
+ function imageEntry(webGrounding: boolean): AzureModelEntry {
59
+ return {
60
+ capabilities: {
61
+ image: {
62
+ sizes: {
63
+ description: 'Sides must be multiples of 16 and at least 768 pixels.',
64
+ },
65
+ fileInput: true,
66
+ maskInput: false,
67
+ maxImagesPerCall: 1,
68
+ },
69
+ },
70
+ providerOptions: {
71
+ image: { api: true, autoAspectRatio: webGrounding, webGrounding },
72
+ },
73
+ requestConfig: { image: { api: 'mai' } },
74
+ };
75
+ }
76
+
77
+ function speechEntry(voiceModel: string): AzureModelEntry {
78
+ return {
79
+ capabilities: { speech: { instructions: false } },
80
+ providerOptions: {
81
+ speech: {
82
+ api: true,
83
+ style: {
84
+ condition: 'Supported styles depend on the selected voice and model.',
85
+ },
86
+ styleDegree: { condition: 'Requires a supported speaking style.' },
87
+ },
88
+ },
89
+ requestConfig: { speech: { api: 'speech', voiceModel } },
90
+ };
91
+ }
92
+
93
+ function transcriptionEntry(
94
+ name: string,
95
+ supportsTimestamps: boolean,
96
+ ): AzureModelEntry {
97
+ return {
98
+ capabilities: {
99
+ transcription: {
100
+ transcription: true,
101
+ streaming: false,
102
+ duration: true,
103
+ segments: supportsTimestamps,
104
+ language: true,
105
+ },
106
+ },
107
+ providerOptions: {
108
+ transcription: {
109
+ api: true,
110
+ language: { condition: 'Requires the MAI streaming API override.' },
111
+ timestamps: supportsTimestamps
112
+ ? true
113
+ : { condition: 'Only none is supported.' },
114
+ transcribeStyle: supportsTimestamps
115
+ ? true
116
+ : { condition: 'Only verbatim is supported.' },
117
+ locales: true,
118
+ diarization: supportsTimestamps,
119
+ phraseList: true,
120
+ },
121
+ },
122
+ requestConfig: {
123
+ transcription: { api: 'speech', name, supportsTimestamps },
124
+ },
125
+ };
126
+ }
127
+
128
+ /**
129
+ * Azure-owned models. OpenAI and DeepSeek deployments use their adapters' model
130
+ * catalogs; arbitrary deployment names do not declare model-family support.
131
+ */
132
+ export const azureModelCatalog: Readonly<Record<string, AzureModelEntry>> = {
133
+ 'mai-image-2.5': imageEntry(false),
134
+ 'mai-image-2.5-flash': imageEntry(false),
135
+ 'mai-image-2.5-pro': imageEntry(false),
136
+ 'mai-image-2.6': imageEntry(true),
137
+ 'mai-image-2.6-flash': imageEntry(true),
138
+ 'mai-voice-2.1-flash': speechEntry('MAI-Voice-2.1-Flash'),
139
+ 'mai-voice-2.1': speechEntry('MAI-Voice-2.1'),
140
+ 'mai-voice-2-flash': speechEntry('MAI-Voice-2-Flash'),
141
+ 'mai-voice-2': speechEntry('MAI-Voice-2'),
142
+ 'mai-transcribe-2': transcriptionEntry('MAI-Transcribe-2', true),
143
+ 'mai-transcribe-1.5': transcriptionEntry('MAI-Transcribe-1.5', false),
144
+ 'mai-transcribe-2-streaming': {
145
+ capabilities: {
146
+ transcription: {
147
+ transcription: false,
148
+ streaming: true,
149
+ duration: {
150
+ condition: 'Requires an audio format with a known byte rate.',
151
+ },
152
+ segments: false,
153
+ language: { condition: 'Reports the configured language hint.' },
154
+ },
155
+ },
156
+ providerOptions: {
157
+ transcription: {
158
+ api: true,
159
+ language: true,
160
+ timestamps: false,
161
+ transcribeStyle: false,
162
+ locales: false,
163
+ diarization: false,
164
+ phraseList: false,
165
+ },
166
+ },
167
+ requestConfig: { transcription: { api: 'mai' } },
168
+ },
169
+ };
170
+
171
+ export function getAzureModelEntry(
172
+ modelId: string,
173
+ ): AzureModelEntry | undefined {
174
+ const id = modelId.toLowerCase();
175
+ return Object.prototype.hasOwnProperty.call(azureModelCatalog, id)
176
+ ? azureModelCatalog[id]
177
+ : undefined;
178
+ }
@@ -6,6 +6,10 @@ import {
6
6
  OpenAIResponsesLanguageModel,
7
7
  OpenAISpeechModel,
8
8
  OpenAITranscriptionModel,
9
+ openaiImageModelEditOptionsShape,
10
+ openaiImageModelGenerationOptionsShape,
11
+ openaiSpeechModelOptionsShape,
12
+ openAITranscriptionModelOptionsShape,
9
13
  } from '@ai-sdk/openai/internal';
10
14
  import { DeepSeekChatLanguageModel } from '@ai-sdk/deepseek/internal';
11
15
  import {
@@ -15,6 +19,7 @@ import {
15
19
  type LanguageModelV4,
16
20
  type ProviderV4,
17
21
  type ImageModelV4,
22
+ type SharedV4ProviderOptions,
18
23
  type SharedV4Warning,
19
24
  type SpeechModelV4,
20
25
  type TranscriptionModelV4,
@@ -46,8 +51,10 @@ import {
46
51
  azureSpeechModelOptions,
47
52
  getMAIVoiceModel,
48
53
  } from './azure-speech-model-options';
54
+ import { azureSpeechSpeechModelOptionsShape } from './azure-speech-speech-model-options';
49
55
  import { AzureSpeechSpeechModel } from './azure-speech-speech-model';
50
56
  import { AzureSpeechTranscriptionModel } from './azure-speech-transcription-model';
57
+ import { azureSpeechTranscriptionModelOptionsShape } from './azure-speech-transcription-model-options';
51
58
  import {
52
59
  azureTranscriptionModelOptions,
53
60
  getMAITranscribeModel,
@@ -595,9 +602,8 @@ class AzureTranscriptionModel implements TranscriptionModelV4 {
595
602
  }
596
603
 
597
604
  async doGenerate(options: Parameters<TranscriptionModelV4['doGenerate']>[0]) {
598
- const { api, speechOptions, maiOptions } = await this.getOptions(
599
- options.providerOptions,
600
- );
605
+ const { api, speechOptions, maiOptions, openaiOptions } =
606
+ await this.getOptions(options.providerOptions);
601
607
  if (api === 'mai') {
602
608
  return this.mai.doGenerate();
603
609
  }
@@ -605,40 +611,42 @@ class AzureTranscriptionModel implements TranscriptionModelV4 {
605
611
  const result = await this.speech.doGenerate(options, speechOptions);
606
612
  return {
607
613
  ...result,
608
- warnings: [...result.warnings, ...maiOnlyWarnings(maiOptions)],
614
+ warnings: [
615
+ ...result.warnings,
616
+ ...maiOnlyWarnings(maiOptions),
617
+ ...openaiTranscriptionOnlyWarnings(openaiOptions),
618
+ ],
609
619
  };
610
620
  }
611
621
 
612
- const result = await this.openai.doGenerate(options);
622
+ const result = await this.openai.doGenerate(
623
+ withAzureOptionsForOpenAI(options, openaiOptions),
624
+ );
613
625
  return {
614
626
  ...result,
615
- warnings: [
616
- ...result.warnings,
617
- ...speechOnlyWarnings(speechOptions),
618
- ...maiOnlyWarnings(maiOptions),
619
- ],
627
+ warnings: [...result.warnings, ...speechOnlyWarnings(speechOptions)],
620
628
  };
621
629
  }
622
630
 
623
631
  async doStream(
624
632
  options: Parameters<NonNullable<TranscriptionModelV4['doStream']>>[0],
625
633
  ) {
626
- const { api, speechOptions, maiOptions } = await this.getOptions(
627
- options.providerOptions,
628
- );
634
+ const { api, speechOptions, maiOptions, openaiOptions } =
635
+ await this.getOptions(options.providerOptions);
629
636
  if (api === 'speech') {
630
637
  throw new UnsupportedFunctionalityError({
631
638
  functionality: 'streaming transcription with the Azure Speech API',
632
639
  });
633
640
  }
634
641
  if (api === 'mai') {
635
- return this.mai.doStream(
636
- options,
637
- maiOptions,
638
- speechOnlyWarnings(speechOptions),
639
- );
642
+ return this.mai.doStream(options, maiOptions, [
643
+ ...speechOnlyWarnings(speechOptions),
644
+ ...openaiTranscriptionOnlyWarnings(openaiOptions),
645
+ ]);
640
646
  }
641
- return this.openai.doStream(options);
647
+ return this.openai.doStream(
648
+ withAzureOptionsForOpenAI(options, openaiOptions),
649
+ );
642
650
  }
643
651
 
644
652
  private async getOptions(
@@ -646,7 +654,7 @@ class AzureTranscriptionModel implements TranscriptionModelV4 {
646
654
  TranscriptionModelV4['doGenerate']
647
655
  >[0]['providerOptions'],
648
656
  ) {
649
- const { api, language, ...speechOptions } =
657
+ const { api, language, ...options } =
650
658
  (await parseProviderOptions({
651
659
  provider: 'azure',
652
660
  providerOptions,
@@ -660,8 +668,15 @@ class AzureTranscriptionModel implements TranscriptionModelV4 {
660
668
  : getMAITranscribeModel(this.modelId)
661
669
  ? ('speech' as const)
662
670
  : ('openai' as const)),
663
- speechOptions,
671
+ speechOptions: pickKeys(
672
+ options,
673
+ azureSpeechTranscriptionModelOptionsShape(),
674
+ ),
664
675
  maiOptions: language != null ? { language } : {},
676
+ openaiOptions: pickAzureOptions(
677
+ providerOptions,
678
+ openAITranscriptionModelOptionsShape(),
679
+ ),
665
680
  };
666
681
  }
667
682
  }
@@ -693,20 +708,40 @@ class AzureSpeechModel implements SpeechModelV4 {
693
708
  }
694
709
 
695
710
  async doGenerate(options: Parameters<SpeechModelV4['doGenerate']>[0]) {
696
- const { api, ...speechOptions } =
711
+ const { api, ...parsedOptions } =
697
712
  (await parseProviderOptions({
698
713
  provider: 'azure',
699
714
  providerOptions: options.providerOptions,
700
715
  schema: azureSpeechModelOptions,
701
716
  })) ?? {};
717
+ const speechOptions = pickKeys(
718
+ parsedOptions,
719
+ azureSpeechSpeechModelOptionsShape(),
720
+ );
721
+ const openaiOptions = pickAzureOptions(
722
+ options.providerOptions,
723
+ openaiSpeechModelOptionsShape(),
724
+ );
702
725
  if (
703
726
  (api ?? (getMAIVoiceModel(this.modelId) ? 'speech' : 'openai')) ===
704
727
  'speech'
705
728
  ) {
706
- return this.speech.doGenerate(options, speechOptions);
729
+ const result = await this.speech.doGenerate(options, speechOptions);
730
+ return {
731
+ ...result,
732
+ warnings: [
733
+ ...result.warnings,
734
+ ...unsupportedOptionWarnings(
735
+ openaiOptions,
736
+ 'This option requires the OpenAI speech API.',
737
+ ),
738
+ ],
739
+ };
707
740
  }
708
741
 
709
- const result = await this.openai.doGenerate(options);
742
+ const result = await this.openai.doGenerate(
743
+ withAzureOptionsForOpenAI(options, openaiOptions),
744
+ );
710
745
  return {
711
746
  ...result,
712
747
  warnings: [...result.warnings, ...speechOnlyWarnings(speechOptions)],
@@ -768,7 +803,17 @@ class AzureImageModel implements ImageModelV4 {
768
803
  return this.mai.doGenerate(options, maiOptions);
769
804
  }
770
805
 
771
- const result = await this.openai.doGenerate(options);
806
+ const result = await this.openai.doGenerate(
807
+ withAzureOptionsForOpenAI(
808
+ options,
809
+ pickAzureOptions(
810
+ options.providerOptions,
811
+ options.files != null
812
+ ? openaiImageModelEditOptionsShape()
813
+ : openaiImageModelGenerationOptionsShape(),
814
+ ),
815
+ ),
816
+ );
772
817
  return {
773
818
  ...result,
774
819
  warnings: [
@@ -782,6 +827,62 @@ class AzureImageModel implements ImageModelV4 {
782
827
  }
783
828
  }
784
829
 
830
+ /**
831
+ * Picks the options that the given schema shape accepts from the raw `azure`
832
+ * provider options. Raw values are used so schema defaults are not injected;
833
+ * the OpenAI model validates them again.
834
+ */
835
+ function pickAzureOptions(
836
+ providerOptions: SharedV4ProviderOptions | undefined,
837
+ shape: Record<string, unknown>,
838
+ ): Record<string, unknown> {
839
+ return pickKeys(providerOptions?.azure ?? {}, shape);
840
+ }
841
+
842
+ function pickKeys(
843
+ options: Record<string, unknown>,
844
+ shape: Record<string, unknown>,
845
+ ): Record<string, unknown> {
846
+ return Object.fromEntries(
847
+ Object.entries(options).filter(
848
+ ([key, value]) => Object.hasOwn(shape, key) && value !== undefined,
849
+ ),
850
+ );
851
+ }
852
+
853
+ /**
854
+ * Azure OpenAI deployments accept their OpenAI API options under `azure` as
855
+ * well as `openai`. Both are merged into `openai` for the OpenAI model; `azure`
856
+ * wins, like it does for Azure chat and completion models.
857
+ */
858
+ function withAzureOptionsForOpenAI<
859
+ OPTIONS extends { providerOptions?: SharedV4ProviderOptions },
860
+ >(options: OPTIONS, azureOptions: Record<string, unknown>): OPTIONS {
861
+ if (Object.keys(azureOptions).length === 0) {
862
+ return options;
863
+ }
864
+
865
+ return {
866
+ ...options,
867
+ providerOptions: {
868
+ ...options.providerOptions,
869
+ openai: {
870
+ ...options.providerOptions?.openai,
871
+ ...azureOptions,
872
+ } as SharedV4ProviderOptions[string],
873
+ },
874
+ };
875
+ }
876
+
877
+ function openaiTranscriptionOnlyWarnings(options: Record<string, unknown>) {
878
+ // `language` is shared with MAI and reported by `maiOnlyWarnings`.
879
+ const { language: _language, ...openaiOnlyOptions } = options;
880
+ return unsupportedOptionWarnings(
881
+ openaiOnlyOptions,
882
+ 'This option requires the OpenAI transcription API.',
883
+ );
884
+ }
885
+
785
886
  function speechOnlyWarnings(options: Record<string, unknown>) {
786
887
  return unsupportedOptionWarnings(
787
888
  options,