@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/CHANGELOG.md +25 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +169 -44
- package/dist/index.js.map +1 -1
- package/docs/04-azure.mdx +76 -23
- package/package.json +6 -6
- package/src/azure-deployment-model-catalog.ts +21 -0
- package/src/azure-image-model-options.ts +2 -10
- package/src/azure-model-catalog.ts +178 -0
- package/src/azure-openai-provider.ts +126 -25
- package/src/azure-speech-model-options.ts +5 -9
- package/src/azure-transcription-model-options.ts +12 -12
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
zodSchema,
|
|
4
4
|
type InferSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
6
|
+
import { openaiSpeechModelOptionsShape } from '@ai-sdk/openai/internal';
|
|
6
7
|
import { z } from 'zod/v4';
|
|
8
|
+
import { getAzureModelEntry } from './azure-model-catalog';
|
|
7
9
|
import { azureSpeechSpeechModelOptionsShape } from './azure-speech-speech-model-options';
|
|
8
10
|
|
|
9
11
|
export const azureSpeechModelOptions = lazySchema(() =>
|
|
@@ -13,6 +15,8 @@ export const azureSpeechModelOptions = lazySchema(() =>
|
|
|
13
15
|
* API to use. Defaults to Speech for MAI-Voice models, OpenAI otherwise.
|
|
14
16
|
*/
|
|
15
17
|
api: z.enum(['openai', 'speech']).optional(),
|
|
18
|
+
// OpenAI API options for Azure OpenAI deployments.
|
|
19
|
+
...openaiSpeechModelOptionsShape(),
|
|
16
20
|
...azureSpeechSpeechModelOptionsShape(),
|
|
17
21
|
}),
|
|
18
22
|
),
|
|
@@ -22,14 +26,6 @@ export type AzureSpeechModelOptions = InferSchema<
|
|
|
22
26
|
typeof azureSpeechModelOptions
|
|
23
27
|
>;
|
|
24
28
|
|
|
25
|
-
// Azure voice-name suffixes by lowercase model ID.
|
|
26
|
-
const maiVoiceModels = new Map([
|
|
27
|
-
['mai-voice-2.1-flash', 'MAI-Voice-2.1-Flash'],
|
|
28
|
-
['mai-voice-2.1', 'MAI-Voice-2.1'],
|
|
29
|
-
['mai-voice-2-flash', 'MAI-Voice-2-Flash'],
|
|
30
|
-
['mai-voice-2', 'MAI-Voice-2'],
|
|
31
|
-
]);
|
|
32
|
-
|
|
33
29
|
export function getMAIVoiceModel(modelId: string) {
|
|
34
|
-
return
|
|
30
|
+
return getAzureModelEntry(modelId)?.requestConfig?.speech?.voiceModel;
|
|
35
31
|
}
|
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
zodSchema,
|
|
4
4
|
type InferSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
6
|
+
import { openAITranscriptionModelOptionsShape } from '@ai-sdk/openai/internal';
|
|
6
7
|
import { z } from 'zod/v4';
|
|
8
|
+
import { getAzureModelEntry } from './azure-model-catalog';
|
|
7
9
|
import { azureMaiTranscriptionModelOptionsShape } from './azure-mai-transcription-model-options';
|
|
8
10
|
import { azureSpeechTranscriptionModelOptionsShape } from './azure-speech-transcription-model-options';
|
|
9
11
|
|
|
@@ -15,6 +17,9 @@ export const azureTranscriptionModelOptions = lazySchema(() =>
|
|
|
15
17
|
* MAI-Transcribe-2-Streaming, and OpenAI otherwise.
|
|
16
18
|
*/
|
|
17
19
|
api: z.enum(['openai', 'speech', 'mai']).optional(),
|
|
20
|
+
// OpenAI API options for Azure OpenAI deployments. Listed first so the
|
|
21
|
+
// shared `language` key keeps the MAI validation.
|
|
22
|
+
...openAITranscriptionModelOptionsShape(),
|
|
18
23
|
...azureSpeechTranscriptionModelOptionsShape(),
|
|
19
24
|
...azureMaiTranscriptionModelOptionsShape(),
|
|
20
25
|
}),
|
|
@@ -25,20 +30,15 @@ export type AzureTranscriptionModelOptions = InferSchema<
|
|
|
25
30
|
typeof azureTranscriptionModelOptions
|
|
26
31
|
>;
|
|
27
32
|
|
|
28
|
-
// Azure Speech model names by lowercase model ID. MAI-Transcribe-1.5 only
|
|
29
|
-
// accepts Azure's default timestamps (`none`).
|
|
30
|
-
const maiTranscribeModels = new Map([
|
|
31
|
-
['mai-transcribe-2', { name: 'MAI-Transcribe-2', supportsTimestamps: true }],
|
|
32
|
-
[
|
|
33
|
-
'mai-transcribe-1.5',
|
|
34
|
-
{ name: 'MAI-Transcribe-1.5', supportsTimestamps: false },
|
|
35
|
-
],
|
|
36
|
-
]);
|
|
37
|
-
|
|
38
33
|
export function getMAITranscribeModel(modelId: string) {
|
|
39
|
-
|
|
34
|
+
const config = getAzureModelEntry(modelId)?.requestConfig?.transcription;
|
|
35
|
+
return config?.api === 'speech'
|
|
36
|
+
? { name: config.name, supportsTimestamps: config.supportsTimestamps }
|
|
37
|
+
: undefined;
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
export function isMAITranscribeStreaming(modelId: string): boolean {
|
|
43
|
-
return
|
|
41
|
+
return (
|
|
42
|
+
getAzureModelEntry(modelId)?.requestConfig?.transcription?.api === 'mai'
|
|
43
|
+
);
|
|
44
44
|
}
|