@openrouter/ai-sdk-provider 1.4.1 → 1.5.0

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/dist/index.mjs CHANGED
@@ -1036,6 +1036,19 @@ function mapOpenRouterFinishReason(finishReason) {
1036
1036
  }
1037
1037
  }
1038
1038
 
1039
+ // src/types/openrouter-chat-completions-input.ts
1040
+ var OPENROUTER_AUDIO_FORMATS = [
1041
+ "wav",
1042
+ "mp3",
1043
+ "aiff",
1044
+ "aac",
1045
+ "ogg",
1046
+ "flac",
1047
+ "m4a",
1048
+ "pcm16",
1049
+ "pcm24"
1050
+ ];
1051
+
1039
1052
  // src/chat/is-url.ts
1040
1053
  function isUrl({
1041
1054
  url,
@@ -1077,6 +1090,34 @@ function getBase64FromDataUrl(dataUrl) {
1077
1090
  const match = dataUrl.match(/^data:[^;]*;base64,(.+)$/);
1078
1091
  return match ? match[1] : dataUrl;
1079
1092
  }
1093
+ var MIME_TO_FORMAT = {
1094
+ // MP3 variants
1095
+ mpeg: "mp3",
1096
+ mp3: "mp3",
1097
+ // WAV variants
1098
+ "x-wav": "wav",
1099
+ wave: "wav",
1100
+ wav: "wav",
1101
+ // OGG variants
1102
+ ogg: "ogg",
1103
+ vorbis: "ogg",
1104
+ // AAC variants
1105
+ aac: "aac",
1106
+ "x-aac": "aac",
1107
+ // M4A variants
1108
+ m4a: "m4a",
1109
+ "x-m4a": "m4a",
1110
+ mp4: "m4a",
1111
+ // AIFF variants
1112
+ aiff: "aiff",
1113
+ "x-aiff": "aiff",
1114
+ // FLAC
1115
+ flac: "flac",
1116
+ "x-flac": "flac",
1117
+ // PCM variants
1118
+ pcm16: "pcm16",
1119
+ pcm24: "pcm24"
1120
+ };
1080
1121
  function getInputAudioData(part) {
1081
1122
  const fileData = getFileUrl({
1082
1123
  part,
@@ -1101,19 +1142,14 @@ Learn more: https://openrouter.ai/docs/features/multimodal/audio`
1101
1142
  }
1102
1143
  const data = getBase64FromDataUrl(fileData);
1103
1144
  const mediaType = part.mediaType || "audio/mpeg";
1104
- let format = mediaType.replace("audio/", "");
1105
- if (format === "mpeg" || format === "mp3") {
1106
- format = "mp3";
1107
- } else if (format === "x-wav" || format === "wave" || format === "wav") {
1108
- format = "wav";
1109
- }
1110
- if (format !== "mp3" && format !== "wav") {
1145
+ const rawFormat = mediaType.replace("audio/", "");
1146
+ const format = MIME_TO_FORMAT[rawFormat];
1147
+ if (format === void 0) {
1148
+ const supportedList = OPENROUTER_AUDIO_FORMATS.join(", ");
1111
1149
  throw new Error(
1112
1150
  `Unsupported audio format: "${mediaType}"
1113
1151
 
1114
- OpenRouter only supports MP3 and WAV audio formats.
1115
- \u2022 For MP3: use "audio/mpeg" or "audio/mp3"
1116
- \u2022 For WAV: use "audio/wav" or "audio/x-wav"
1152
+ OpenRouter supports the following audio formats: ${supportedList}
1117
1153
 
1118
1154
  Learn more: https://openrouter.ai/docs/features/multimodal/audio`
1119
1155
  );
@@ -2784,7 +2820,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
2784
2820
  }
2785
2821
 
2786
2822
  // src/version.ts
2787
- var VERSION = false ? "0.0.0-test" : "1.4.1";
2823
+ var VERSION = false ? "0.0.0-test" : "1.5.0";
2788
2824
 
2789
2825
  // src/provider.ts
2790
2826
  function createOpenRouter(options = {}) {
@@ -2852,9 +2888,30 @@ var openrouter = createOpenRouter({
2852
2888
  compatibility: "strict"
2853
2889
  // strict for OpenRouter API
2854
2890
  });
2891
+
2892
+ // src/toon/index.ts
2893
+ async function getToonModule() {
2894
+ try {
2895
+ return await import("@toon-format/toon");
2896
+ } catch (e) {
2897
+ throw new Error(
2898
+ "The @toon-format/toon package is required for TOON encoding/decoding. Install it with: npm install @toon-format/toon"
2899
+ );
2900
+ }
2901
+ }
2902
+ async function encodeToon(value, options) {
2903
+ const toon = await getToonModule();
2904
+ return toon.encode(value, options);
2905
+ }
2906
+ async function decodeToon(input, options) {
2907
+ const toon = await getToonModule();
2908
+ return toon.decode(input, options);
2909
+ }
2855
2910
  export {
2856
2911
  OpenRouter,
2857
2912
  createOpenRouter,
2913
+ decodeToon,
2914
+ encodeToon,
2858
2915
  openrouter
2859
2916
  };
2860
2917
  //# sourceMappingURL=index.mjs.map