sarvam-ai-sdk 0.0.3 → 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");
@@ -396,7 +396,6 @@ var SarvamChatLanguageModel = class {
396
396
  // messages:
397
397
  messages: convertToSarvamChatMessages(prompt2, fakeToolSystemPrompt)
398
398
  });
399
- console.log(type, mode);
400
399
  switch (type) {
401
400
  case "regular": {
402
401
  const { tools, tool_choice, toolWarnings } = prepareTools({
@@ -759,140 +758,12 @@ var sarvamChatChunkSchema = import_zod2.z.union([
759
758
  sarvamErrorDataSchema
760
759
  ]);
761
760
 
762
- // src/sarvam-transcription-model.ts
763
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
764
- var import_zod4 = require("zod");
765
-
766
- // src/sarvam-transcription-settings.ts
767
- var import_zod3 = require("zod");
768
- var SarvamProviderOptionsSchema = import_zod3.z.object({
769
- with_timestamps: import_zod3.z.boolean().nullish().default(false),
770
- with_diarization: import_zod3.z.boolean().nullish().default(false),
771
- num_speakers: import_zod3.z.number().int().nullish()
772
- });
773
-
774
- // src/sarvam-transcription-model.ts
775
- var SarvamTranscriptionModel = class {
776
- constructor(modelId, languageCode, config) {
777
- this.modelId = modelId;
778
- this.languageCode = languageCode;
779
- this.config = config;
780
- this.specificationVersion = "v1";
781
- }
782
- get provider() {
783
- return this.config.provider;
784
- }
785
- getArgs({
786
- audio,
787
- mediaType,
788
- providerOptions
789
- }) {
790
- const warnings = [];
791
- if (this.modelId === "saarika:v1" && this.languageCode === "unknown")
792
- throw new Error(
793
- "Language code unknown is not supported for model saarika:v1"
794
- );
795
- const sarvamOptions = (0, import_provider_utils5.parseProviderOptions)({
796
- provider: "sarvam",
797
- providerOptions: {
798
- sarvam: __spreadValues(__spreadValues({}, providerOptions == null ? void 0 : providerOptions.sarvam), this.config.transcription)
799
- },
800
- schema: SarvamProviderOptionsSchema
801
- });
802
- const formData = new FormData();
803
- const blob = audio instanceof Blob ? audio : new Blob([audio], { type: mediaType });
804
- formData.append("file", blob);
805
- formData.append("model", this.modelId);
806
- if (sarvamOptions) {
807
- formData.append("language_code", this.languageCode);
808
- formData.append(
809
- "with_timestamps",
810
- sarvamOptions.with_timestamps ? "true" : "false"
811
- );
812
- formData.append(
813
- "with_diarization",
814
- sarvamOptions.with_diarization ? "true" : "false"
815
- );
816
- if (sarvamOptions.num_speakers !== null && sarvamOptions.num_speakers !== void 0) {
817
- formData.append(
818
- "num_speakers",
819
- sarvamOptions.num_speakers.toString()
820
- );
821
- }
822
- }
823
- return {
824
- formData,
825
- warnings
826
- };
827
- }
828
- async doGenerate(options) {
829
- var _a, _b, _c, _d, _e;
830
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
831
- const { formData, warnings } = this.getArgs(options);
832
- const {
833
- value: response,
834
- responseHeaders,
835
- rawValue: rawResponse
836
- } = await (0, import_provider_utils5.postFormDataToApi)({
837
- url: this.config.url({
838
- path: "/speech-to-text",
839
- modelId: this.modelId
840
- }),
841
- headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
842
- formData,
843
- failedResponseHandler: sarvamFailedResponseHandler,
844
- successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
845
- sarvamTranscriptionResponseSchema
846
- ),
847
- abortSignal: options.abortSignal,
848
- fetch: this.config.fetch
849
- });
850
- return {
851
- text: response.transcript,
852
- segments: response.timestamps ? response.timestamps.words.map((word, index) => ({
853
- text: word,
854
- startSecond: response.timestamps.start_time_seconds[index],
855
- endSecond: response.timestamps.end_time_seconds[index]
856
- })) : [],
857
- language: response.language_code ? response.language_code : void 0,
858
- durationInSeconds: (_e = (_d = response.timestamps) == null ? void 0 : _d.end_time_seconds[response.timestamps.end_time_seconds.length - 1]) != null ? _e : void 0,
859
- warnings,
860
- response: {
861
- timestamp: currentDate,
862
- modelId: this.modelId,
863
- headers: responseHeaders,
864
- body: rawResponse
865
- }
866
- };
867
- }
868
- };
869
- var sarvamTranscriptionResponseSchema = import_zod4.z.object({
870
- request_id: import_zod4.z.string().nullable(),
871
- transcript: import_zod4.z.string(),
872
- language_code: import_zod4.z.string().nullable(),
873
- timestamps: import_zod4.z.object({
874
- end_time_seconds: import_zod4.z.array(import_zod4.z.number()),
875
- start_time_seconds: import_zod4.z.array(import_zod4.z.number()),
876
- words: import_zod4.z.array(import_zod4.z.string())
877
- }).optional(),
878
- diarized_transcript: import_zod4.z.object({
879
- entries: import_zod4.z.array(
880
- import_zod4.z.object({
881
- end_time_seconds: import_zod4.z.array(import_zod4.z.number()),
882
- start_time_seconds: import_zod4.z.array(import_zod4.z.number()),
883
- transcript: import_zod4.z.string(),
884
- speaker_id: import_zod4.z.string()
885
- })
886
- )
887
- }).optional()
888
- });
889
-
890
761
  // src/sarvam-speech-model.ts
891
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
762
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
892
763
 
893
764
  // src/sarvam-speech-settings.ts
894
- var import_zod5 = require("zod");
895
- var SpeakerSchema = import_zod5.z.enum([
765
+ var import_zod3 = require("zod");
766
+ var SpeakerSchema = import_zod3.z.enum([
896
767
  "meera",
897
768
  "pavithra",
898
769
  "maitreyi",
@@ -913,22 +784,22 @@ var SpeakerSchema = import_zod5.z.enum([
913
784
  "karun",
914
785
  "hitesh"
915
786
  ]).default("meera");
916
- var SarvamProviderOptionsSchema2 = import_zod5.z.object({
787
+ var SarvamProviderOptionsSchema = import_zod3.z.object({
917
788
  speaker: SpeakerSchema,
918
- pitch: import_zod5.z.number().min(-0.75).max(0.75).default(0),
919
- pace: import_zod5.z.number().min(0.5).max(2).default(1),
920
- loudness: import_zod5.z.number().min(0.3).max(3).default(1),
921
- speech_sample_rate: import_zod5.z.union([
922
- import_zod5.z.literal(8e3),
923
- import_zod5.z.literal(16e3),
924
- import_zod5.z.literal(22050),
925
- 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)
926
797
  ]).default(22050),
927
- enable_preprocessing: import_zod5.z.boolean().default(false)
798
+ enable_preprocessing: import_zod3.z.boolean().default(false)
928
799
  }).partial();
929
800
 
930
801
  // src/sarvam-speech-model.ts
931
- var import_zod6 = require("zod");
802
+ var import_zod4 = require("zod");
932
803
  var SarvamSpeechModel = class {
933
804
  constructor(modelId, languageCode, config) {
934
805
  this.modelId = modelId;
@@ -948,12 +819,12 @@ var SarvamSpeechModel = class {
948
819
  providerOptions
949
820
  }) {
950
821
  const warnings = [];
951
- const sarvamOptions = (0, import_provider_utils6.parseProviderOptions)({
822
+ const sarvamOptions = (0, import_provider_utils5.parseProviderOptions)({
952
823
  provider: "sarvam",
953
824
  providerOptions: {
954
825
  sarvam: __spreadValues(__spreadValues({}, providerOptions == null ? void 0 : providerOptions.sarvam), this.config.speech)
955
826
  },
956
- schema: SarvamProviderOptionsSchema2
827
+ schema: SarvamProviderOptionsSchema
957
828
  });
958
829
  const getSpeaker = () => {
959
830
  if (sarvamOptions == null ? void 0 : sarvamOptions.speaker) return sarvamOptions.speaker;
@@ -1012,18 +883,18 @@ var SarvamSpeechModel = class {
1012
883
  value,
1013
884
  responseHeaders,
1014
885
  rawValue: rawResponse
1015
- } = await (0, import_provider_utils6.postJsonToApi)({
886
+ } = await (0, import_provider_utils5.postJsonToApi)({
1016
887
  url: this.config.url({
1017
888
  path: "/text-to-speech",
1018
889
  modelId: this.modelId
1019
890
  }),
1020
- headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), options.headers),
891
+ headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
1021
892
  body: requestBody,
1022
893
  failedResponseHandler: sarvamFailedResponseHandler,
1023
- successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
1024
- import_zod6.z.object({
1025
- request_id: import_zod6.z.string(),
1026
- 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())
1027
898
  })
1028
899
  ),
1029
900
  abortSignal: options.abortSignal,
@@ -1046,7 +917,135 @@ var SarvamSpeechModel = class {
1046
917
  }
1047
918
  };
1048
919
 
1049
- // 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
1050
1049
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1051
1050
  var import_zod8 = require("zod");
1052
1051
 
@@ -1066,7 +1065,110 @@ var SarvamLanguageCodeSchema = import_zod7.z.enum([
1066
1065
  "gu-IN"
1067
1066
  ]);
1068
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
+
1069
1169
  // src/sarvam-transliterate-model.ts
1170
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1171
+ var import_zod9 = require("zod");
1070
1172
  var SarvamTransliterateModel = class {
1071
1173
  constructor(settings, config) {
1072
1174
  this.specificationVersion = "v1";
@@ -1124,14 +1226,14 @@ var SarvamTransliterateModel = class {
1124
1226
  responseHeaders,
1125
1227
  value: response,
1126
1228
  rawValue: rawResponse
1127
- } = await (0, import_provider_utils7.postJsonToApi)({
1229
+ } = await (0, import_provider_utils8.postJsonToApi)({
1128
1230
  url: this.config.url({
1129
1231
  path: "/transliterate"
1130
1232
  }),
1131
- headers: (0, import_provider_utils7.combineHeaders)(this.config.headers(), options.headers),
1233
+ headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
1132
1234
  body: args,
1133
1235
  failedResponseHandler: sarvamFailedResponseHandler,
1134
- successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1236
+ successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
1135
1237
  sarvamTransliterateResponseSchema
1136
1238
  ),
1137
1239
  abortSignal: options.abortSignal,
@@ -1159,17 +1261,17 @@ var SarvamTransliterateModel = class {
1159
1261
  throw new Error("Transliterate feature doesn't streaming yet");
1160
1262
  }
1161
1263
  };
1162
- var sarvamTransliterateResponseSchema = import_zod8.z.object({
1163
- transliterated_text: import_zod8.z.string().nullish(),
1264
+ var sarvamTransliterateResponseSchema = import_zod9.z.object({
1265
+ transliterated_text: import_zod9.z.string().nullish(),
1164
1266
  source_language_code: SarvamLanguageCodeSchema.nullable(),
1165
- request_id: import_zod8.z.string().nullish()
1267
+ request_id: import_zod9.z.string().nullish()
1166
1268
  });
1167
1269
 
1168
1270
  // src/sarvam-provider.ts
1169
1271
  function createSarvam(options = {}) {
1170
1272
  var _a;
1171
- const baseURL = (_a = (0, import_provider_utils8.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.sarvam.ai";
1172
- 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)({
1173
1275
  apiKey: options.apiKey,
1174
1276
  environmentVariableName: "SARVAM_API_KEY",
1175
1277
  description: "Sarvam"
@@ -1202,7 +1304,7 @@ function createSarvam(options = {}) {
1202
1304
  });
1203
1305
  };
1204
1306
  const createSpeechModel = (modelId, languageCode, settings) => new SarvamSpeechModel(modelId, languageCode, {
1205
- provider: `sarvam.speech`,
1307
+ provider: "sarvam.speech",
1206
1308
  url: ({ path }) => `${baseURL}${path}`,
1207
1309
  headers: getHeaders,
1208
1310
  fetch: options.fetch,
@@ -1220,12 +1322,25 @@ function createSarvam(options = {}) {
1220
1322
  fetch: options.fetch
1221
1323
  }
1222
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
+ );
1223
1337
  const provider = (modelId, settings) => createLanguageModel(modelId, settings);
1224
1338
  provider.languageModel = createLanguageModel;
1225
1339
  provider.chat = createChatModel;
1226
1340
  provider.transcription = createTranscriptionModel;
1227
1341
  provider.speech = createSpeechModel;
1228
1342
  provider.transliterate = createTransliterateModel;
1343
+ provider.translation = createTranslationModel;
1229
1344
  return provider;
1230
1345
  }
1231
1346
  var sarvam = createSarvam();