@ai-sdk/azure 4.0.116 → 4.0.118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # @ai-sdk/azure
2
2
 
3
+ ## 4.0.118
4
+
5
+ ### Patch Changes
6
+
7
+ - c6efa4b: Refactor Azure model ID logic into a model catalog that declares capabilities and provider options, and generate provider capability documentation from it. Export the OpenAI catalog internally for Azure to reuse. Request behavior is unchanged.
8
+ - Updated dependencies [c6efa4b]
9
+ - Updated dependencies [f6dbf04]
10
+ - Updated dependencies [646a7e3]
11
+ - Updated dependencies [6b97088]
12
+ - @ai-sdk/openai@4.0.110
13
+
14
+ ## 4.0.117
15
+
16
+ ### Patch Changes
17
+
18
+ - 27528db: Expose `customTool` through `azure.tools` for Azure Responses models, sharing the OpenAI custom tool factory and its raw string input support.
19
+ - bf10079: Expose `azure.tools.applyPatch` for client-executed file edits through the Azure Responses API.
20
+ - 934100c: Report the actual OpenAI Chat HTTP endpoint (also used by Azure Chat and Bedrock Mantle Chat) through optional request metadata and model-call end events. Record its host and port on OpenTelemetry chat spans without exposing URL credentials, paths, queries, or fragments. Expose only the sanitized HTTP origin in text and object generation results and step/finish callbacks. Providers that do not report an endpoint leave these attributes unset.
21
+ - 5cc6d28: Expose `azure.tools.shell` for local and hosted shell execution through the Azure Responses API.
22
+ - 41465fd: Expose optional transcription word timings separately from segments and accept shared timestampGranularities. Explicit provider timing settings take precedence. OpenAI now sends timestamp_granularities only with verbose_json and warns when a requested timing is unavailable or excluded.
23
+ - Updated dependencies [27528db]
24
+ - Updated dependencies [7139593]
25
+ - Updated dependencies [7bb309d]
26
+ - Updated dependencies [7a90522]
27
+ - Updated dependencies [36802d4]
28
+ - Updated dependencies [6549344]
29
+ - Updated dependencies [5f9bb8e]
30
+ - Updated dependencies [e0143b0]
31
+ - Updated dependencies [934100c]
32
+ - Updated dependencies [892af4d]
33
+ - Updated dependencies [892af4d]
34
+ - Updated dependencies [89aff56]
35
+ - Updated dependencies [243bf22]
36
+ - Updated dependencies [5cc6d28]
37
+ - Updated dependencies [41465fd]
38
+ - Updated dependencies [9754014]
39
+ - Updated dependencies [4bb73b0]
40
+ - Updated dependencies [2e44144]
41
+ - @ai-sdk/openai@4.0.109
42
+ - @ai-sdk/deepseek@3.0.80
43
+ - @ai-sdk/provider@4.0.36
44
+ - @ai-sdk/provider-utils@5.0.75
45
+
3
46
  ## 4.0.116
4
47
 
5
48
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,13 +1,16 @@
1
- import { ResponsesProviderMetadata, ResponsesReasoningProviderMetadata, ResponsesSourceDocumentProviderMetadata, ResponsesTextProviderMetadata, codeInterpreter, fileSearch, imageGeneration, toolSearch, webSearch, webSearchPreview } from "@ai-sdk/openai/internal";
1
+ import { ResponsesProviderMetadata, ResponsesReasoningProviderMetadata, ResponsesSourceDocumentProviderMetadata, ResponsesTextProviderMetadata, applyPatch, codeInterpreter, customTool, fileSearch, imageGeneration, shell, toolSearch, webSearch, webSearchPreview } from "@ai-sdk/openai/internal";
2
2
  import { EmbeddingModelV4, ImageModelV4, LanguageModelV4, ProviderV4, SpeechModelV4, TranscriptionModelV4 } from "@ai-sdk/provider";
3
3
  import { FetchFunction, InferSchema, Resolvable, WebSocketConstructor } from "@ai-sdk/provider-utils";
