@ai-sdk/azure 4.0.87 → 4.0.89
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 +13 -0
- package/dist/index.d.ts +20 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +256 -12
- package/dist/index.js.map +1 -1
- package/docs/04-azure.mdx +103 -18
- package/package.json +1 -1
- package/src/azure-openai-provider.ts +101 -17
- package/src/azure-speech-model-options.ts +33 -0
- package/src/azure-speech-speech-model-options.ts +27 -0
- package/src/azure-speech-speech-model.ts +282 -0
- package/src/azure-speech-transcription-model.ts +6 -5
- package/src/azure-transcription-model-options.ts +13 -3
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/azure
|
|
2
2
|
|
|
3
|
+
## 4.0.89
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d08102b: Add test coverage for `resourceName` validation edge cases: labels at the 63-character limit, underscores, non-ASCII characters, and invalid `AZURE_RESOURCE_NAME` values for non-language models.
|
|
8
|
+
|
|
9
|
+
## 4.0.88
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 560ac0b: Route `mai-transcribe-1.5` to the Azure Speech API by default, like `mai-transcribe-2`. MAI-Transcribe-1.5 requests no longer send the `segment` timestamps default, which the model rejects.
|
|
14
|
+
- 00f2a59: Add MAI-Voice-2-Flash and MAI-Voice-2 speech generation through `azure.speech()` using Azure Speech text to speech (SSML), with voice, output format, speed, and `style`/`styleDegree` provider options. `language` picks a default voice when no voice is set. Select the API with `providerOptions.azure.api` to override model-based routing, and add `azure.speechModel()` as an alias of `azure.speech()`.
|
|
15
|
+
|
|
3
16
|
## 4.0.87
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -60,8 +60,8 @@ interface AzureOpenAIProvider extends ProviderV4 {
|
|
|
60
60
|
*/
|
|
61
61
|
imageModel(deploymentId: string): ImageModelV4;
|
|
62
62
|
/**
|
|
63
|
-
* Creates an Azure transcription model. MAI-Transcribe
|
|
64
|
-
* by default; other IDs use OpenAI. Override with providerOptions.azure.api.
|
|
63
|
+
* Creates an Azure transcription model. MAI-Transcribe models use the Speech
|
|
64
|
+
* API by default; other IDs use OpenAI. Override with providerOptions.azure.api.
|
|
65
65
|
*/
|
|
66
66
|
transcription(deploymentId: string): TranscriptionModelV4;
|
|
67
67
|
/**
|
|
@@ -69,9 +69,14 @@ interface AzureOpenAIProvider extends ProviderV4 {
|
|
|
69
69
|
*/
|
|
70
70
|
transcriptionModel(deploymentId: string): TranscriptionModelV4;
|
|
71
71
|
/**
|
|
72
|
-
* Creates an Azure
|
|
72
|
+
* Creates an Azure speech generation model. MAI-Voice models use the Speech
|
|
73
|
+
* API by default; other IDs use OpenAI. Override with providerOptions.azure.api.
|
|
73
74
|
*/
|
|
74
75
|
speech(deploymentId: string): SpeechModelV4;
|
|
76
|
+
/**
|
|
77
|
+
* Creates an Azure speech generation model. Alias of `speech`.
|
|
78
|
+
*/
|
|
79
|
+
speechModel(deploymentId: string): SpeechModelV4;
|
|
75
80
|
/**
|
|
76
81
|
* AzureOpenAI-specific tools.
|
|
77
82
|
*/
|
|
@@ -125,8 +130,9 @@ interface AzureOpenAIProviderSettings {
|
|
|
125
130
|
*/
|
|
126
131
|
useDeploymentBasedUrls?: boolean;
|
|
127
132
|
/**
|
|
128
|
-
* URL prefix for Azure Speech
|
|
129
|
-
* regional endpoint like
|
|
133
|
+
* URL prefix for Azure Speech (MAI-Transcribe transcription and MAI-Voice
|
|
134
|
+
* speech), e.g. a regional endpoint like
|
|
135
|
+
* `https://eastus.api.cognitive.microsoft.com`.
|
|
130
136
|
* Defaults to `https://{resourceName}.cognitiveservices.azure.com`.
|
|
131
137
|
* Speech requests do not use `baseURL` or `apiVersion`.
|
|
132
138
|
*/
|
|
@@ -158,6 +164,14 @@ type AzureResponsesSourceDocumentProviderMetadata = {
|
|
|
158
164
|
//#region src/version.d.ts
|
|
159
165
|
export declare const VERSION: string;
|
|
160
166
|
//#endregion
|
|
167
|
+
//#region src/azure-speech-model-options.d.ts
|
|
168
|
+
declare const azureSpeechModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
169
|
+
style?: string | undefined;
|
|
170
|
+
styleDegree?: number | undefined;
|
|
171
|
+
api?: "openai" | "speech" | undefined;
|
|
172
|
+
}>;
|
|
173
|
+
type AzureSpeechModelOptions = InferSchema<typeof azureSpeechModelOptions>;
|
|
174
|
+
//#endregion
|
|
161
175
|
//#region src/azure-transcription-model-options.d.ts
|
|
162
176
|
declare const azureTranscriptionModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
163
177
|
timestamps?: "word" | "segment" | "none" | undefined;
|
|
@@ -197,5 +211,5 @@ export type AzureDeepSeekLanguageModelOptions = Omit<DeepSeekLanguageModelChatOp
|
|
|
197
211
|
/** @deprecated Use `AzureDeepSeekLanguageModelOptions` instead. */
|
|
198
212
|
export type AzureDeepSeekChatOptions = AzureDeepSeekLanguageModelOptions;
|
|
199
213
|
//#endregion
|
|
200
|
-
export type { AzureOpenAIProvider, AzureOpenAIProviderSettings, AzureResponsesProviderMetadata, AzureResponsesReasoningProviderMetadata, AzureResponsesSourceDocumentProviderMetadata, AzureResponsesTextProviderMetadata, AzureTranscriptionModelOptions, AzureTranscriptionProviderMetadata, OpenAIChatLanguageModelOptions, OpenAILanguageModelChatOptions, OpenAILanguageModelResponsesOptions, OpenAIResponsesProviderOptions, OpenAIResponsesSystemMessageOptions };
|
|
214
|
+
export type { AzureOpenAIProvider, AzureOpenAIProviderSettings, AzureResponsesProviderMetadata, AzureResponsesReasoningProviderMetadata, AzureResponsesSourceDocumentProviderMetadata, AzureResponsesTextProviderMetadata, AzureSpeechModelOptions, AzureTranscriptionModelOptions, AzureTranscriptionProviderMetadata, OpenAIChatLanguageModelOptions, OpenAILanguageModelChatOptions, OpenAILanguageModelResponsesOptions, OpenAIResponsesProviderOptions, OpenAIResponsesSystemMessageOptions };
|
|
201
215
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/azure-openai-tools.ts","../src/azure-openai-provider.ts","../src/azure-openai-provider-metadata.ts","../src/version.ts","../src/azure-transcription-model-options.ts","../src/azure-transcription-provider-metadata.ts","../src/index.ts"],"mappings":";;;;;;cAQa;EACX,wBAAwB;EACxB,mBAAmB;EACnB,wBAAwB;EACxB,kBAAkB;EAClB,yBAAyB;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/azure-openai-tools.ts","../src/azure-openai-provider.ts","../src/azure-openai-provider-metadata.ts","../src/version.ts","../src/azure-speech-model-options.ts","../src/azure-transcription-model-options.ts","../src/azure-transcription-provider-metadata.ts","../src/index.ts"],"mappings":";;;;;;cAQa;EACX,wBAAwB;EACxB,mBAAmB;EACnB,wBAAwB;EACxB,kBAAkB;EAClB,yBAAyB;;;;UCkCV,4BAA4B;GAC1C,uBAAuB;;;;EAKxB,cAAc,uBAAuB;;;;EAKrC,KAAK,uBAAuB;;;;EAK5B,SAAS,uBAAuB;;;;EAKhC,UAAU,uBAAuB;;;;EAKjC,WAAW,uBAAuB;;;;EAKlC,UAAU,uBAAuB;;;;EAKjC,eAAe,uBAAuB;;;;EAKtC,cAAc,uBAAuB;;;;EAKrC,mBAAmB,uBAAuB;;;;EAK1C,MAAM,uBAAuB;;;;EAK7B,WAAW,uBAAuB;;;;;EAMlC,cAAc,uBAAuB;;;;EAKrC,mBAAmB,uBAAuB;;;;;EAM1C,OAAO,uBAAuB;;;;EAK9B,YAAY,uBAAuB;;;;EAKnC,cAAc;;UAGC;;;;;;;EAOf;;;;;;;;;EAUA;;;;EAKA;;;;;;EAOA,uBAAuB;;;;EAKvB,UAAU;;;;;EAMV,QAAQ;;;;;EAMR;;;;;;EAOA;;;;;;;;EASA;;;;;wBAgCc,YACd,UAAS,8BACR;;;;qBA4OU,OAAK;;;KC1cN;EACV,OAAO;;KAGG;EACV,OAAO;;KAGG;EACV,OAAO;;KAGG;EACV,OAAO;;;;qBClBI;;;cCMA,0DAAuB;;;;;KAYxB,0BAA0B,mBAC7B;;;cCbI,iEAA8B;;;;;;;;;;;;KAY/B,iCAAiC,mBACpC;;;KCrBG;EACV;IACE,SAAS;MACP;MACA;MACA;MACA;MACA;MACA;MACA,QAAQ;QACN;QACA;QACA;;;;;;;YCVI,oCAAoC,KAC9C;;YAIU,2BAA2B"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAIChatLanguageModel, OpenAICompletionLanguageModel, OpenAIEmbeddingModel, OpenAIImageModel, OpenAIResponsesLanguageModel, OpenAISpeechModel, OpenAITranscriptionModel, codeInterpreter, fileSearch, imageGeneration, webSearch, webSearchPreview } from "@ai-sdk/openai/internal";
|
|
2
2
|
import { DeepSeekChatLanguageModel } from "@ai-sdk/deepseek/internal";
|
|
3
|
-
import { InvalidArgumentError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
|
|
4
|
-
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertBase64ToUint8Array, createJsonErrorResponseHandler, createJsonResponseHandler, isValidHostnamePart, lazySchema, loadApiKey, loadSetting, mediaTypeToExtension, normalizeHeaders, parseProviderOptions, postFormDataToApi, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
3
|
+
import { APICallError, InvalidArgumentError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
|
|
4
|
+
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertBase64ToUint8Array, createBinaryResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, extractResponseHeaders, isValidHostnamePart, lazySchema, loadApiKey, loadSetting, mediaTypeToExtension, normalizeHeaders, parseProviderOptions, postFormDataToApi, postToApi, safeParseJSON, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
//#region src/azure-openai-tools.ts
|
|
7
7
|
const azureOpenaiTools = {
|
|
@@ -12,6 +12,200 @@ const azureOpenaiTools = {
|
|
|
12
12
|
webSearchPreview
|
|
13
13
|
};
|
|
14
14
|
//#endregion
|
|
15
|
+
//#region src/azure-speech-speech-model-options.ts
|
|
16
|
+
const azureSpeechSpeechModelOptionsShape = () => ({
|
|
17
|
+
/**
|
|
18
|
+
* Speaking style applied with `mstts:express-as`, e.g. `excited` or
|
|
19
|
+
* `whispering`. Supported styles vary by voice.
|
|
20
|
+
*/
|
|
21
|
+
style: z.string().min(1).optional(),
|
|
22
|
+
/**
|
|
23
|
+
* Intensity of `style`, from 0.01 to 2. Azure defaults to 1.
|
|
24
|
+
*/
|
|
25
|
+
styleDegree: z.number().min(.01).max(2).optional()
|
|
26
|
+
});
|
|
27
|
+
lazySchema(() => zodSchema(z.strictObject(azureSpeechSpeechModelOptionsShape())));
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/azure-speech-model-options.ts
|
|
30
|
+
const azureSpeechModelOptions = lazySchema(() => zodSchema(z.strictObject({
|
|
31
|
+
/**
|
|
32
|
+
* API to use. Defaults to Speech for MAI-Voice models, OpenAI otherwise.
|
|
33
|
+
*/
|
|
34
|
+
api: z.enum(["openai", "speech"]).optional(),
|
|
35
|
+
...azureSpeechSpeechModelOptionsShape()
|
|
36
|
+
})));
|
|
37
|
+
const maiVoiceModels = /* @__PURE__ */ new Map([["mai-voice-2-flash", "MAI-Voice-2-Flash"], ["mai-voice-2", "MAI-Voice-2"]]);
|
|
38
|
+
function getMAIVoiceModel(modelId) {
|
|
39
|
+
return maiVoiceModels.get(modelId.toLowerCase());
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/azure-speech-speech-model.ts
|
|
43
|
+
const DEFAULT_VOICE = "en-US-Harper";
|
|
44
|
+
const DEFAULT_VOICES = /* @__PURE__ */ new Map([
|
|
45
|
+
["de", "de-DE-Mia"],
|
|
46
|
+
["en", DEFAULT_VOICE],
|
|
47
|
+
["es", "es-MX-Valeria"],
|
|
48
|
+
["fr", "fr-FR-Soleil"],
|
|
49
|
+
["hi", "hi-IN-Kavya"],
|
|
50
|
+
["hu", "hu-HU-Lilla"],
|
|
51
|
+
["it", "it-IT-Rosa"],
|
|
52
|
+
["ko", "ko-KR-Haena"],
|
|
53
|
+
["nl", "nl-NL-Fleur"],
|
|
54
|
+
["pt", "pt-BR-Luana"],
|
|
55
|
+
["ro", "ro-RO-Elena"],
|
|
56
|
+
["ru", "ru-RU-Masha"],
|
|
57
|
+
["th", "th-TH-Krit"],
|
|
58
|
+
["tr", "tr-TR-Elif"],
|
|
59
|
+
["zh", "zh-CN-Mei"]
|
|
60
|
+
]);
|
|
61
|
+
const DEFAULT_OUTPUT_FORMAT = "audio-24khz-160kbitrate-mono-mp3";
|
|
62
|
+
const OUTPUT_FORMATS = /* @__PURE__ */ new Map([
|
|
63
|
+
["mp3", DEFAULT_OUTPUT_FORMAT],
|
|
64
|
+
["opus", "ogg-24khz-16bit-mono-opus"],
|
|
65
|
+
["pcm", "raw-24khz-16bit-mono-pcm"],
|
|
66
|
+
["wav", "riff-24khz-16bit-mono-pcm"]
|
|
67
|
+
]);
|
|
68
|
+
const NATIVE_OUTPUT_FORMAT = /^(?:amr|audio|g722|ogg|raw|riff|webm)-[a-z0-9-]+$/;
|
|
69
|
+
/**
|
|
70
|
+
* Azure Speech text to speech with SSML. The model is appended to the voice
|
|
71
|
+
* name, e.g. `en-US-Harper:MAI-Voice-2`.
|
|
72
|
+
*/
|
|
73
|
+
var AzureSpeechSpeechModel = class {
|
|
74
|
+
constructor(modelId, config) {
|
|
75
|
+
this.modelId = modelId;
|
|
76
|
+
this.config = config;
|
|
77
|
+
this.specificationVersion = "v4";
|
|
78
|
+
this.provider = "azure.speech";
|
|
79
|
+
}
|
|
80
|
+
async doGenerate(options, azureOptions = {}) {
|
|
81
|
+
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date();
|
|
82
|
+
const warnings = [];
|
|
83
|
+
const { style, styleDegree } = azureOptions;
|
|
84
|
+
if (options.instructions != null) warnings.push({
|
|
85
|
+
type: "unsupported",
|
|
86
|
+
feature: "instructions",
|
|
87
|
+
details: "Use providerOptions.azure.style to control speaking style."
|
|
88
|
+
});
|
|
89
|
+
const { voice, languageWarning } = resolveVoice(options.voice, options.language);
|
|
90
|
+
if (languageWarning != null) warnings.push({
|
|
91
|
+
type: "unsupported",
|
|
92
|
+
feature: "language",
|
|
93
|
+
details: languageWarning
|
|
94
|
+
});
|
|
95
|
+
if (styleDegree != null && style == null) warnings.push({
|
|
96
|
+
type: "unsupported",
|
|
97
|
+
feature: "providerOptions.azure.styleDegree",
|
|
98
|
+
details: "styleDegree requires style."
|
|
99
|
+
});
|
|
100
|
+
let outputFormat = DEFAULT_OUTPUT_FORMAT;
|
|
101
|
+
if (options.outputFormat != null) {
|
|
102
|
+
const format = options.outputFormat.toLowerCase();
|
|
103
|
+
const shorthand = OUTPUT_FORMATS.get(format);
|
|
104
|
+
if (shorthand != null) outputFormat = shorthand;
|
|
105
|
+
else if (NATIVE_OUTPUT_FORMAT.test(format)) outputFormat = format;
|
|
106
|
+
else warnings.push({
|
|
107
|
+
type: "unsupported",
|
|
108
|
+
feature: "outputFormat",
|
|
109
|
+
details: `Unsupported output format: ${options.outputFormat}. Using mp3 instead.`
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const ssml = buildSsml({
|
|
113
|
+
text: options.text,
|
|
114
|
+
voiceName: voice.includes(":") ? voice : `${voice}:${getMAIVoiceModel(this.modelId) ?? this.modelId}`,
|
|
115
|
+
locale: /^([a-z]{2,3}-[a-z]{2,4})-/i.exec(voice)?.[1],
|
|
116
|
+
speed: options.speed,
|
|
117
|
+
style,
|
|
118
|
+
styleDegree: style != null ? styleDegree : void 0
|
|
119
|
+
});
|
|
120
|
+
const { value: audio, responseHeaders, rawValue } = await postToApi({
|
|
121
|
+
url: this.config.url(),
|
|
122
|
+
headers: combineHeaders(this.config.headers(), {
|
|
123
|
+
"Content-Type": "application/ssml+xml",
|
|
124
|
+
"X-Microsoft-OutputFormat": outputFormat
|
|
125
|
+
}, options.headers),
|
|
126
|
+
body: {
|
|
127
|
+
content: ssml,
|
|
128
|
+
values: ssml
|
|
129
|
+
},
|
|
130
|
+
failedResponseHandler,
|
|
131
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
132
|
+
abortSignal: options.abortSignal,
|
|
133
|
+
fetch: this.config.fetch
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
audio,
|
|
137
|
+
warnings,
|
|
138
|
+
request: { body: ssml },
|
|
139
|
+
response: {
|
|
140
|
+
timestamp: currentDate,
|
|
141
|
+
modelId: this.modelId,
|
|
142
|
+
headers: responseHeaders,
|
|
143
|
+
body: rawValue
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
function buildSsml({ text, voiceName, locale = "en-US", speed, style, styleDegree }) {
|
|
149
|
+
let content = escapeXml(text);
|
|
150
|
+
if (speed != null) content = `<prosody rate="${speed}">${content}</prosody>`;
|
|
151
|
+
if (style != null) {
|
|
152
|
+
const degree = styleDegree != null ? ` styledegree="${styleDegree}"` : "";
|
|
153
|
+
content = `<mstts:express-as style="${escapeXml(style)}"${degree}>${content}</mstts:express-as>`;
|
|
154
|
+
}
|
|
155
|
+
return `<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="http://www.w3.org/2001/mstts" xml:lang="${escapeXml(locale)}"><voice name="${escapeXml(voiceName)}">${content}</voice></speak>`;
|
|
156
|
+
}
|
|
157
|
+
const XML_ESCAPES = {
|
|
158
|
+
"&": "&",
|
|
159
|
+
"<": "<",
|
|
160
|
+
">": ">",
|
|
161
|
+
"\"": """,
|
|
162
|
+
"'": "'"
|
|
163
|
+
};
|
|
164
|
+
function escapeXml(value) {
|
|
165
|
+
return value.replace(/[&<>"']/g, (char) => XML_ESCAPES[char]);
|
|
166
|
+
}
|
|
167
|
+
function resolveVoice(voice, language) {
|
|
168
|
+
const code = language ? language.split("-")[0].toLowerCase() : void 0;
|
|
169
|
+
if (voice == null) {
|
|
170
|
+
if (code == null) return { voice: DEFAULT_VOICE };
|
|
171
|
+
if (code === "auto") return {
|
|
172
|
+
voice: DEFAULT_VOICE,
|
|
173
|
+
languageWarning: `Automatic language detection is not supported. ${DEFAULT_VOICE} was used.`
|
|
174
|
+
};
|
|
175
|
+
const defaultVoice = DEFAULT_VOICES.get(code);
|
|
176
|
+
return defaultVoice != null ? { voice: defaultVoice } : {
|
|
177
|
+
voice: DEFAULT_VOICE,
|
|
178
|
+
languageWarning: `No default MAI voice for language "${language}". ${DEFAULT_VOICE} was used.`
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const voiceLanguage = /^([a-z]{2,3})-[a-z]{2,4}-/i.exec(voice)?.[1]?.toLowerCase();
|
|
182
|
+
return code != null && code !== "auto" && voiceLanguage != null && code !== voiceLanguage ? {
|
|
183
|
+
voice,
|
|
184
|
+
languageWarning: `The voice ${voice} selects the language. Language "${language}" was ignored.`
|
|
185
|
+
} : { voice };
|
|
186
|
+
}
|
|
187
|
+
const errorSchema = z.object({ error: z.object({ message: z.string() }) });
|
|
188
|
+
const failedResponseHandler = async ({ response, url, requestBodyValues }) => {
|
|
189
|
+
const responseHeaders = extractResponseHeaders(response);
|
|
190
|
+
const responseBody = await response.text();
|
|
191
|
+
const parsed = await safeParseJSON({
|
|
192
|
+
text: responseBody,
|
|
193
|
+
schema: errorSchema
|
|
194
|
+
});
|
|
195
|
+
const message = parsed.success ? parsed.value.error.message : response.status === 400 ? "Azure Speech request failed with status 400. Check the voice name, style, and output format." : `Azure Speech request failed with status ${response.status}.`;
|
|
196
|
+
return {
|
|
197
|
+
responseHeaders,
|
|
198
|
+
value: new APICallError({
|
|
199
|
+
message,
|
|
200
|
+
url,
|
|
201
|
+
requestBodyValues,
|
|
202
|
+
statusCode: response.status,
|
|
203
|
+
responseHeaders,
|
|
204
|
+
responseBody
|
|
205
|
+
})
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
//#endregion
|
|
15
209
|
//#region src/azure-speech-transcription-model-options.ts
|
|
16
210
|
const azureSpeechTranscriptionModelOptionsShape = () => ({
|
|
17
211
|
/**
|
|
@@ -47,13 +241,20 @@ lazySchema(() => zodSchema(z.strictObject(azureSpeechTranscriptionModelOptionsSh
|
|
|
47
241
|
//#region src/azure-transcription-model-options.ts
|
|
48
242
|
const azureTranscriptionModelOptions = lazySchema(() => zodSchema(z.strictObject({
|
|
49
243
|
/**
|
|
50
|
-
* API to use. Defaults to Speech for MAI-Transcribe
|
|
244
|
+
* API to use. Defaults to Speech for MAI-Transcribe models, OpenAI otherwise.
|
|
51
245
|
*/
|
|
52
246
|
api: z.enum(["openai", "speech"]).optional(),
|
|
53
247
|
...azureSpeechTranscriptionModelOptionsShape()
|
|
54
248
|
})));
|
|
55
|
-
|
|
56
|
-
|
|
249
|
+
const maiTranscribeModels = /* @__PURE__ */ new Map([["mai-transcribe-2", {
|
|
250
|
+
name: "MAI-Transcribe-2",
|
|
251
|
+
supportsTimestamps: true
|
|
252
|
+
}], ["mai-transcribe-1.5", {
|
|
253
|
+
name: "MAI-Transcribe-1.5",
|
|
254
|
+
supportsTimestamps: false
|
|
255
|
+
}]]);
|
|
256
|
+
function getMAITranscribeModel(modelId) {
|
|
257
|
+
return maiTranscribeModels.get(modelId.toLowerCase());
|
|
57
258
|
}
|
|
58
259
|
//#endregion
|
|
59
260
|
//#region src/azure-speech-transcription-model.ts
|
|
@@ -66,14 +267,15 @@ var AzureSpeechTranscriptionModel = class {
|
|
|
66
267
|
}
|
|
67
268
|
async doGenerate(options, azureOptions = {}) {
|
|
68
269
|
const timestamp = /* @__PURE__ */ new Date();
|
|
270
|
+
const maiModel = getMAITranscribeModel(this.modelId);
|
|
69
271
|
const formData = new FormData();
|
|
70
272
|
formData.append("audio", new Blob([typeof options.audio === "string" ? convertBase64ToUint8Array(options.audio) : options.audio], { type: options.mediaType }), `audio.${mediaTypeToExtension(options.mediaType)}`);
|
|
71
273
|
formData.append("definition", JSON.stringify({
|
|
72
274
|
enhancedMode: {
|
|
73
275
|
enabled: true,
|
|
74
|
-
model:
|
|
276
|
+
model: maiModel?.name ?? this.modelId,
|
|
75
277
|
modelOptions: {
|
|
76
|
-
timestamps: azureOptions.timestamps ?? "segment",
|
|
278
|
+
timestamps: azureOptions.timestamps ?? (maiModel?.supportsTimestamps === false ? void 0 : "segment"),
|
|
77
279
|
transcribeStyle: azureOptions.transcribeStyle
|
|
78
280
|
}
|
|
79
281
|
},
|
|
@@ -136,7 +338,7 @@ const responseSchema = z.object({
|
|
|
136
338
|
});
|
|
137
339
|
//#endregion
|
|
138
340
|
//#region src/version.ts
|
|
139
|
-
const VERSION = "4.0.
|
|
341
|
+
const VERSION = "4.0.89";
|
|
140
342
|
//#endregion
|
|
141
343
|
//#region src/azure-openai-provider.ts
|
|
142
344
|
function getAzureOpenAIBaseURLInfo(baseURL) {
|
|
@@ -252,22 +454,27 @@ function createAzure(options = {}) {
|
|
|
252
454
|
supportsMaskInputs: void 0
|
|
253
455
|
}
|
|
254
456
|
});
|
|
457
|
+
const speechBaseURL = () => withoutTrailingSlash(options.speechBaseURL) ?? `https://${getResourceName()}.cognitiveservices.azure.com`;
|
|
255
458
|
const createTranscriptionModel = (modelId) => new AzureTranscriptionModel(modelId, options, new OpenAITranscriptionModel(modelId, {
|
|
256
459
|
provider: "azure.transcription",
|
|
257
460
|
url,
|
|
258
461
|
headers: getHeaders,
|
|
259
462
|
fetch
|
|
260
463
|
}), new AzureSpeechTranscriptionModel(modelId, {
|
|
261
|
-
url: () => `${
|
|
464
|
+
url: () => `${speechBaseURL()}/speechtotext/transcriptions:transcribe?api-version=2025-10-15`,
|
|
262
465
|
headers: () => getHeaders("speech"),
|
|
263
466
|
fetch
|
|
264
467
|
}));
|
|
265
|
-
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
468
|
+
const createSpeechModel = (modelId) => new AzureSpeechModel(modelId, options, new OpenAISpeechModel(modelId, {
|
|
266
469
|
provider: "azure.speech",
|
|
267
470
|
url,
|
|
268
471
|
headers: getHeaders,
|
|
269
472
|
fetch
|
|
270
|
-
})
|
|
473
|
+
}), new AzureSpeechSpeechModel(modelId, {
|
|
474
|
+
url: () => `${speechBaseURL()}/tts/cognitiveservices/v1`,
|
|
475
|
+
headers: () => getHeaders("speech"),
|
|
476
|
+
fetch
|
|
477
|
+
}));
|
|
271
478
|
const provider = function(deploymentId) {
|
|
272
479
|
if (new.target) throw new Error("The Azure OpenAI model function cannot be called with the new keyword.");
|
|
273
480
|
return createResponsesModel(deploymentId);
|
|
@@ -287,6 +494,7 @@ function createAzure(options = {}) {
|
|
|
287
494
|
provider.transcription = createTranscriptionModel;
|
|
288
495
|
provider.transcriptionModel = createTranscriptionModel;
|
|
289
496
|
provider.speech = createSpeechModel;
|
|
497
|
+
provider.speechModel = createSpeechModel;
|
|
290
498
|
provider.tools = azureOpenaiTools;
|
|
291
499
|
return provider;
|
|
292
500
|
}
|
|
@@ -338,7 +546,43 @@ var AzureTranscriptionModel = class {
|
|
|
338
546
|
});
|
|
339
547
|
return {
|
|
340
548
|
...options,
|
|
341
|
-
api: options?.api ?? (
|
|
549
|
+
api: options?.api ?? (getMAITranscribeModel(this.modelId) ? "speech" : "openai")
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
var AzureSpeechModel = class {
|
|
554
|
+
constructor(modelId, config, openai, speech) {
|
|
555
|
+
this.modelId = modelId;
|
|
556
|
+
this.config = config;
|
|
557
|
+
this.openai = openai;
|
|
558
|
+
this.speech = speech;
|
|
559
|
+
this.specificationVersion = "v4";
|
|
560
|
+
this.provider = "azure.speech";
|
|
561
|
+
}
|
|
562
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
563
|
+
return serializeModelOptions({
|
|
564
|
+
modelId: model.modelId,
|
|
565
|
+
config: model.config
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
569
|
+
return createAzure(options.config).speech(options.modelId);
|
|
570
|
+
}
|
|
571
|
+
async doGenerate(options) {
|
|
572
|
+
const { api, ...speechOptions } = await parseProviderOptions({
|
|
573
|
+
provider: "azure",
|
|
574
|
+
providerOptions: options.providerOptions,
|
|
575
|
+
schema: azureSpeechModelOptions
|
|
576
|
+
}) ?? {};
|
|
577
|
+
if ((api ?? (getMAIVoiceModel(this.modelId) ? "speech" : "openai")) === "speech") return this.speech.doGenerate(options, speechOptions);
|
|
578
|
+
const result = await this.openai.doGenerate(options);
|
|
579
|
+
return {
|
|
580
|
+
...result,
|
|
581
|
+
warnings: [...result.warnings, ...Object.entries(speechOptions).filter(([, value]) => value !== void 0).map(([key]) => ({
|
|
582
|
+
type: "unsupported",
|
|
583
|
+
feature: `providerOptions.azure.${key}`,
|
|
584
|
+
details: "This option requires the Azure Speech API."
|
|
585
|
+
}))]
|
|
342
586
|
};
|
|
343
587
|
}
|
|
344
588
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/azure-openai-tools.ts","../src/azure-speech-transcription-model-options.ts","../src/azure-transcription-model-options.ts","../src/azure-speech-transcription-model.ts","../src/version.ts","../src/azure-openai-provider.ts"],"sourcesContent":["import {\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 {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// Strict objects reject unknown keys (e.g. `diarization.maxSpeakers`, which\n// MAI-Transcribe-2 does not support) instead of silently dropping them.\nexport const azureSpeechTranscriptionModelOptionsShape = () => ({\n /**\n * Timing granularity. Defaults to `segment` so that transcription results\n * include timed segments (Azure's own default is `none`).\n */\n timestamps: z.enum(['word', 'segment', 'none']).optional(),\n\n /**\n * `verbatim` keeps fillers and false starts, `clean` removes them.\n * Azure defaults to `verbatim`.\n */\n transcribeStyle: z.enum(['verbatim', 'clean']).optional(),\n\n /**\n * Forces a single language, e.g. `['en']`. Omit for automatic language\n * detection and code switching.\n */\n locales: z.array(z.string()).length(1).optional(),\n\n /**\n * Speaker diarization. Speaker IDs are available in provider metadata.\n */\n diarization: z.strictObject({ enabled: z.boolean() }).optional(),\n\n /**\n * Keyword biasing for names and domain terminology.\n */\n phraseList: z.strictObject({ phrases: z.array(z.string()) }).optional(),\n});\n\nexport const azureSpeechTranscriptionModelOptions = lazySchema(() =>\n zodSchema(z.strictObject(azureSpeechTranscriptionModelOptionsShape())),\n);\n\nexport type AzureTranscriptionModelSpeechOptions = InferSchema<\n typeof azureSpeechTranscriptionModelOptions\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { 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 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","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAISpeechModel,\n OpenAITranscriptionModel,\n} 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 isValidHostnamePart,\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 (!isValidHostnamePart(resourceName)) {\n throw new InvalidArgumentError({\n argument: 'resourceName',\n message:\n 'Invalid Azure resource name. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',\n });\n }\n\n return resourceName;\n };\n\n const apiVersion = options.apiVersion ?? 'v1';\n const {\n isAzureOpenAI,\n isFoundryProject,\n isVersioned: isAzureOpenAIVersioned,\n } = getAzureOpenAIBaseURLInfo(options.baseURL);\n\n const url = ({ path, modelId }: { path: string; modelId: string }) => {\n const baseUrlPrefix = withoutTrailingSlash(\n options.baseURL ?? `https://${getResourceName()}.openai.azure.com/openai`,\n );\n\n let fullUrl: URL;\n if (options.useDeploymentBasedUrls) {\n // Use deployment-based format for compatibility with certain Azure OpenAI models\n fullUrl = new URL(`${baseUrlPrefix}/deployments/${modelId}${path}`);\n } else if (!isAzureOpenAI || isAzureOpenAIVersioned) {\n // Custom gateways can own Azure routing and versioning themselves.\n // Complete Azure OpenAI v1 URLs also own their versioning.\n fullUrl = new URL(`${baseUrlPrefix}${path}`);\n } else {\n // Use v1 API format - no deployment ID in URL\n fullUrl = new URL(`${baseUrlPrefix}/v1${path}`);\n }\n\n if (\n options.useDeploymentBasedUrls ||\n (isAzureOpenAI && !isAzureOpenAIVersioned && !isFoundryProject)\n ) {\n fullUrl.searchParams.set('api-version', apiVersion);\n }\n\n return fullUrl.toString();\n };\n\n const createChatModel = (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"],"mappings":";;;;;;AAQA,MAAa,mBAMT;CACF;CACA;CACA;CACA;CACA;AACF;;;ACXA,MAAa,mDAAmD;;;;;CAK9D,YAAY,EAAE,KAAK;EAAC;EAAQ;EAAW;CAAM,CAAC,CAAC,CAAC,SAAS;;;;;CAMzD,iBAAiB,EAAE,KAAK,CAAC,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS;;;;;CAMxD,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;;;;CAKhD,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;;;;CAK/D,YAAY,EAAE,aA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C,UAAU;GACV;GACA,QAAQ;EACV,CAAC;EACD,OAAO;GACL,GAAG;GACH,KACE,SAAS,QAAQ,iBAAiB,KAAK,OAAO,IAAI,WAAW;EACjE;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/azure-openai-tools.ts","../src/azure-speech-speech-model-options.ts","../src/azure-speech-model-options.ts","../src/azure-speech-speech-model.ts","../src/azure-speech-transcription-model-options.ts","../src/azure-transcription-model-options.ts","../src/azure-speech-transcription-model.ts","../src/version.ts","../src/azure-openai-provider.ts"],"sourcesContent":["import {\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 {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const azureSpeechSpeechModelOptionsShape = () => ({\n /**\n * Speaking style applied with `mstts:express-as`, e.g. `excited` or\n * `whispering`. Supported styles vary by voice.\n */\n style: z.string().min(1).optional(),\n\n /**\n * Intensity of `style`, from 0.01 to 2. Azure defaults to 1.\n */\n styleDegree: z.number().min(0.01).max(2).optional(),\n});\n\nexport const azureSpeechSpeechModelOptions = lazySchema(() =>\n zodSchema(z.strictObject(azureSpeechSpeechModelOptionsShape())),\n);\n\nexport type AzureSpeechModelSpeechOptions = InferSchema<\n typeof azureSpeechSpeechModelOptions\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { azureSpeechSpeechModelOptionsShape } from './azure-speech-speech-model-options';\n\nexport const azureSpeechModelOptions = lazySchema(() =>\n zodSchema(\n z.strictObject({\n /**\n * API to use. Defaults to Speech for MAI-Voice models, OpenAI otherwise.\n */\n api: z.enum(['openai', 'speech']).optional(),\n ...azureSpeechSpeechModelOptionsShape(),\n }),\n ),\n);\n\nexport type AzureSpeechModelOptions = InferSchema<\n typeof azureSpeechModelOptions\n>;\n\n// Azure voice-name suffixes by lowercase model ID.\nconst maiVoiceModels = new Map([\n ['mai-voice-2-flash', 'MAI-Voice-2-Flash'],\n ['mai-voice-2', 'MAI-Voice-2'],\n]);\n\nexport function getMAIVoiceModel(modelId: string) {\n return maiVoiceModels.get(modelId.toLowerCase());\n}\n","import {\n APICallError,\n type SharedV4Warning,\n type SpeechModelV4,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createBinaryResponseHandler,\n extractResponseHeaders,\n postToApi,\n safeParseJSON,\n type FetchFunction,\n type ResponseHandler,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { getMAIVoiceModel } from './azure-speech-model-options';\nimport type { AzureSpeechModelSpeechOptions } from './azure-speech-speech-model-options';\n\nconst DEFAULT_VOICE = 'en-US-Harper';\n\n// Default voice per ISO 639-1 language; available on MAI-Voice-2 and\n// MAI-Voice-2-Flash.\nconst DEFAULT_VOICES = new Map([\n ['de', 'de-DE-Mia'],\n ['en', DEFAULT_VOICE],\n ['es', 'es-MX-Valeria'],\n ['fr', 'fr-FR-Soleil'],\n ['hi', 'hi-IN-Kavya'],\n ['hu', 'hu-HU-Lilla'],\n ['it', 'it-IT-Rosa'],\n ['ko', 'ko-KR-Haena'],\n ['nl', 'nl-NL-Fleur'],\n ['pt', 'pt-BR-Luana'],\n ['ro', 'ro-RO-Elena'],\n ['ru', 'ru-RU-Masha'],\n ['th', 'th-TH-Krit'],\n ['tr', 'tr-TR-Elif'],\n ['zh', 'zh-CN-Mei'],\n]);\nconst DEFAULT_OUTPUT_FORMAT = 'audio-24khz-160kbitrate-mono-mp3';\n\n// Shorthand formats for `outputFormat`; other X-Microsoft-OutputFormat values\n// (e.g. `audio-48khz-192kbitrate-mono-mp3`) are passed through unchanged.\nconst OUTPUT_FORMATS = new Map([\n ['mp3', DEFAULT_OUTPUT_FORMAT],\n ['opus', 'ogg-24khz-16bit-mono-opus'],\n ['pcm', 'raw-24khz-16bit-mono-pcm'],\n ['wav', 'riff-24khz-16bit-mono-pcm'],\n]);\nconst NATIVE_OUTPUT_FORMAT =\n /^(?:amr|audio|g722|ogg|raw|riff|webm)-[a-z0-9-]+$/;\n\n/**\n * Azure Speech text to speech with SSML. The model is appended to the voice\n * name, e.g. `en-US-Harper:MAI-Voice-2`.\n */\nexport class AzureSpeechSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.speech';\n\n constructor(\n readonly modelId: string,\n private readonly config: {\n url: () => string;\n headers: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n _internal?: { currentDate?: () => Date };\n },\n ) {}\n\n async doGenerate(\n options: Parameters<SpeechModelV4['doGenerate']>[0],\n azureOptions: AzureSpeechModelSpeechOptions = {},\n ): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const warnings: SharedV4Warning[] = [];\n const { style, styleDegree } = azureOptions;\n\n if (options.instructions != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'instructions',\n details: 'Use providerOptions.azure.style to control speaking style.',\n });\n }\n const { voice, languageWarning } = resolveVoice(\n options.voice,\n options.language,\n );\n if (languageWarning != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'language',\n details: languageWarning,\n });\n }\n if (styleDegree != null && style == null) {\n warnings.push({\n type: 'unsupported',\n feature: 'providerOptions.azure.styleDegree',\n details: 'styleDegree requires style.',\n });\n }\n\n let outputFormat = DEFAULT_OUTPUT_FORMAT;\n if (options.outputFormat != null) {\n const format = options.outputFormat.toLowerCase();\n const shorthand = OUTPUT_FORMATS.get(format);\n if (shorthand != null) {\n outputFormat = shorthand;\n } else if (NATIVE_OUTPUT_FORMAT.test(format)) {\n outputFormat = format;\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'outputFormat',\n details: `Unsupported output format: ${options.outputFormat}. Using mp3 instead.`,\n });\n }\n }\n\n const ssml = buildSsml({\n text: options.text,\n voiceName: voice.includes(':')\n ? voice\n : `${voice}:${getMAIVoiceModel(this.modelId) ?? this.modelId}`,\n locale: /^([a-z]{2,3}-[a-z]{2,4})-/i.exec(voice)?.[1],\n speed: options.speed,\n style,\n styleDegree: style != null ? styleDegree : undefined,\n });\n\n const {\n value: audio,\n responseHeaders,\n rawValue,\n } = await postToApi({\n url: this.config.url(),\n headers: combineHeaders(\n this.config.headers(),\n {\n 'Content-Type': 'application/ssml+xml',\n 'X-Microsoft-OutputFormat': outputFormat,\n },\n options.headers,\n ),\n body: { content: ssml, values: ssml },\n failedResponseHandler,\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n audio,\n warnings,\n request: { body: ssml },\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawValue,\n },\n };\n }\n}\n\nfunction buildSsml({\n text,\n voiceName,\n locale = 'en-US',\n speed,\n style,\n styleDegree,\n}: {\n text: string;\n voiceName: string;\n locale?: string;\n speed?: number;\n style?: string;\n styleDegree?: number;\n}) {\n let content = escapeXml(text);\n if (speed != null) {\n content = `<prosody rate=\"${speed}\">${content}</prosody>`;\n }\n if (style != null) {\n const degree = styleDegree != null ? ` styledegree=\"${styleDegree}\"` : '';\n content = `<mstts:express-as style=\"${escapeXml(style)}\"${degree}>${content}</mstts:express-as>`;\n }\n return (\n `<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" ` +\n `xmlns:mstts=\"http://www.w3.org/2001/mstts\" xml:lang=\"${escapeXml(locale)}\">` +\n `<voice name=\"${escapeXml(voiceName)}\">${content}</voice></speak>`\n );\n}\n\nconst XML_ESCAPES: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n};\n\nfunction escapeXml(value: string) {\n return value.replace(/[&<>\"']/g, char => XML_ESCAPES[char]);\n}\n\n// Uses the language's default voice when no voice is set. An explicit voice\n// wins, and its locale selects the language.\nfunction resolveVoice(\n voice: string | undefined,\n language: string | undefined,\n): { voice: string; languageWarning?: string } {\n const code = language ? language.split('-')[0].toLowerCase() : undefined;\n if (voice == null) {\n if (code == null) return { voice: DEFAULT_VOICE };\n if (code === 'auto') {\n return {\n voice: DEFAULT_VOICE,\n languageWarning: `Automatic language detection is not supported. ${DEFAULT_VOICE} was used.`,\n };\n }\n const defaultVoice = DEFAULT_VOICES.get(code);\n return defaultVoice != null\n ? { voice: defaultVoice }\n : {\n voice: DEFAULT_VOICE,\n languageWarning: `No default MAI voice for language \"${language}\". ${DEFAULT_VOICE} was used.`,\n };\n }\n const voiceLanguage = /^([a-z]{2,3})-[a-z]{2,4}-/i\n .exec(voice)?.[1]\n ?.toLowerCase();\n return code != null &&\n code !== 'auto' &&\n voiceLanguage != null &&\n code !== voiceLanguage\n ? {\n voice,\n languageWarning: `The voice ${voice} selects the language. Language \"${language}\" was ignored.`,\n }\n : { voice };\n}\n\nconst errorSchema = z.object({\n error: z.object({ message: z.string() }),\n});\n\n// Azure Speech answers invalid requests (unknown voice, style, or output\n// format) with an empty 400 body.\nconst failedResponseHandler: ResponseHandler<APICallError> = async ({\n response,\n url,\n requestBodyValues,\n}) => {\n const responseHeaders = extractResponseHeaders(response);\n const responseBody = await response.text();\n const parsed = await safeParseJSON({\n text: responseBody,\n schema: errorSchema,\n });\n\n const message = parsed.success\n ? parsed.value.error.message\n : response.status === 400\n ? 'Azure Speech request failed with status 400. Check the voice name, style, and output format.'\n : `Azure Speech request failed with status ${response.status}.`;\n\n return {\n responseHeaders,\n value: new APICallError({\n message,\n url,\n requestBodyValues,\n statusCode: response.status,\n responseHeaders,\n responseBody,\n }),\n };\n};\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// Strict objects reject unknown keys (e.g. `diarization.maxSpeakers`, which\n// MAI-Transcribe-2 does not support) instead of silently dropping them.\nexport const azureSpeechTranscriptionModelOptionsShape = () => ({\n /**\n * Timing granularity. Defaults to `segment` so that transcription results\n * include timed segments (Azure's own default is `none`).\n */\n timestamps: z.enum(['word', 'segment', 'none']).optional(),\n\n /**\n * `verbatim` keeps fillers and false starts, `clean` removes them.\n * Azure defaults to `verbatim`.\n */\n transcribeStyle: z.enum(['verbatim', 'clean']).optional(),\n\n /**\n * Forces a single language, e.g. `['en']`. Omit for automatic language\n * detection and code switching.\n */\n locales: z.array(z.string()).length(1).optional(),\n\n /**\n * Speaker diarization. Speaker IDs are available in provider metadata.\n */\n diarization: z.strictObject({ enabled: z.boolean() }).optional(),\n\n /**\n * Keyword biasing for names and domain terminology.\n */\n phraseList: z.strictObject({ phrases: z.array(z.string()) }).optional(),\n});\n\nexport const azureSpeechTranscriptionModelOptions = lazySchema(() =>\n zodSchema(z.strictObject(azureSpeechTranscriptionModelOptionsShape())),\n);\n\nexport type AzureTranscriptionModelSpeechOptions = InferSchema<\n typeof azureSpeechTranscriptionModelOptions\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { 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 models, 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\n// Azure Speech model names by lowercase model ID. MAI-Transcribe-1.5 only\n// accepts Azure's default timestamps (`none`).\nconst maiTranscribeModels = new Map([\n ['mai-transcribe-2', { name: 'MAI-Transcribe-2', supportsTimestamps: true }],\n [\n 'mai-transcribe-1.5',\n { name: 'MAI-Transcribe-1.5', supportsTimestamps: false },\n ],\n]);\n\nexport function getMAITranscribeModel(modelId: string) {\n return maiTranscribeModels.get(modelId.toLowerCase());\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 { getMAITranscribeModel } from './azure-transcription-model-options';\n\nexport class AzureSpeechTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.transcription';\n\n constructor(\n readonly modelId: string,\n private readonly config: {\n url: () => string;\n headers: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n },\n ) {}\n\n async doGenerate(\n options: Parameters<TranscriptionModelV4['doGenerate']>[0],\n azureOptions: AzureTranscriptionModelSpeechOptions = {},\n ): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {\n const timestamp = new Date();\n const maiModel = getMAITranscribeModel(this.modelId);\n const 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: maiModel?.name ?? this.modelId,\n modelOptions: {\n timestamps:\n azureOptions.timestamps ??\n (maiModel?.supportsTimestamps === false ? undefined : 'segment'),\n transcribeStyle: azureOptions.transcribeStyle,\n },\n },\n locales: azureOptions.locales,\n diarization: azureOptions.diarization,\n phraseList: azureOptions.phraseList,\n }),\n );\n\n const { value, rawValue, responseHeaders } = await postFormDataToApi({\n url: this.config.url(),\n headers: combineHeaders(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","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n OpenAIChatLanguageModel,\n OpenAICompletionLanguageModel,\n OpenAIEmbeddingModel,\n OpenAIImageModel,\n OpenAIResponsesLanguageModel,\n OpenAISpeechModel,\n OpenAITranscriptionModel,\n} 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 SharedV4Warning,\n type SpeechModelV4,\n type TranscriptionModelV4,\n} from '@ai-sdk/provider';\nimport {\n isValidHostnamePart,\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 {\n azureSpeechModelOptions,\n getMAIVoiceModel,\n} from './azure-speech-model-options';\nimport { AzureSpeechSpeechModel } from './azure-speech-speech-model';\nimport { AzureSpeechTranscriptionModel } from './azure-speech-transcription-model';\nimport {\n azureTranscriptionModelOptions,\n getMAITranscribeModel,\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 models use the Speech\n * API 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 speech generation model. MAI-Voice models use the Speech\n * API by default; other IDs use OpenAI. Override with providerOptions.azure.api.\n */\n speech(deploymentId: string): SpeechModelV4;\n\n /**\n * Creates an Azure speech generation model. Alias of `speech`.\n */\n speechModel(deploymentId: string): SpeechModelV4;\n\n /**\n * AzureOpenAI-specific tools.\n */\n tools: typeof azureOpenaiTools;\n}\n\nexport interface AzureOpenAIProviderSettings {\n /**\n * Name of the Azure OpenAI resource. Either this or `baseURL` can be used.\n *\n * The resource name is used in the assembled URL: `https://{resourceName}.openai.azure.com/openai/v1{path}`.\n * It must be a single DNS label (letters, digits, and hyphens).\n */\n resourceName?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers. Either this or `resourceName` can be used.\n * When a baseURL is provided, the resourceName is ignored.\n *\n * With an unversioned Azure OpenAI baseURL, the resolved URL is `{baseURL}/v1{path}`.\n * Azure OpenAI base URLs that already end in `/openai/v1` are used as-is.\n * With a non-Azure custom gateway baseURL, the resolved URL is `{baseURL}{path}`.\n */\n baseURL?: string;\n\n /**\n * API key for authenticating requests.\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 (MAI-Transcribe transcription and MAI-Voice\n * speech), e.g. a regional endpoint like\n * `https://eastus.api.cognitive.microsoft.com`.\n * Defaults to `https://{resourceName}.cognitiveservices.azure.com`.\n * Speech requests do not use `baseURL` or `apiVersion`.\n */\n speechBaseURL?: string;\n}\n\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 (!isValidHostnamePart(resourceName)) {\n throw new InvalidArgumentError({\n argument: 'resourceName',\n message:\n 'Invalid Azure resource name. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',\n });\n }\n\n return resourceName;\n };\n\n const apiVersion = options.apiVersion ?? 'v1';\n const {\n isAzureOpenAI,\n isFoundryProject,\n isVersioned: isAzureOpenAIVersioned,\n } = getAzureOpenAIBaseURLInfo(options.baseURL);\n\n const url = ({ path, modelId }: { path: string; modelId: string }) => {\n const baseUrlPrefix = withoutTrailingSlash(\n options.baseURL ?? `https://${getResourceName()}.openai.azure.com/openai`,\n );\n\n let fullUrl: URL;\n if (options.useDeploymentBasedUrls) {\n // Use deployment-based format for compatibility with certain Azure OpenAI models\n fullUrl = new URL(`${baseUrlPrefix}/deployments/${modelId}${path}`);\n } else if (!isAzureOpenAI || isAzureOpenAIVersioned) {\n // Custom gateways can own Azure routing and versioning themselves.\n // Complete Azure OpenAI v1 URLs also own their versioning.\n fullUrl = new URL(`${baseUrlPrefix}${path}`);\n } else {\n // Use v1 API format - no deployment ID in URL\n fullUrl = new URL(`${baseUrlPrefix}/v1${path}`);\n }\n\n if (\n options.useDeploymentBasedUrls ||\n (isAzureOpenAI && !isAzureOpenAIVersioned && !isFoundryProject)\n ) {\n fullUrl.searchParams.set('api-version', apiVersion);\n }\n\n return fullUrl.toString();\n };\n\n const createChatModel = (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 speechBaseURL = () =>\n withoutTrailingSlash(options.speechBaseURL) ??\n `https://${getResourceName()}.cognitiveservices.azure.com`;\n\n const createTranscriptionModel = (modelId: string) =>\n new AzureTranscriptionModel(\n modelId,\n options,\n new OpenAITranscriptionModel(modelId, {\n provider: 'azure.transcription',\n url,\n headers: getHeaders,\n fetch,\n }),\n new AzureSpeechTranscriptionModel(modelId, {\n url: () =>\n `${speechBaseURL()}/speechtotext/transcriptions:transcribe?api-version=2025-10-15`,\n headers: () => getHeaders('speech'),\n fetch,\n }),\n );\n\n const createSpeechModel = (modelId: string) =>\n new AzureSpeechModel(\n modelId,\n options,\n new OpenAISpeechModel(modelId, {\n provider: 'azure.speech',\n url,\n headers: getHeaders,\n fetch,\n }),\n new AzureSpeechSpeechModel(modelId, {\n url: () => `${speechBaseURL()}/tts/cognitiveservices/v1`,\n headers: () => getHeaders('speech'),\n fetch,\n }),\n );\n\n const provider = function (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.speechModel = createSpeechModel;\n provider.tools = azureOpenaiTools;\n return provider;\n}\n\n/**\n * Default Azure OpenAI provider instance.\n */\nexport const azure = createAzure();\n\n// Resolves the API per request: providerOptions also reach this model via Gateway.\nclass AzureTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.transcription';\n\n constructor(\n readonly modelId: string,\n private readonly config: AzureOpenAIProviderSettings,\n private readonly openai: OpenAITranscriptionModel,\n private readonly speech: AzureSpeechTranscriptionModel,\n ) {}\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 ??\n (getMAITranscribeModel(this.modelId) ? 'speech' : 'openai'),\n };\n }\n}\n\n// Resolves the API per request: providerOptions also reach this model via Gateway.\nclass AzureSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider = 'azure.speech';\n\n constructor(\n readonly modelId: string,\n private readonly config: AzureOpenAIProviderSettings,\n private readonly openai: OpenAISpeechModel,\n private readonly speech: AzureSpeechSpeechModel,\n ) {}\n\n static [WORKFLOW_SERIALIZE](model: AzureSpeechModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: string;\n config: AzureOpenAIProviderSettings;\n }) {\n return createAzure(options.config).speech(options.modelId);\n }\n\n async doGenerate(options: Parameters<SpeechModelV4['doGenerate']>[0]) {\n const { api, ...speechOptions } =\n (await parseProviderOptions({\n provider: 'azure',\n providerOptions: options.providerOptions,\n schema: azureSpeechModelOptions,\n })) ?? {};\n if (\n (api ?? (getMAIVoiceModel(this.modelId) ? 'speech' : 'openai')) ===\n 'speech'\n ) {\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.entries(speechOptions)\n .filter(([, value]) => value !== undefined)\n .map(\n ([key]): SharedV4Warning => ({\n type: 'unsupported',\n feature: `providerOptions.azure.${key}`,\n details: 'This option requires the Azure Speech API.',\n }),\n ),\n ],\n };\n }\n}\n"],"mappings":";;;;;;AAQA,MAAa,mBAMT;CACF;CACA;CACA;CACA;CACA;AACF;;;ACbA,MAAa,4CAA4C;;;;;CAKvD,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;;;;CAKlC,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,GAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;AACpD;AAE6C,iBAC3C,UAAU,EAA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