sarvam-ai-sdk 0.0.4 → 0.0.5

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/README.md CHANGED
@@ -69,6 +69,25 @@ const { text } = await transcribe({
69
69
  console.log(text); // പാചകം തുടരും സുഹൃത്തുക്കളെ
70
70
  ```
71
71
 
72
+ ## Translation
73
+
74
+ > Only transliterates `prompt` and `role:user` messages, not `system` not `assistant`.
75
+
76
+ ```ts
77
+ import { sarvam } from "sarvam-ai-sdk";
78
+ import { generateText } from "ai";
79
+
80
+ const result = await generateText({
81
+ model: sarvam.translation({
82
+ "to": "en-IN",
83
+ "from": "ml-IN"
84
+ }),
85
+ prompt: "ഇതൊക്കെ ശ്രദ്ധിക്കണ്ടേ അംബാനെ?",
86
+ });
87
+
88
+ console.log(result.text); // Shouldn't we be careful about this, Ambane?
89
+ ```
90
+
72
91
  ## Transliterate
73
92
 
74
93
  > Only transliterates `prompt` and `role:user` messages, not `system` not `assistant`.
package/dist/index.cjs CHANGED
@@ -55,7 +55,7 @@ __export(index_exports, {
55
55
  module.exports = __toCommonJS(index_exports);
56
56
 
57
57
  // src/sarvam-provider.ts
58
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
58
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
59
59
 
60
60
  // src/sarvam-chat-language-model.ts
61
61
  var import_provider3 = require("@ai-sdk/provider");
@@ -758,140 +758,12 @@ var sarvamChatChunkSchema = import_zod2.z.union([
758
758
  sarvamErrorDataSchema
759
759
  ]);
760
760
 
761
- // src/sarvam-transcription-model.ts
762
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
763
- var import_zod4 = require("zod");
764
-
765
- // src/sarvam-transcription-settings.ts
766
- var import_zod3 = require("zod");
767
- var SarvamProviderOptionsSchema = import_zod3.z.object({
768
- with_timestamps: import_zod3.z.boolean().nullish().default(false),
769
- with_diarization: import_zod3.z.boolean().nullish().default(false),
770
- num_speakers: import_zod3.z.number().int().nullish()
771
- });
772
-
773
- // src/sarvam-transcription-model.ts
774
- var SarvamTranscriptionModel = class {
775
- constructor(modelId, languageCode, config) {
776
- this.modelId = modelId;
777
- this.languageCode = languageCode;
778
- this.config = config;
779
- this.specificationVersion = "v1";
780
- }
781
- get provider() {
782
- return this.config.provider;
783
- }
784
- getArgs({
785
- audio,
786
- mediaType,
787
- providerOptions
788
- }) {
789
- const warnings = [];
790
- if (this.modelId === "saarika:v1" && this.languageCode === "unknown")
791
- throw new Error(
792
- "Language code unknown is not supported for model saarika:v1"
793
- );
794
- const sarvamOptions = (0, import_provider_utils5.parseProviderOptions)({
795
- provider: "sarvam",
796
- providerOptions: {
797
- sarvam: __spreadValues(__spreadValues({}, providerOptions == null ? void 0 : providerOptions.sarvam), this.config.transcription)
798
- },
799
- schema: SarvamProviderOptionsSchema
800
- });
801
- const formData = new FormData();
802
- const blob = audio instanceof Blob ? audio : new Blob([audio], { type: mediaType });
803
- formData.append("file", blob);
804
- formData.append("model", this.modelId);
805
- if (sarvamOptions) {
806
- formData.append("language_code", this.languageCode);
807
- formData.append(
808
- "with_timestamps",
809
- sarvamOptions.with_timestamps ? "true" : "false"
810
- );
811
- formData.append(
812
- "with_diarization",
813
- sarvamOptions.with_diarization ? "true" : "false"
814
- );
815
- if (sarvamOptions.num_speakers !== null && sarvamOptions.num_speakers !== void 0) {
816
- formData.append(
817
- "num_speakers",
818
- sarvamOptions.num_speakers.toString()
819
- );
820
- }
821
- }
822
- return {
823
- formData,
824
- warnings
825
- };
826
- }
827
- async doGenerate(options) {
828
- var _a, _b, _c, _d, _e;
829
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
830
- const { formData, warnings } = this.getArgs(options);
831
- const {
832
- value: response,
833
- responseHeaders,
834
- rawValue: rawResponse
835
- } = await (0, import_provider_utils5.postFormDataToApi)({
836
- url: this.config.url({
837
- path: "/speech-to-text",
838
- modelId: this.modelId
839
- }),
840
- headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
841
- formData,
842
- failedResponseHandler: sarvamFailedResponseHandler,
843
- successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
844
- sarvamTranscriptionResponseSchema
845
- ),
846
- abortSignal: options.abortSignal,
847
- fetch: this.config.fetch
848
- });
849
- return {
850
- text: response.transcript,
851
- segments: response.timestamps ? response.timestamps.words.map((word, index) => ({
852
- text: word,
853
- startSecond: response.timestamps.start_time_seconds[index],
854
- endSecond: response.timestamps.end_time_seconds[index]
855
- })) : [],
856
- language: response.language_code ? response.language_code : void 0,
857
- durationInSeconds: (_e = (_d = response.timestamps) == null ? void 0 : _d.end_time_seconds[response.timestamps.end_time_seconds.length - 1]) != null ? _e : void 0,
858
- warnings,
859
- response: {
860
- timestamp: currentDate,
861
- modelId: this.modelId,
862
- headers: responseHeaders,
863
- body: rawResponse
864
- }
865
- };
866
- }
867
- };
868
- var sarvamTranscriptionResponseSchema = import_zod4.z.object({
869
- request_id: import_zod4.z.string().nullable(),
870
- transcript: import_zod4.z.string(),
871
- language_code: import_zod4.z.string().nullable(),
872
- timestamps: import_zod4.z.object({
873
- end_time_seconds: import_zod4.z.array(import_zod4.z.number()),
874
- start_time_seconds: import_zod4.z.array(import_zod4.z.number()),
875
- words: import_zod4.z.array(import_zod4.z.string())
876
- }).optional(),
877
- diarized_transcript: import_zod4.z.object({
878
- entries: import_zod4.z.array(
879
- import_zod4.z.object({
880
- end_time_seconds: import_zod4.z.array(import_zod4.z.number()),
881
- start_time_seconds: import_zod4.z.array(import_zod4.z.number()),
882
- transcript: import_zod4.z.string(),
883
- speaker_id: import_zod4.z.string()
884
- })
885
- )
886
- }).optional()
887
- });
888
-
889
761
  // src/sarvam-speech-model.ts
890
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
762
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
891
763
 
892
764
  // src/sarvam-speech-settings.ts
893
- var import_zod5 = require("zod");
894
- var SpeakerSchema = import_zod5.z.enum([
765
+ var import_zod3 = require("zod");
766
+ var SpeakerSchema = import_zod3.z.enum([
895
767
  "meera",
896
768
  "pavithra",
897
769
  "maitreyi",
@@ -912,22 +784,22 @@ var SpeakerSchema = import_zod5.z.enum([
912
784
  "karun",
913
785
  "hitesh"
914
786
  ]).default("meera");
915
- var SarvamProviderOptionsSchema2 = import_zod5.z.object({
787
+ var SarvamProviderOptionsSchema = import_zod3.z.object({
916
788
  speaker: SpeakerSchema,
917
- pitch: import_zod5.z.number().min(-0.75).max(0.75).default(0),
918
- pace: import_zod5.z.number().min(0.5).max(2).default(1),
919
- loudness: import_zod5.z.number().min(0.3).max(3).default(1),
920
- speech_sample_rate: import_zod5.z.union([
921
- import_zod5.z.literal(8e3),
922
- import_zod5.z.literal(16e3),
923
- import_zod5.z.literal(22050),
924
- import_zod5.z.literal(24e3)
789
+ pitch: import_zod3.z.number().min(-0.75).max(0.75).default(0),
790
+ pace: import_zod3.z.number().min(0.5).max(2).default(1),
791
+ loudness: import_zod3.z.number().min(0.3).max(3).default(1),
792
+ speech_sample_rate: import_zod3.z.union([
793
+ import_zod3.z.literal(8e3),
794
+ import_zod3.z.literal(16e3),
795
+ import_zod3.z.literal(22050),
796
+ import_zod3.z.literal(24e3)
925
797
  ]).default(22050),
926
- enable_preprocessing: import_zod5.z.boolean().default(false)
798
+ enable_preprocessing: import_zod3.z.boolean().default(false)
927
799
  }).partial();
928
800
 
929
801
  // src/sarvam-speech-model.ts
930
- var import_zod6 = require("zod");
802
+ var import_zod4 = require("zod");
931
803
  var SarvamSpeechModel = class {
932
804
  constructor(modelId, languageCode, config) {
933
805
  this.modelId = modelId;
@@ -947,12 +819,12 @@ var SarvamSpeechModel = class {
947
819
  providerOptions
948
820
  }) {
949
821
  const warnings = [];
950
- const sarvamOptions = (0, import_provider_utils6.parseProviderOptions)({
822
+ const sarvamOptions = (0, import_provider_utils5.parseProviderOptions)({
951
823
  provider: "sarvam",
952
824
  providerOptions: {
953
825
  sarvam: __spreadValues(__spreadValues({}, providerOptions == null ? void 0 : providerOptions.sarvam), this.config.speech)
954
826
  },
955
- schema: SarvamProviderOptionsSchema2
827
+ schema: SarvamProviderOptionsSchema
956
828
  });
957
829
  const getSpeaker = () => {
958
830
  if (sarvamOptions == null ? void 0 : sarvamOptions.speaker) return sarvamOptions.speaker;
@@ -1011,18 +883,18 @@ var SarvamSpeechModel = class {
1011
883
  value,
1012
884
  responseHeaders,
1013
885
  rawValue: rawResponse
1014
- } = await (0, import_provider_utils6.postJsonToApi)({
886
+ } = await (0, import_provider_utils5.postJsonToApi)({
1015
887
  url: this.config.url({
1016
888
  path: "/text-to-speech",
1017
889
  modelId: this.modelId
1018
890
  }),
1019
- headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), options.headers),
891
+ headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
1020
892
  body: requestBody,
1021
893
  failedResponseHandler: sarvamFailedResponseHandler,
1022
- successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
1023
- import_zod6.z.object({
1024
- request_id: import_zod6.z.string(),
1025
- audios: import_zod6.z.array(import_zod6.z.string())
894
+ successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
895
+ import_zod4.z.object({
896
+ request_id: import_zod4.z.string(),
897
+ audios: import_zod4.z.array(import_zod4.z.string())
1026
898
  })
1027
899
  ),
1028
900
  abortSignal: options.abortSignal,
@@ -1045,7 +917,135 @@ var SarvamSpeechModel = class {
1045
917
  }
1046
918
  };
1047
919
 
1048
- // src/sarvam-transliterate-model.ts
920
+ // src/sarvam-transcription-model.ts
921
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
922
+ var import_zod6 = require("zod");
923
+
924
+ // src/sarvam-transcription-settings.ts
925
+ var import_zod5 = require("zod");
926
+ var SarvamProviderOptionsSchema2 = import_zod5.z.object({
927
+ with_timestamps: import_zod5.z.boolean().nullish().default(false),
928
+ with_diarization: import_zod5.z.boolean().nullish().default(false),
929
+ num_speakers: import_zod5.z.number().int().nullish()
930
+ });
931
+
932
+ // src/sarvam-transcription-model.ts
933
+ var SarvamTranscriptionModel = class {
934
+ constructor(modelId, languageCode, config) {
935
+ this.modelId = modelId;
936
+ this.languageCode = languageCode;
937
+ this.config = config;
938
+ this.specificationVersion = "v1";
939
+ }
940
+ get provider() {
941
+ return this.config.provider;
942
+ }
943
+ getArgs({
944
+ audio,
945
+ mediaType,
946
+ providerOptions
947
+ }) {
948
+ const warnings = [];
949
+ if (this.modelId === "saarika:v1" && this.languageCode === "unknown")
950
+ throw new Error(
951
+ "Language code unknown is not supported for model saarika:v1"
952
+ );
953
+ const sarvamOptions = (0, import_provider_utils6.parseProviderOptions)({
954
+ provider: "sarvam",
955
+ providerOptions: {
956
+ sarvam: __spreadValues(__spreadValues({}, providerOptions == null ? void 0 : providerOptions.sarvam), this.config.transcription)
957
+ },
958
+ schema: SarvamProviderOptionsSchema2
959
+ });
960
+ const formData = new FormData();
961
+ const blob = audio instanceof Blob ? audio : new Blob([audio], { type: mediaType });
962
+ formData.append("file", blob);
963
+ formData.append("model", this.modelId);
964
+ if (sarvamOptions) {
965
+ formData.append("language_code", this.languageCode);
966
+ formData.append(
967
+ "with_timestamps",
968
+ sarvamOptions.with_timestamps ? "true" : "false"
969
+ );
970
+ formData.append(
971
+ "with_diarization",
972
+ sarvamOptions.with_diarization ? "true" : "false"
973
+ );
974
+ if (sarvamOptions.num_speakers !== null && sarvamOptions.num_speakers !== void 0) {
975
+ formData.append(
976
+ "num_speakers",
977
+ sarvamOptions.num_speakers.toString()
978
+ );
979
+ }
980
+ }
981
+ return {
982
+ formData,
983
+ warnings
984
+ };
985
+ }
986
+ async doGenerate(options) {
987
+ var _a, _b, _c, _d, _e;
988
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
989
+ const { formData, warnings } = this.getArgs(options);
990
+ const {
991
+ value: response,
992
+ responseHeaders,
993
+ rawValue: rawResponse
994
+ } = await (0, import_provider_utils6.postFormDataToApi)({
995
+ url: this.config.url({
996
+ path: "/speech-to-text",
997
+ modelId: this.modelId
998
+ }),
999
+ headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), options.headers),
1000
+ formData,
1001
+ failedResponseHandler: sarvamFailedResponseHandler,
1002
+ successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
1003
+ sarvamTranscriptionResponseSchema
1004
+ ),
1005
+ abortSignal: options.abortSignal,
1006
+ fetch: this.config.fetch
1007
+ });
1008
+ return {
1009
+ text: response.transcript,
1010
+ segments: response.timestamps ? response.timestamps.words.map((word, index) => ({
1011
+ text: word,
1012
+ startSecond: response.timestamps.start_time_seconds[index],
1013
+ endSecond: response.timestamps.end_time_seconds[index]
1014
+ })) : [],
1015
+ language: response.language_code ? response.language_code : void 0,
1016
+ durationInSeconds: (_e = (_d = response.timestamps) == null ? void 0 : _d.end_time_seconds[response.timestamps.end_time_seconds.length - 1]) != null ? _e : void 0,
1017
+ warnings,
1018
+ response: {
1019
+ timestamp: currentDate,
1020
+ modelId: this.modelId,
1021
+ headers: responseHeaders,
1022
+ body: rawResponse
1023
+ }
1024
+ };
1025
+ }
1026
+ };
1027
+ var sarvamTranscriptionResponseSchema = import_zod6.z.object({
1028
+ request_id: import_zod6.z.string().nullable(),
1029
+ transcript: import_zod6.z.string(),
1030
+ language_code: import_zod6.z.string().nullable(),
1031
+ timestamps: import_zod6.z.object({
1032
+ end_time_seconds: import_zod6.z.array(import_zod6.z.number()),
1033
+ start_time_seconds: import_zod6.z.array(import_zod6.z.number()),
1034
+ words: import_zod6.z.array(import_zod6.z.string())
1035
+ }).optional(),
1036
+ diarized_transcript: import_zod6.z.object({
1037
+ entries: import_zod6.z.array(
1038
+ import_zod6.z.object({
1039
+ end_time_seconds: import_zod6.z.array(import_zod6.z.number()),
1040
+ start_time_seconds: import_zod6.z.array(import_zod6.z.number()),
1041
+ transcript: import_zod6.z.string(),
1042
+ speaker_id: import_zod6.z.string()
1043
+ })
1044
+ )
1045
+ }).optional()
1046
+ });
1047
+
1048
+ // src/sarvam-translation-model.ts
1049
1049
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1050
1050
  var import_zod8 = require("zod");
1051
1051
 
@@ -1065,7 +1065,110 @@ var SarvamLanguageCodeSchema = import_zod7.z.enum([
1065
1065
  "gu-IN"
1066
1066
  ]);
1067
1067
 
1068
+ // src/sarvam-translation-model.ts
1069
+ var SarvamTranslationModel = class {
1070
+ constructor(settings, config) {
1071
+ this.specificationVersion = "v1";
1072
+ this.supportsStructuredOutputs = false;
1073
+ this.defaultObjectGenerationMode = "json";
1074
+ this.modelId = "unknown";
1075
+ this.settings = settings;
1076
+ this.config = config;
1077
+ }
1078
+ get provider() {
1079
+ return this.config.provider;
1080
+ }
1081
+ get supportsImageUrls() {
1082
+ return false;
1083
+ }
1084
+ getArgs({
1085
+ mode,
1086
+ prompt
1087
+ }) {
1088
+ var _a, _b, _c, _d, _e, _f;
1089
+ const type = mode.type;
1090
+ const warnings = [];
1091
+ if (this.settings.from !== "auto") {
1092
+ if (this.settings.to !== "en-IN" && this.settings.from !== "en-IN")
1093
+ throw new Error(
1094
+ "Sarvam doesn't support Indic-Indic Transliteration yet"
1095
+ );
1096
+ }
1097
+ if (type !== "regular") {
1098
+ const _exhaustiveCheck = type;
1099
+ throw new Error(`Unsupported type: ${_exhaustiveCheck}`);
1100
+ }
1101
+ const messages = convertToSarvamChatMessages(prompt);
1102
+ return {
1103
+ messages,
1104
+ args: {
1105
+ input: messages.filter((m) => m.role === "user").map((m) => m.content).join("\n"),
1106
+ source_language_code: (_a = this.settings.from) != null ? _a : "auto",
1107
+ target_language_code: this.settings.to,
1108
+ numerals_format: (_b = this.settings.numerals_format) != null ? _b : "international",
1109
+ enable_preprocessing: (_c = this.settings.enable_preprocessing) != null ? _c : false,
1110
+ output_script: (_d = this.settings.output_script) != null ? _d : null,
1111
+ speaker_gender: (_e = this.settings.speaker_gender) != null ? _e : "Male",
1112
+ mode: (_f = this.settings.mode) != null ? _f : "formal"
1113
+ // model: this.settings.model ?? "male",
1114
+ },
1115
+ warnings
1116
+ };
1117
+ }
1118
+ async doGenerate(options) {
1119
+ var _b;
1120
+ const { args, warnings, messages } = this.getArgs(__spreadProps(__spreadValues({}, options), {
1121
+ stream: false
1122
+ }));
1123
+ const body = JSON.stringify(args);
1124
+ const {
1125
+ responseHeaders,
1126
+ value: response,
1127
+ rawValue: rawResponse
1128
+ } = await (0, import_provider_utils7.postJsonToApi)({
1129
+ url: this.config.url({
1130
+ path: "/translate"
1131
+ }),
1132
+ headers: (0, import_provider_utils7.combineHeaders)(this.config.headers(), options.headers),
1133
+ body: args,
1134
+ failedResponseHandler: sarvamFailedResponseHandler,
1135
+ successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1136
+ sarvamTranslationResponseSchema
1137
+ ),
1138
+ abortSignal: options.abortSignal,
1139
+ fetch: this.config.fetch
1140
+ });
1141
+ const _a = args, { input: rawPrompt } = _a, rawSettings = __objRest(_a, ["input"]);
1142
+ const text = (_b = response.translated_text) != null ? _b : void 0;
1143
+ return {
1144
+ text,
1145
+ toolCalls: void 0,
1146
+ reasoning: void 0,
1147
+ finishReason: "unknown",
1148
+ usage: {
1149
+ promptTokens: NaN,
1150
+ completionTokens: NaN
1151
+ },
1152
+ rawCall: { rawPrompt, rawSettings },
1153
+ rawResponse: { headers: responseHeaders, body: rawResponse },
1154
+ response: void 0,
1155
+ warnings,
1156
+ request: { body }
1157
+ };
1158
+ }
1159
+ async doStream(options) {
1160
+ throw new Error("Translation feature doesn't streaming yet");
1161
+ }
1162
+ };
1163
+ var sarvamTranslationResponseSchema = import_zod8.z.object({
1164
+ translated_text: import_zod8.z.string().nullish(),
1165
+ source_language_code: SarvamLanguageCodeSchema.nullable(),
1166
+ request_id: import_zod8.z.string().nullish()
1167
+ });
1168
+
1068
1169
  // src/sarvam-transliterate-model.ts
1170
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1171
+ var import_zod9 = require("zod");
1069
1172
  var SarvamTransliterateModel = class {
1070
1173
  constructor(settings, config) {
1071
1174
  this.specificationVersion = "v1";
@@ -1123,14 +1226,14 @@ var SarvamTransliterateModel = class {
1123
1226
  responseHeaders,
1124
1227
  value: response,
1125
1228
  rawValue: rawResponse
1126
- } = await (0, import_provider_utils7.postJsonToApi)({
1229
+ } = await (0, import_provider_utils8.postJsonToApi)({
1127
1230
  url: this.config.url({
1128
1231
  path: "/transliterate"
1129
1232
  }),
1130
- headers: (0, import_provider_utils7.combineHeaders)(this.config.headers(), options.headers),
1233
+ headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
1131
1234
  body: args,
1132
1235
  failedResponseHandler: sarvamFailedResponseHandler,
1133
- successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1236
+ successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
1134
1237
  sarvamTransliterateResponseSchema
1135
1238
  ),
1136
1239
  abortSignal: options.abortSignal,
@@ -1158,17 +1261,17 @@ var SarvamTransliterateModel = class {
1158
1261
  throw new Error("Transliterate feature doesn't streaming yet");
1159
1262
  }
1160
1263
  };
1161
- var sarvamTransliterateResponseSchema = import_zod8.z.object({
1162
- transliterated_text: import_zod8.z.string().nullish(),
1264
+ var sarvamTransliterateResponseSchema = import_zod9.z.object({
1265
+ transliterated_text: import_zod9.z.string().nullish(),
1163
1266
  source_language_code: SarvamLanguageCodeSchema.nullable(),
1164
- request_id: import_zod8.z.string().nullish()
1267
+ request_id: import_zod9.z.string().nullish()
1165
1268
  });
1166
1269
 
1167
1270
  // src/sarvam-provider.ts
1168
1271
  function createSarvam(options = {}) {
1169
1272
  var _a;
1170
- const baseURL = (_a = (0, import_provider_utils8.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.sarvam.ai";
1171
- const ApiKey = (0, import_provider_utils8.loadApiKey)({
1273
+ const baseURL = (_a = (0, import_provider_utils9.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.sarvam.ai";
1274
+ const ApiKey = (0, import_provider_utils9.loadApiKey)({
1172
1275
  apiKey: options.apiKey,
1173
1276
  environmentVariableName: "SARVAM_API_KEY",
1174
1277
  description: "Sarvam"
@@ -1201,7 +1304,7 @@ function createSarvam(options = {}) {
1201
1304
  });
1202
1305
  };
1203
1306
  const createSpeechModel = (modelId, languageCode, settings) => new SarvamSpeechModel(modelId, languageCode, {
1204
- provider: `sarvam.speech`,
1307
+ provider: "sarvam.speech",
1205
1308
  url: ({ path }) => `${baseURL}${path}`,
1206
1309
  headers: getHeaders,
1207
1310
  fetch: options.fetch,
@@ -1219,12 +1322,25 @@ function createSarvam(options = {}) {
1219
1322
  fetch: options.fetch
1220
1323
  }
1221
1324
  );
1325
+ const createTranslationModel = (settings) => new SarvamTranslationModel(
1326
+ {
1327
+ to: settings.to,
1328
+ from: settings.from
1329
+ },
1330
+ {
1331
+ provider: "sarvam.translation",
1332
+ url: ({ path }) => `${baseURL}${path}`,
1333
+ headers: getHeaders,
1334
+ fetch: options.fetch
1335
+ }
1336
+ );
1222
1337
  const provider = (modelId, settings) => createLanguageModel(modelId, settings);
1223
1338
  provider.languageModel = createLanguageModel;
1224
1339
  provider.chat = createChatModel;
1225
1340
  provider.transcription = createTranscriptionModel;
1226
1341
  provider.speech = createSpeechModel;
1227
1342
  provider.transliterate = createTransliterateModel;
1343
+ provider.translation = createTranslationModel;
1228
1344
  return provider;
1229
1345
  }
1230
1346
  var sarvam = createSarvam();