4
4
  import { DeepSeekLanguageModelChatOptions } from "@ai-sdk/deepseek";
5
5
  import { OpenAILanguageModelChatOptions, OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions, OpenAILanguageModelResponsesOptions, OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions, OpenAIResponsesSystemMessageOptions } from "@ai-sdk/openai";
6
6
  //#region src/azure-openai-tools.d.ts
7
7
  declare const azureOpenaiTools: {
8
+ applyPatch: typeof applyPatch;
8
9
  codeInterpreter: typeof codeInterpreter;
10
+ customTool: typeof customTool;
9
11
  fileSearch: typeof fileSearch;
10
12
  imageGeneration: typeof imageGeneration;
13
+ shell: typeof shell;
11
14
  toolSearch: typeof toolSearch;
12
15
  webSearch: typeof webSearch;
13
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/azure-openai-tools.ts","../src/azure-openai-provider.ts","../src/azure-openai-provider-metadata.ts","../src/version.ts","../src/azure-image-model-options.ts","../src/azure-speech-model-options.ts","../src/azure-transcription-model-options.ts","../src/azure-transcription-provider-metadata.ts","../src/index.ts"],"mappings":";;;;;;cASa;EACX,wBAAwB;EACxB,mBAAmB;EACnB,wBAAwB;EACxB,mBAAmB;EACnB,kBAAkB;;;;EAIlB,yBAAyB;;;;UCuCV;;;;;EAKf;;UAGe,4BAA4B;;;;;GAMzC,sBACA,WAAW,mCACV;;;;;EAMH,cACE,sBACA,WAAW,mCACV;;;;;EAMH,KACE,sBACA,WAAW,mCACV;;;;EAKH,SAAS,uBAAuB;;;;;EAMhC,UACE,sBACA,WAAW,mCACV;;;;;EAMH,WACE,sBACA,WAAW,mCACV;;;;EAKH,UAAU,uBAAuB;;;;EAKjC,eAAe,uBAAuB;;;;EAKtC,cAAc,uBAAuB;;;;EAKrC,mBAAmB,uBAAuB;;;;;EAM1C,MAAM,uBAAuB;;;;EAK7B,WAAW,uBAAuB;;;;;;EAOlC,cAAc,uBAAuB;;;;EAKrC,mBAAmB,uBAAuB;;;;;EAM1C,OAAO,uBAAuB;;;;EAK9B,YAAY,uBAAuB;;;;EAKnC,cAAc;;UAGC;;;;;;;EAOf;;;;;;;;;EAUA;;;;EAKA,SAAS;;;;;;EAOT,uBAAuB;;;;EAKvB,UAAU;;;;;EAMV,QAAQ;;;;;EAMR;;;;;;EAOA;;;;;;;;EASA;;;;;EAMA;;;;;;;EAQA,YAAY;;;;;wBAgCE,YACd,UAAS,8BACR;;;;qBAyRU,OAAK;;;KChjBN;EACV,OAAO;;KAGG;EACV,OAAO;;KAGG;EACV,OAAO;;KAGG;EACV,OAAO;;;;qBClBI;;;cCMA,yDAAsB;;;;;KAYvB,yBAAyB,mBAAmB;;;cCZ3C,0DAAuB;;;;;KAYxB,0BAA0B,mBAC7B;;;cCZI,iEAA8B;;;;;;;;;;;;;KAc/B,iCAAiC,mBACpC;;;KCxBG;EACV;IACE,SAAS;MACP;MACA;MACA;MACA;MACA;MACA;MACA,QAAQ;QACN;QACA;QACA;;;;;;;YCVI,oCAAoC,KAC9C;;YAIU,2BAA2B"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/azure-openai-tools.ts","../src/azure-openai-provider.ts","../src/azure-openai-provider-metadata.ts","../src/version.ts","../src/azure-image-model-options.ts","../src/azure-speech-model-options.ts","../src/azure-transcription-model-options.ts","../src/azure-transcription-provider-metadata.ts","../src/index.ts"],"mappings":";;;;;;cAYa;EACX,mBAAmB;EACnB,wBAAwB;EACxB,mBAAmB;EACnB,mBAAmB;EACnB,wBAAwB;EACxB,cAAc;EACd,mBAAmB;EACnB,kBAAkB;;;;EAIlB,yBAAyB;;;;UCiCV;;;;;EAKf;;UAGe,4BAA4B;;;;;GAMzC,sBACA,WAAW,mCACV;;;;;EAMH,cACE,sBACA,WAAW,mCACV;;;;;EAMH,KACE,sBACA,WAAW,mCACV;;;;EAKH,SAAS,uBAAuB;;;;;EAMhC,UACE,sBACA,WAAW,mCACV;;;;;EAMH,WACE,sBACA,WAAW,mCACV;;;;EAKH,UAAU,uBAAuB;;;;EAKjC,eAAe,uBAAuB;;;;EAKtC,cAAc,uBAAuB;;;;EAKrC,mBAAmB,uBAAuB;;;;;EAM1C,MAAM,uBAAuB;;;;EAK7B,WAAW,uBAAuB;;;;;;EAOlC,cAAc,uBAAuB;;;;EAKrC,mBAAmB,uBAAuB;;;;;EAM1C,OAAO,uBAAuB;;;;EAK9B,YAAY,uBAAuB;;;;EAKnC,cAAc;;UAGC;;;;;;;EAOf;;;;;;;;;EAUA;;;;EAKA,SAAS;;;;;;EAOT,uBAAuB;;;;EAKvB,UAAU;;;;;EAMV,QAAQ;;;;;EAMR;;;;;;EAOA;;;;;;;;EASA;;;;;EAMA;;;;;;;EAQA,YAAY;;;;;wBAgCE,YACd,UAAS,8BACR;;;;qBAyRU,OAAK;;;KChjBN;EACV,OAAO;;KAGG;EACV,OAAO;;KAGG;EACV,OAAO;;KAGG;EACV,OAAO;;;;qBClBI;;;cCOA,yDAAsB;;;;;KAYvB,yBAAyB,mBAAmB;;;cCZ3C,0DAAuB;;;;;KAYxB,0BAA0B,mBAC7B;;;cCZI,iEAA8B;;;;;;;;;;;;;KAc/B,iCAAiC,mBACpC;;;KCzBG;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,8 +1,105 @@
1
- import { OpenAIChatLanguageModel, OpenAICompletionLanguageModel, OpenAIEmbeddingModel, OpenAIImageModel, OpenAIResponsesLanguageModel, OpenAISpeechModel, OpenAITranscriptionModel, codeInterpreter, fileSearch, imageGeneration, toolSearch, webSearch, webSearchPreview } from "@ai-sdk/openai/internal";
1
+ import { OpenAIChatLanguageModel, OpenAICompletionLanguageModel, OpenAIEmbeddingModel, OpenAIImageModel, OpenAIResponsesLanguageModel, OpenAISpeechModel, OpenAITranscriptionModel, applyPatch, codeInterpreter, customTool, fileSearch, imageGeneration, shell, toolSearch, webSearch, webSearchPreview } from "@ai-sdk/openai/internal";
2
2
  import { DeepSeekChatLanguageModel } from "@ai-sdk/deepseek/internal";
3
3
  import { APICallError, InvalidArgumentError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
4
4
  import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertBase64ToUint8Array, convertToBase64, createBinaryResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, downloadBlob, extractResponseHeaders, isValidHostnamePart, lazySchema, loadApiKey, loadSetting, mediaTypeToExtension, normalizeHeaders, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, resolve, resolveWith, safeParseJSON, serializeModelOptions, toWebSocketUrl, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
5
5
  import { z } from "zod/v4";
6
+ //#region src/azure-model-catalog.ts
7
+ function imageEntry(webGrounding) {
8
+ return {
9
+ capabilities: { image: {
10
+ sizes: { description: "Sides must be multiples of 16 and at least 768 pixels." },
11
+ fileInput: true,
12
+ maskInput: false,
13
+ maxImagesPerCall: 1
14
+ } },
15
+ providerOptions: { image: {
16
+ api: true,
17
+ autoAspectRatio: webGrounding,
18
+ webGrounding
19
+ } },
20
+ requestConfig: { image: { api: "mai" } }
21
+ };
22
+ }
23
+ function speechEntry(voiceModel) {
24
+ return {
25
+ capabilities: { speech: { instructions: false } },
26
+ providerOptions: { speech: {
27
+ api: true,
28
+ style: { condition: "Supported styles depend on the selected voice and model." },
29
+ styleDegree: { condition: "Requires a supported speaking style." }
30
+ } },
31
+ requestConfig: { speech: {
32
+ api: "speech",
33
+ voiceModel
34
+ } }
35
+ };
36
+ }
37
+ function transcriptionEntry(name, supportsTimestamps) {
38
+ return {
39
+ capabilities: { transcription: {
40
+ transcription: true,
41
+ streaming: false,
42
+ duration: true,
43
+ segments: supportsTimestamps,
44
+ language: true
45
+ } },
46
+ providerOptions: { transcription: {
47
+ api: true,
48
+ language: { condition: "Requires the MAI streaming API override." },
49
+ timestamps: supportsTimestamps ? true : { condition: "Only none is supported." },
50
+ transcribeStyle: supportsTimestamps ? true : { condition: "Only verbatim is supported." },
51
+ locales: true,
52
+ diarization: supportsTimestamps,
53
+ phraseList: true
54
+ } },
55
+ requestConfig: { transcription: {
56
+ api: "speech",
57
+ name,
58
+ supportsTimestamps
59
+ } }
60
+ };
61
+ }
62
+ /**
63
+ * Azure-owned models. OpenAI and DeepSeek deployments use their adapters' model
64
+ * catalogs; arbitrary deployment names do not declare model-family support.
65
+ */
66
+ const azureModelCatalog = {
67
+ "mai-image-2.5": imageEntry(false),
68
+ "mai-image-2.5-flash": imageEntry(false),
69
+ "mai-image-2.5-pro": imageEntry(false),
70
+ "mai-image-2.6": imageEntry(true),
71
+ "mai-image-2.6-flash": imageEntry(true),
72
+ "mai-voice-2.1-flash": speechEntry("MAI-Voice-2.1-Flash"),
73
+ "mai-voice-2.1": speechEntry("MAI-Voice-2.1"),
74
+ "mai-voice-2-flash": speechEntry("MAI-Voice-2-Flash"),
75
+ "mai-voice-2": speechEntry("MAI-Voice-2"),
76
+ "mai-transcribe-2": transcriptionEntry("MAI-Transcribe-2", true),
77
+ "mai-transcribe-1.5": transcriptionEntry("MAI-Transcribe-1.5", false),
78
+ "mai-transcribe-2-streaming": {
79
+ capabilities: { transcription: {
80
+ transcription: false,
81
+ streaming: true,
82
+ duration: { condition: "Requires an audio format with a known byte rate." },
83
+ segments: false,
84
+ language: { condition: "Reports the configured language hint." }
85
+ } },
86
+ providerOptions: { transcription: {
87
+ api: true,
88
+ language: true,
89
+ timestamps: false,
90
+ transcribeStyle: false,
91
+ locales: false,
92
+ diarization: false,
93
+ phraseList: false
94
+ } },
95
+ requestConfig: { transcription: { api: "mai" } }
96
+ }
97
+ };
98
+ function getAzureModelEntry(modelId) {
99
+ const id = modelId.toLowerCase();
100
+ return Object.prototype.hasOwnProperty.call(azureModelCatalog, id) ? azureModelCatalog[id] : void 0;
101
+ }
102
+ //#endregion
6
103
  //#region src/azure-mai-image-model-options.ts
7
104
  const azureMaiImageModelOptionsShape = () => ({
8
105
  /**
@@ -25,15 +122,8 @@ const azureImageModelOptions = lazySchema(() => zodSchema(z.object({
25
122
  api: z.enum(["openai", "mai"]).optional(),
26
123
  ...azureMaiImageModelOptionsShape()
27
124
  })));
28
- const maiImageModels = /* @__PURE__ */ new Set([
29
- "mai-image-2.5",
30
- "mai-image-2.5-flash",
31
- "mai-image-2.5-pro",
32
- "mai-image-2.6",
33
- "mai-image-2.6-flash"
34
- ]);
35
125
  function isMAIImageModel(modelId) {
36
- return maiImageModels.has(modelId.toLowerCase());
126
+ return getAzureModelEntry(modelId)?.requestConfig?.image?.api === "mai";
37
127
  }
38
128
  //#endregion
39
129
  //#region src/azure-mai-image-model.ts
@@ -427,9 +517,12 @@ function base64ByteLength(base64) {
427
517
  //#endregion
428
518
  //#region src/azure-openai-tools.ts
429
519
  const azureOpenaiTools = {
520
+ applyPatch,
430
521
  codeInterpreter,
522
+ customTool,
431
523
  fileSearch,
432
524
  imageGeneration,
525
+ shell,
433
526
  toolSearch,
434
527
  webSearch,
435
528
  webSearchPreview
@@ -457,14 +550,8 @@ const azureSpeechModelOptions = lazySchema(() => zodSchema(z.strictObject({
457
550
  api: z.enum(["openai", "speech"]).optional(),
458
551
  ...azureSpeechSpeechModelOptionsShape()
459
552
  })));
460
- const maiVoiceModels = /* @__PURE__ */ new Map([
461
- ["mai-voice-2.1-flash", "MAI-Voice-2.1-Flash"],
462
- ["mai-voice-2.1", "MAI-Voice-2.1"],
463
- ["mai-voice-2-flash", "MAI-Voice-2-Flash"],
464
- ["mai-voice-2", "MAI-Voice-2"]
465
- ]);
466
553
  function getMAIVoiceModel(modelId) {
467
- return maiVoiceModels.get(modelId.toLowerCase());
554
+ return getAzureModelEntry(modelId)?.requestConfig?.speech?.voiceModel;
468
555
  }
469
556
  //#endregion
470
557
  //#region src/azure-speech-speech-model.ts
@@ -689,18 +776,15 @@ const azureTranscriptionModelOptions = lazySchema(() => zodSchema(z.strictObject
689
776
  ...azureSpeechTranscriptionModelOptionsShape(),
690
777
  ...azureMaiTranscriptionModelOptionsShape()
691
778
  })));
692
- const maiTranscribeModels = /* @__PURE__ */ new Map([["mai-transcribe-2", {
693
- name: "MAI-Transcribe-2",
694
- supportsTimestamps: true
695
- }], ["mai-transcribe-1.5", {
696
- name: "MAI-Transcribe-1.5",
697
- supportsTimestamps: false
698
- }]]);
699
779
  function getMAITranscribeModel(modelId) {
700
- return maiTranscribeModels.get(modelId.toLowerCase());
780
+ const config = getAzureModelEntry(modelId)?.requestConfig?.transcription;
781
+ return config?.api === "speech" ? {
782
+ name: config.name,
783
+ supportsTimestamps: config.supportsTimestamps
784
+ } : void 0;
701
785
  }
702
786
  function isMAITranscribeStreaming(modelId) {
703
- return modelId.toLowerCase() === "mai-transcribe-2-streaming";
787
+ return getAzureModelEntry(modelId)?.requestConfig?.transcription?.api === "mai";
704
788
  }
705
789
  //#endregion
706
790
  //#region src/azure-speech-transcription-model.ts
@@ -714,6 +798,25 @@ var AzureSpeechTranscriptionModel = class {
714
798
  async doGenerate(options, azureOptions = {}) {
715
799
  const timestamp = /* @__PURE__ */ new Date();
716
800
  const maiModel = getMAITranscribeModel(this.modelId);
801
+ const warnings = [];
802
+ let timestamps = azureOptions.timestamps;
803
+ if (options.timestampGranularities != null) {
804
+ const wantsWord = options.timestampGranularities.includes("word");
805
+ const wantsSegment = options.timestampGranularities.includes("segment");
806
+ if (maiModel?.supportsTimestamps === false && (wantsWord || wantsSegment)) warnings.push({
807
+ type: "unsupported",
808
+ feature: "timestampGranularities",
809
+ details: `${maiModel.name} cannot return word or segment timings.`
810
+ });
811
+ else if (timestamps == null) {
812
+ if (wantsWord) timestamps = "word";
813
+ else if (wantsSegment) timestamps = "segment";
814
+ } else if (wantsWord && timestamps !== "word" || wantsSegment && timestamps === "none") warnings.push({
815
+ type: "unsupported",
816
+ feature: "timestampGranularities",
817
+ details: `providerOptions.azure.timestamps is "${timestamps}" and overrides the requested timestamp granularities.`
818
+ });
819
+ }
717
820
  const formData = new FormData();
718
821
  formData.append("audio", new Blob([typeof options.audio === "string" ? convertBase64ToUint8Array(options.audio) : options.audio], { type: options.mediaType }), `audio.${mediaTypeToExtension(options.mediaType)}`);
719
822
  formData.append("definition", JSON.stringify({
@@ -721,7 +824,7 @@ var AzureSpeechTranscriptionModel = class {
721
824
  enabled: true,
722
825
  model: maiModel?.name ?? this.modelId,
723
826
  modelOptions: {
724
- timestamps: azureOptions.timestamps ?? (maiModel?.supportsTimestamps === false ? void 0 : "segment"),
827
+ timestamps: timestamps ?? (maiModel?.supportsTimestamps === false ? void 0 : "segment"),
725
828
  transcribeStyle: azureOptions.transcribeStyle
726
829
  }
727
830
  },
@@ -745,8 +848,14 @@ var AzureSpeechTranscriptionModel = class {
745
848
  const languages = new Set(phrases.flatMap((phrase) => phrase.locale ? [phrase.locale.split("-")[0].toLowerCase()] : []));
746
849
  const [language] = languages;
747
850
  const reportedLanguage = languages.size === 1 && /^[a-z]{2}$/.test(language) ? language : void 0;
851
+ const words = phrases.flatMap((phrase) => (phrase.words ?? []).flatMap((word) => word.offsetMilliseconds != null && word.durationMilliseconds != null ? [{
852
+ text: word.text,
853
+ startSecond: word.offsetMilliseconds / 1e3,
854
+ endSecond: (word.offsetMilliseconds + word.durationMilliseconds) / 1e3
855
+ }] : []));
748
856
  return {
749
857
  text: value.combinedPhrases.map((phrase) => phrase.text).join(" "),
858
+ ...words.length > 0 ? { words } : {},
750
859
  segments: phrases.flatMap((phrase) => phrase.offsetMilliseconds != null && phrase.durationMilliseconds != null ? [{
751
860
  text: phrase.text,
752
861
  startSecond: phrase.offsetMilliseconds / 1e3,
@@ -754,7 +863,7 @@ var AzureSpeechTranscriptionModel = class {
754
863
  }] : []),
755
864
  language: reportedLanguage,
756
865
  durationInSeconds: value.durationMilliseconds != null ? value.durationMilliseconds / 1e3 : void 0,
757
- warnings: [],
866
+ warnings,
758
867
  providerMetadata: { azure: { phrases } },
759
868
  response: {
760
869
  timestamp,
@@ -784,7 +893,7 @@ const responseSchema = lazySchema(() => zodSchema(z.object({
784
893
  })));
785
894
  //#endregion
786
895
  //#region src/version.ts
787
- const VERSION = "4.0.116";
896
+ const VERSION = "4.0.118";
788
897
  //#endregion
789
898
  //#region src/azure-openai-provider.ts
790
899
  function getAzureOpenAIBaseURLInfo(baseURL) {