sarvamai 1.1.7 → 1.1.8-alpha.2

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.
Files changed (114) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/api/resources/chat/client/requests/ChatCompletionsRequest.d.ts +3 -1
  3. package/dist/cjs/api/resources/speechToText/client/Client.d.ts +2 -2
  4. package/dist/cjs/api/resources/speechToText/client/Client.js +2 -2
  5. package/dist/cjs/api/resources/speechToText/client/requests/SpeechToTextTranscriptionRequest.d.ts +2 -2
  6. package/dist/cjs/api/resources/speechToText/client/requests/SpeechToTextTranslationRequest.d.ts +2 -0
  7. package/dist/cjs/api/resources/speechToTextStreaming/client/Client.d.ts +5 -2
  8. package/dist/cjs/api/resources/speechToTextStreaming/client/Client.js +15 -3
  9. package/dist/cjs/api/resources/speechToTextStreaming/client/Socket.d.ts +5 -0
  10. package/dist/cjs/api/resources/speechToTextStreaming/client/Socket.js +7 -0
  11. package/dist/cjs/api/resources/speechToTextTranslateStreaming/client/Client.d.ts +3 -2
  12. package/dist/cjs/api/resources/speechToTextTranslateStreaming/client/Client.js +13 -4
  13. package/dist/cjs/api/resources/speechToTextTranslateStreaming/client/Socket.d.ts +5 -0
  14. package/dist/cjs/api/resources/speechToTextTranslateStreaming/client/Socket.js +7 -0
  15. package/dist/cjs/api/resources/speechToTextTranslateStreaming/types/index.d.ts +0 -2
  16. package/dist/cjs/api/resources/speechToTextTranslateStreaming/types/index.js +0 -2
  17. package/dist/cjs/api/resources/text/client/requests/TranslationRequest.d.ts +1 -1
  18. package/dist/cjs/api/resources/textToSpeechStreaming/client/Client.d.ts +4 -3
  19. package/dist/cjs/api/resources/textToSpeechStreaming/client/Client.js +13 -4
  20. package/dist/cjs/api/types/ConfigureConnection.d.ts +32 -8
  21. package/dist/cjs/api/types/ConfigureConnection.js +23 -5
  22. package/dist/cjs/api/types/DocDigitizationJobParameters.d.ts +2 -2
  23. package/dist/cjs/api/types/DocDigitizationSupportedLanguage.d.ts +2 -2
  24. package/dist/cjs/api/types/DocDigitizationSupportedLanguage.js +2 -2
  25. package/dist/cjs/api/types/ErrorDetails.d.ts +1 -1
  26. package/dist/cjs/api/types/ErrorDetails2.d.ts +1 -1
  27. package/dist/cjs/api/types/FilesRequest.d.ts +5 -0
  28. package/dist/cjs/api/types/JsonSchemaDefinition.d.ts +10 -0
  29. package/dist/cjs/api/types/JsonSchemaDefinition.js +3 -0
  30. package/dist/cjs/api/types/ResponseFormat.d.ts +13 -0
  31. package/dist/cjs/api/types/ResponseFormat.js +3 -0
  32. package/dist/cjs/api/types/ResponseFormatJsonObject.d.ts +1 -0
  33. package/dist/cjs/api/types/ResponseFormatJsonObject.js +3 -0
  34. package/dist/cjs/api/types/ResponseFormatJsonSchema.d.ts +5 -0
  35. package/dist/cjs/api/types/ResponseFormatJsonSchema.js +3 -0
  36. package/dist/cjs/api/types/ResponseFormatText.d.ts +1 -0
  37. package/dist/cjs/api/types/ResponseFormatText.js +3 -0
  38. package/dist/cjs/api/types/SarvamModelIds.d.ts +1 -2
  39. package/dist/cjs/api/types/SarvamModelIds.js +1 -2
  40. package/dist/cjs/api/types/SpeechToTextJobParameters.d.ts +2 -2
  41. package/dist/cjs/api/types/SpeechToTextModel.d.ts +3 -3
  42. package/dist/cjs/api/types/SpeechToTextModel.js +3 -3
  43. package/dist/cjs/api/types/SpeechToTextTranslateJobParameters.d.ts +2 -0
  44. package/dist/cjs/api/types/SpeechToTextTranslateLanguage.d.ts +1 -1
  45. package/dist/cjs/api/types/SpeechToTextTranslateLanguage.js +1 -1
  46. package/dist/cjs/api/types/SpeechToTextTranslateModel.d.ts +2 -0
  47. package/dist/cjs/api/types/index.d.ts +5 -0
  48. package/dist/cjs/api/types/index.js +5 -0
  49. package/dist/cjs/index.d.ts +1 -0
  50. package/dist/cjs/index.js +2 -1
  51. package/dist/cjs/version.d.ts +1 -1
  52. package/dist/cjs/version.js +1 -1
  53. package/dist/esm/BaseClient.mjs +2 -2
  54. package/dist/esm/api/resources/chat/client/requests/ChatCompletionsRequest.d.mts +3 -1
  55. package/dist/esm/api/resources/speechToText/client/Client.d.mts +2 -2
  56. package/dist/esm/api/resources/speechToText/client/Client.mjs +2 -2
  57. package/dist/esm/api/resources/speechToText/client/requests/SpeechToTextTranscriptionRequest.d.mts +2 -2
  58. package/dist/esm/api/resources/speechToText/client/requests/SpeechToTextTranslationRequest.d.mts +2 -0
  59. package/dist/esm/api/resources/speechToTextStreaming/client/Client.d.mts +5 -2
  60. package/dist/esm/api/resources/speechToTextStreaming/client/Client.mjs +15 -3
  61. package/dist/esm/api/resources/speechToTextStreaming/client/Socket.d.mts +5 -0
  62. package/dist/esm/api/resources/speechToTextStreaming/client/Socket.mjs +7 -0
  63. package/dist/esm/api/resources/speechToTextTranslateStreaming/client/Client.d.mts +3 -2
  64. package/dist/esm/api/resources/speechToTextTranslateStreaming/client/Client.mjs +13 -4
  65. package/dist/esm/api/resources/speechToTextTranslateStreaming/client/Socket.d.mts +5 -0
  66. package/dist/esm/api/resources/speechToTextTranslateStreaming/client/Socket.mjs +7 -0
  67. package/dist/esm/api/resources/speechToTextTranslateStreaming/types/index.d.mts +0 -2
  68. package/dist/esm/api/resources/speechToTextTranslateStreaming/types/index.mjs +0 -2
  69. package/dist/esm/api/resources/text/client/requests/TranslationRequest.d.mts +1 -1
  70. package/dist/esm/api/resources/textToSpeechStreaming/client/Client.d.mts +4 -3
  71. package/dist/esm/api/resources/textToSpeechStreaming/client/Client.mjs +13 -4
  72. package/dist/esm/api/types/ConfigureConnection.d.mts +32 -8
  73. package/dist/esm/api/types/ConfigureConnection.mjs +23 -5
  74. package/dist/esm/api/types/DocDigitizationJobParameters.d.mts +2 -2
  75. package/dist/esm/api/types/DocDigitizationSupportedLanguage.d.mts +2 -2
  76. package/dist/esm/api/types/DocDigitizationSupportedLanguage.mjs +2 -2
  77. package/dist/esm/api/types/ErrorDetails.d.mts +1 -1
  78. package/dist/esm/api/types/ErrorDetails2.d.mts +1 -1
  79. package/dist/esm/api/types/FilesRequest.d.mts +5 -0
  80. package/dist/esm/api/types/JsonSchemaDefinition.d.mts +10 -0
  81. package/dist/esm/api/types/JsonSchemaDefinition.mjs +2 -0
  82. package/dist/esm/api/types/ResponseFormat.d.mts +13 -0
  83. package/dist/esm/api/types/ResponseFormat.mjs +2 -0
  84. package/dist/esm/api/types/ResponseFormatJsonObject.d.mts +1 -0
  85. package/dist/esm/api/types/ResponseFormatJsonObject.mjs +2 -0
  86. package/dist/esm/api/types/ResponseFormatJsonSchema.d.mts +5 -0
  87. package/dist/esm/api/types/ResponseFormatJsonSchema.mjs +2 -0
  88. package/dist/esm/api/types/ResponseFormatText.d.mts +1 -0
  89. package/dist/esm/api/types/ResponseFormatText.mjs +2 -0
  90. package/dist/esm/api/types/SarvamModelIds.d.mts +1 -2
  91. package/dist/esm/api/types/SarvamModelIds.mjs +1 -2
  92. package/dist/esm/api/types/SpeechToTextJobParameters.d.mts +2 -2
  93. package/dist/esm/api/types/SpeechToTextModel.d.mts +3 -3
  94. package/dist/esm/api/types/SpeechToTextModel.mjs +3 -3
  95. package/dist/esm/api/types/SpeechToTextTranslateJobParameters.d.mts +2 -0
  96. package/dist/esm/api/types/SpeechToTextTranslateLanguage.d.mts +1 -1
  97. package/dist/esm/api/types/SpeechToTextTranslateLanguage.mjs +1 -1
  98. package/dist/esm/api/types/SpeechToTextTranslateModel.d.mts +2 -0
  99. package/dist/esm/api/types/index.d.mts +5 -0
  100. package/dist/esm/api/types/index.mjs +5 -0
  101. package/dist/esm/index.d.mts +1 -0
  102. package/dist/esm/index.mjs +1 -0
  103. package/dist/esm/version.d.mts +1 -1
  104. package/dist/esm/version.mjs +1 -1
  105. package/package.json +1 -1
  106. package/reference.md +17 -7
  107. package/dist/cjs/api/resources/speechToTextTranslateStreaming/types/SpeechToTextTranslateStreamingMode.d.ts +0 -22
  108. package/dist/cjs/api/resources/speechToTextTranslateStreaming/types/SpeechToTextTranslateStreamingMode.js +0 -25
  109. package/dist/cjs/api/resources/speechToTextTranslateStreaming/types/SpeechToTextTranslateStreamingModel.d.ts +0 -13
  110. package/dist/cjs/api/resources/speechToTextTranslateStreaming/types/SpeechToTextTranslateStreamingModel.js +0 -16
  111. package/dist/esm/api/resources/speechToTextTranslateStreaming/types/SpeechToTextTranslateStreamingMode.d.mts +0 -22
  112. package/dist/esm/api/resources/speechToTextTranslateStreaming/types/SpeechToTextTranslateStreamingMode.mjs +0 -22
  113. package/dist/esm/api/resources/speechToTextTranslateStreaming/types/SpeechToTextTranslateStreamingModel.d.mts +0 -13
  114. package/dist/esm/api/resources/speechToTextTranslateStreaming/types/SpeechToTextTranslateStreamingModel.mjs +0 -13
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "sarvamai",
46
- "X-Fern-SDK-Version": "1.1.7",
47
- "User-Agent": "sarvamai/1.1.7",
46
+ "X-Fern-SDK-Version": "1.1.8-alpha.2",
47
+ "User-Agent": "sarvamai/1.1.8-alpha.2",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -11,7 +11,7 @@ import type * as SarvamAI from "../../../../index.js";
11
11
  export interface ChatCompletionsRequest {
12
12
  /** A list of messages comprising the conversation so far. */
13
13
  messages: SarvamAI.ChatCompletionRequestMessage[];
14
- /** Chat model ID. Prefer `sarvam-30b` (64K context) or `sarvam-105b` (128K context) for new workloads. The value `sarvam-m` is a legacy 24B model that remains accepted; migrate to Sarvam-30B or Sarvam-105B for better performance. */
14
+ /** Chat model ID. Use `sarvam-30b` (64K context) or `sarvam-105b` (128K context). */
15
15
  model: SarvamAI.SarvamModelIds;
16
16
  /**
17
17
  * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
@@ -63,4 +63,6 @@ export interface ChatCompletionsRequest {
63
63
  tools?: SarvamAI.ChatCompletionTool[];
64
64
  /** Controls which (if any) tool is called by the model. */
65
65
  tool_choice?: SarvamAI.ToolChoiceOption;
66
+ /** An object specifying the format that the model must output. Setting `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which guarantees the model generates output matching the supplied JSON Schema. Setting `{ "type": "json_object" }` enables the older JSON mode, which guarantees valid JSON but not a specific schema. */
67
+ response_format?: SarvamAI.ResponseFormat;
66
68
  }
@@ -23,7 +23,7 @@ export declare class SpeechToTextClient {
23
23
  * ### Note:
24
24
  * - Pricing differs for REST and Batch APIs
25
25
  * - Diarization is only available in Batch API with separate pricing
26
- * - Please refer to [here](https://docs.sarvam.ai/api-reference-docs/getting-started/pricing) for detailed pricing information
26
+ * - Please refer to [here](https://docs.sarvam.ai/api-reference-docs/pricing) for detailed pricing information
27
27
  *
28
28
  * @param {SarvamAI.SpeechToTextTranscriptionRequest} request
29
29
  * @param {SpeechToTextClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -56,7 +56,7 @@ export declare class SpeechToTextClient {
56
56
  * ### Note:
57
57
  * - Pricing differs for REST and Batch APIs
58
58
  * - Diarization is only available in Batch API with separate pricing
59
- * - Please refer to [here](https://docs.sarvam.ai/api-reference-docs/getting-started/pricing) for detailed pricing information
59
+ * - Please refer to [here](https://docs.sarvam.ai/api-reference-docs/pricing) for detailed pricing information
60
60
  *
61
61
  * @param {SarvamAI.SpeechToTextTranslationRequest} request
62
62
  * @param {SpeechToTextClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -68,7 +68,7 @@ class SpeechToTextClient {
68
68
  * ### Note:
69
69
  * - Pricing differs for REST and Batch APIs
70
70
  * - Diarization is only available in Batch API with separate pricing
71
- * - Please refer to [here](https://docs.sarvam.ai/api-reference-docs/getting-started/pricing) for detailed pricing information
71
+ * - Please refer to [here](https://docs.sarvam.ai/api-reference-docs/pricing) for detailed pricing information
72
72
  *
73
73
  * @param {SarvamAI.SpeechToTextTranscriptionRequest} request
74
74
  * @param {SpeechToTextClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -164,7 +164,7 @@ class SpeechToTextClient {
164
164
  * ### Note:
165
165
  * - Pricing differs for REST and Batch APIs
166
166
  * - Diarization is only available in Batch API with separate pricing
167
- * - Please refer to [here](https://docs.sarvam.ai/api-reference-docs/getting-started/pricing) for detailed pricing information
167
+ * - Please refer to [here](https://docs.sarvam.ai/api-reference-docs/pricing) for detailed pricing information
168
168
  *
169
169
  * @param {SarvamAI.SpeechToTextTranslationRequest} request
170
170
  * @param {SpeechToTextClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -15,9 +15,9 @@ export interface SpeechToTextTranscriptionRequest {
15
15
  /**
16
16
  * Specifies the model to use for speech-to-text conversion.
17
17
  *
18
- * - **saarika:v2.5** (default): Transcribes audio in the spoken language.
18
+ * - **saaras:v3** (default, recommended): State-of-the-art model with flexible output formats. Supports multiple modes via the `mode` parameter: transcribe, translate, verbatim, translit, codemix.
19
19
  *
20
- * - **saaras:v3**: State-of-the-art model with flexible output formats. Supports multiple modes via the `mode` parameter: transcribe, translate, verbatim, translit, codemix.
20
+ * - **saarika:v2.5** (legacy): Transcribes audio in the spoken language. Kept for backward compatibility.
21
21
  */
22
22
  model?: SarvamAI.SpeechToTextModel;
23
23
  /**
@@ -19,6 +19,8 @@ export interface SpeechToTextTranslationRequest {
19
19
  *
20
20
  * - **saaras:v2.5** (default): Translation model that translates audio from any spoken Indic language to English.
21
21
  * - Example: Hindi audio → English text output
22
+ *
23
+ * For the latest model (saaras:v3), use the `/speech-to-text` endpoint with `mode="translate"`.
22
24
  */
23
25
  model?: SarvamAI.SpeechToTextTranslateModel;
24
26
  /** Audio codec/format of the input file. Our API automatically detects all codec formats, but for PCM files specifically (pcm_s16le, pcm_l16, pcm_raw), you must pass this parameter. PCM files are supported only at 16kHz sample rate. */
@@ -6,13 +6,16 @@ export declare namespace SpeechToTextStreamingClient {
6
6
  }
7
7
  interface ConnectArgs {
8
8
  "language-code": SarvamAI.SpeechToTextStreamingLanguageCode;
9
- model?: SarvamAI.SpeechToTextTranslateModel | undefined;
9
+ model?: SarvamAI.SpeechToTextStreamingModel | undefined;
10
+ /** Mode of operation. Only applicable when using the saaras:v3 model. */
11
+ mode?: SarvamAI.SpeechToTextStreamingMode | undefined;
10
12
  input_audio_codec?: SarvamAI.SpeechToTextStreamingInputAudioCodec | undefined;
11
13
  sample_rate?: string | undefined;
12
14
  high_vad_sensitivity?: SarvamAI.SpeechToTextStreamingHighVadSensitivity | undefined;
13
15
  vad_signals?: SarvamAI.SpeechToTextStreamingVadSignals | undefined;
14
16
  flush_signal?: SarvamAI.SpeechToTextStreamingFlushSignal | undefined;
15
- "Api-Subscription-Key": string;
17
+ /** Optional when the client is configured with `apiSubscriptionKey` or the `SARVAM_API_KEY` environment variable. */
18
+ "Api-Subscription-Key"?: string;
16
19
  /** Arbitrary headers to send with the websocket connect request. */
17
20
  headers?: Record<string, string>;
18
21
  /** Enable debug mode on the websocket. Defaults to false. */
@@ -56,12 +56,15 @@ class SpeechToTextStreamingClient {
56
56
  connect(args) {
57
57
  return __awaiter(this, void 0, void 0, function* () {
58
58
  var _a, _b;
59
- const { "language-code": languageCode, model, input_audio_codec: inputAudioCodec, sample_rate: sampleRate, high_vad_sensitivity: highVadSensitivity, vad_signals: vadSignals, flush_signal: flushSignal, headers, debug, reconnectAttempts, } = args;
59
+ const { "language-code": languageCode, model, mode, input_audio_codec: inputAudioCodec, sample_rate: sampleRate, high_vad_sensitivity: highVadSensitivity, vad_signals: vadSignals, flush_signal: flushSignal, headers, debug, reconnectAttempts, } = args;
60
60
  const _queryParams = {};
61
61
  _queryParams["language-code"] = languageCode;
62
62
  if (model != null) {
63
63
  _queryParams.model = model;
64
64
  }
65
+ if (mode != null) {
66
+ _queryParams.mode = mode;
67
+ }
65
68
  if (inputAudioCodec != null) {
66
69
  _queryParams.input_audio_codec = inputAudioCodec;
67
70
  }
@@ -77,8 +80,17 @@ class SpeechToTextStreamingClient {
77
80
  if (flushSignal != null) {
78
81
  _queryParams.flush_signal = flushSignal;
79
82
  }
80
- const _authRequest = yield this._options.authProvider.getAuthRequest();
81
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Api-Subscription-Key": args["Api-Subscription-Key"] }), headers);
83
+ let _authRequest;
84
+ try {
85
+ _authRequest = yield this._options.authProvider.getAuthRequest();
86
+ }
87
+ catch (error) {
88
+ // Fall back to the key passed via connect args when the client itself has no credentials.
89
+ if (args["Api-Subscription-Key"] == null) {
90
+ throw error;
91
+ }
92
+ }
93
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest === null || _authRequest === void 0 ? void 0 : _authRequest.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Api-Subscription-Key": args["Api-Subscription-Key"] }), headers);
82
94
  const apiSubscriptionKeyValue = _headers["api-subscription-key"];
83
95
  const socket = new core.ReconnectingWebSocket({
84
96
  url: core.url.join((_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : ((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.SarvamAIEnvironment.Production).production, "/speech-to-text/ws"),
@@ -40,6 +40,11 @@ export declare class SpeechToTextStreamingSocket {
40
40
  encoding?: string;
41
41
  }): void;
42
42
  sendConfigMessage(message: SarvamAI.ConfigMessage): void;
43
+ /**
44
+ * Set a prompt (e.g. domain-specific words) to improve transcription accuracy.
45
+ * Convenience wrapper over `sendConfigMessage`.
46
+ */
47
+ setPrompt(prompt: string): void;
43
48
  /** Signal to flush the audio buffer and force finalize partial transcriptions */
44
49
  flush(): void;
45
50
  /** Connect to the websocket and register event handlers. */
@@ -107,6 +107,13 @@ class SpeechToTextStreamingSocket {
107
107
  this.assertSocketIsOpen();
108
108
  this.sendJson(message);
109
109
  }
110
+ /**
111
+ * Set a prompt (e.g. domain-specific words) to improve transcription accuracy.
112
+ * Convenience wrapper over `sendConfigMessage`.
113
+ */
114
+ setPrompt(prompt) {
115
+ this.sendConfigMessage({ type: "config", prompt });
116
+ }
110
117
  /** Signal to flush the audio buffer and force finalize partial transcriptions */
111
118
  flush() {
112
119
  this.assertSocketIsOpen();
@@ -11,7 +11,8 @@ export declare namespace SpeechToTextTranslateStreamingClient {
11
11
  high_vad_sensitivity?: SarvamAI.SpeechToTextTranslateStreamingHighVadSensitivity | undefined;
12
12
  vad_signals?: SarvamAI.SpeechToTextTranslateStreamingVadSignals | undefined;
13
13
  flush_signal?: SarvamAI.SpeechToTextTranslateStreamingFlushSignal | undefined;
14
- "Api-Subscription-Key": string;
14
+ /** Optional when the client is configured with `apiSubscriptionKey` or the `SARVAM_API_KEY` environment variable. */
15
+ "Api-Subscription-Key"?: string;
15
16
  /** Arbitrary headers to send with the websocket connect request. */
16
17
  headers?: Record<string, string>;
17
18
  /** Enable debug mode on the websocket. Defaults to false. */
@@ -23,5 +24,5 @@ export declare namespace SpeechToTextTranslateStreamingClient {
23
24
  export declare class SpeechToTextTranslateStreamingClient {
24
25
  protected readonly _options: NormalizedClientOptionsWithAuth<SpeechToTextTranslateStreamingClient.Options>;
25
26
  constructor(options?: SpeechToTextTranslateStreamingClient.Options);
26
- connect(args: SpeechToTextTranslateStreamingClient.ConnectArgs): Promise<SpeechToTextTranslateStreamingSocket>;
27
+ connect(args?: SpeechToTextTranslateStreamingClient.ConnectArgs): Promise<SpeechToTextTranslateStreamingSocket>;
27
28
  }
@@ -53,8 +53,8 @@ class SpeechToTextTranslateStreamingClient {
53
53
  constructor(options = {}) {
54
54
  this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
55
55
  }
56
- connect(args) {
57
- return __awaiter(this, void 0, void 0, function* () {
56
+ connect() {
57
+ return __awaiter(this, arguments, void 0, function* (args = {}) {
58
58
  var _a, _b;
59
59
  const { model, input_audio_codec: inputAudioCodec, sample_rate: sampleRate, high_vad_sensitivity: highVadSensitivity, vad_signals: vadSignals, flush_signal: flushSignal, headers, debug, reconnectAttempts, } = args;
60
60
  const _queryParams = {};
@@ -76,8 +76,17 @@ class SpeechToTextTranslateStreamingClient {
76
76
  if (flushSignal != null) {
77
77
  _queryParams.flush_signal = flushSignal;
78
78
  }
79
- const _authRequest = yield this._options.authProvider.getAuthRequest();
80
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Api-Subscription-Key": args["Api-Subscription-Key"] }), headers);
79
+ let _authRequest;
80
+ try {
81
+ _authRequest = yield this._options.authProvider.getAuthRequest();
82
+ }
83
+ catch (error) {
84
+ // Fall back to the key passed via connect args when the client itself has no credentials.
85
+ if (args["Api-Subscription-Key"] == null) {
86
+ throw error;
87
+ }
88
+ }
89
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest === null || _authRequest === void 0 ? void 0 : _authRequest.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Api-Subscription-Key": args["Api-Subscription-Key"] }), headers);
81
90
  const apiSubscriptionKeyValue = _headers["api-subscription-key"];
82
91
  const socket = new core.ReconnectingWebSocket({
83
92
  url: core.url.join((_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : ((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.SarvamAIEnvironment.Production).production, "/speech-to-text-translate/ws"),
@@ -40,6 +40,11 @@ export declare class SpeechToTextTranslateStreamingSocket {
40
40
  encoding?: string;
41
41
  }): void;
42
42
  sendConfigMessage(message: SarvamAI.ConfigMessage): void;
43
+ /**
44
+ * Set a prompt (e.g. domain-specific words) to improve translation accuracy.
45
+ * Convenience wrapper over `sendConfigMessage`.
46
+ */
47
+ setPrompt(prompt: string): void;
43
48
  /** Flush the audio buffer and finalize transcriptions and translations */
44
49
  flush(): void;
45
50
  /** Connect to the websocket and register event handlers. */
@@ -107,6 +107,13 @@ class SpeechToTextTranslateStreamingSocket {
107
107
  this.assertSocketIsOpen();
108
108
  this.sendJson(message);
109
109
  }
110
+ /**
111
+ * Set a prompt (e.g. domain-specific words) to improve translation accuracy.
112
+ * Convenience wrapper over `sendConfigMessage`.
113
+ */
114
+ setPrompt(prompt) {
115
+ this.sendConfigMessage({ type: "config", prompt });
116
+ }
110
117
  /** Flush the audio buffer and finalize transcriptions and translations */
111
118
  flush() {
112
119
  this.assertSocketIsOpen();
@@ -1,6 +1,4 @@
1
1
  export * from "./SpeechToTextTranslateStreamingFlushSignal.js";
2
2
  export * from "./SpeechToTextTranslateStreamingHighVadSensitivity.js";
3
3
  export * from "./SpeechToTextTranslateStreamingInputAudioCodec.js";
4
- export * from "./SpeechToTextTranslateStreamingMode.js";
5
- export * from "./SpeechToTextTranslateStreamingModel.js";
6
4
  export * from "./SpeechToTextTranslateStreamingVadSignals.js";
@@ -17,6 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./SpeechToTextTranslateStreamingFlushSignal.js"), exports);
18
18
  __exportStar(require("./SpeechToTextTranslateStreamingHighVadSensitivity.js"), exports);
19
19
  __exportStar(require("./SpeechToTextTranslateStreamingInputAudioCodec.js"), exports);
20
- __exportStar(require("./SpeechToTextTranslateStreamingMode.js"), exports);
21
- __exportStar(require("./SpeechToTextTranslateStreamingModel.js"), exports);
22
20
  __exportStar(require("./SpeechToTextTranslateStreamingVadSignals.js"), exports);
@@ -36,7 +36,7 @@ export interface TranslationRequest {
36
36
  * Specifies the tone or style of the translation.
37
37
  *
38
38
  * **Model Support:**
39
- * - **mayura:v1**: Supports formal, classic-colloquial, and modern-colloquial modes
39
+ * - **mayura:v1**: Supports formal, classic-colloquial, modern-colloquial, and code-mixed modes
40
40
  * - **sarvam-translate:v1**: Only formal mode is supported
41
41
  *
42
42
  * **Default:** formal
@@ -5,9 +5,10 @@ export declare namespace TextToSpeechStreamingClient {
5
5
  interface Options extends BaseClientOptions {
6
6
  }
7
7
  interface ConnectArgs {
8
- model?: "bulbul:v2" | undefined;
8
+ model?: SarvamAI.TextToSpeechStreamingModel | undefined;
9
9
  send_completion_event?: SarvamAI.TextToSpeechStreamingSendCompletionEvent | undefined;
10
- "Api-Subscription-Key": string;
10
+ /** Optional when the client is configured with `apiSubscriptionKey` or the `SARVAM_API_KEY` environment variable. */
11
+ "Api-Subscription-Key"?: string;
11
12
  /** Arbitrary headers to send with the websocket connect request. */
12
13
  headers?: Record<string, string>;
13
14
  /** Enable debug mode on the websocket. Defaults to false. */
@@ -19,5 +20,5 @@ export declare namespace TextToSpeechStreamingClient {
19
20
  export declare class TextToSpeechStreamingClient {
20
21
  protected readonly _options: NormalizedClientOptionsWithAuth<TextToSpeechStreamingClient.Options>;
21
22
  constructor(options?: TextToSpeechStreamingClient.Options);
22
- connect(args: TextToSpeechStreamingClient.ConnectArgs): Promise<TextToSpeechStreamingSocket>;
23
+ connect(args?: TextToSpeechStreamingClient.ConnectArgs): Promise<TextToSpeechStreamingSocket>;
23
24
  }
@@ -53,8 +53,8 @@ class TextToSpeechStreamingClient {
53
53
  constructor(options = {}) {
54
54
  this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
55
55
  }
56
- connect(args) {
57
- return __awaiter(this, void 0, void 0, function* () {
56
+ connect() {
57
+ return __awaiter(this, arguments, void 0, function* (args = {}) {
58
58
  var _a, _b;
59
59
  const { model, send_completion_event: sendCompletionEvent, headers, debug, reconnectAttempts } = args;
60
60
  const _queryParams = {};
@@ -64,8 +64,17 @@ class TextToSpeechStreamingClient {
64
64
  if (sendCompletionEvent != null) {
65
65
  _queryParams.send_completion_event = sendCompletionEvent;
66
66
  }
67
- const _authRequest = yield this._options.authProvider.getAuthRequest();
68
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Api-Subscription-Key": args["Api-Subscription-Key"] }), headers);
67
+ let _authRequest;
68
+ try {
69
+ _authRequest = yield this._options.authProvider.getAuthRequest();
70
+ }
71
+ catch (error) {
72
+ // Fall back to the key passed via connect args when the client itself has no credentials.
73
+ if (args["Api-Subscription-Key"] == null) {
74
+ throw error;
75
+ }
76
+ }
77
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest === null || _authRequest === void 0 ? void 0 : _authRequest.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Api-Subscription-Key": args["Api-Subscription-Key"] }), headers);
69
78
  const apiSubscriptionKeyValue = _headers["api-subscription-key"];
70
79
  const socket = new core.ReconnectingWebSocket({
71
80
  url: core.url.join((_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : ((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.SarvamAIEnvironment.Production).production, "/text-to-speech/ws"),
@@ -25,11 +25,17 @@ export declare namespace ConfigureConnection {
25
25
  /**
26
26
  * The speaker voice to be used for the output audio.
27
27
  *
28
- * **Model Compatibility:**
29
- * - **bulbul:v2:** anushka (default), abhilash, manisha, vidya, arya, karun, hitesh
30
- * - **bulbul:v3:** aditya (default), ritu, priya, neha, rahul, pooja, rohan, simran, kavya, amit, dev, ishita, shreya, ratan, varun, manan, sumit, roopa, kabir, aayan, shubh, ashutosh, advait, amelia, sophia
28
+ * **Default:** shubh (for bulbul:v3), anushka (for bulbul:v2)
29
+ *
30
+ * **Model Compatibility (Speakers compatible with respective model):**
31
+ * - **bulbul:v3:** shubh (default), aditya, ritu, priya, neha, rahul, pooja, rohan, simran, kavya, amit, dev, ishita, shreya, ratan, varun, manan, sumit, roopa, kabir, aayan, ashutosh, advait, anand, tanya, tarun, sunny, mani, gokul, vijay, shruti, suhani, mohit, kavitha, rehan, soham, rupali
32
+ * - **bulbul:v2:**
33
+ * - Female: anushka (default), manisha, vidya, arya
34
+ * - Male: abhilash, karun, hitesh
31
35
  *
32
36
  * **Note:** Speaker selection must match the chosen model version.
37
+ *
38
+ * **Important:** Speaker names are case-sensitive and must be lowercase (e.g., `ritu` not `Ritu`).
33
39
  */
34
40
  speaker: Data.Speaker;
35
41
  /**
@@ -132,11 +138,17 @@ export declare namespace ConfigureConnection {
132
138
  /**
133
139
  * The speaker voice to be used for the output audio.
134
140
  *
135
- * **Model Compatibility:**
136
- * - **bulbul:v2:** anushka (default), abhilash, manisha, vidya, arya, karun, hitesh
137
- * - **bulbul:v3:** aditya (default), ritu, priya, neha, rahul, pooja, rohan, simran, kavya, amit, dev, ishita, shreya, ratan, varun, manan, sumit, roopa, kabir, aayan, shubh, ashutosh, advait, amelia, sophia
141
+ * **Default:** shubh (for bulbul:v3), anushka (for bulbul:v2)
142
+ *
143
+ * **Model Compatibility (Speakers compatible with respective model):**
144
+ * - **bulbul:v3:** shubh (default), aditya, ritu, priya, neha, rahul, pooja, rohan, simran, kavya, amit, dev, ishita, shreya, ratan, varun, manan, sumit, roopa, kabir, aayan, ashutosh, advait, anand, tanya, tarun, sunny, mani, gokul, vijay, shruti, suhani, mohit, kavitha, rehan, soham, rupali
145
+ * - **bulbul:v2:**
146
+ * - Female: anushka (default), manisha, vidya, arya
147
+ * - Male: abhilash, karun, hitesh
138
148
  *
139
149
  * **Note:** Speaker selection must match the chosen model version.
150
+ *
151
+ * **Important:** Speaker names are case-sensitive and must be lowercase (e.g., `ritu` not `Ritu`).
140
152
  */
141
153
  const Speaker: {
142
154
  readonly Anushka: "anushka";
@@ -169,8 +181,20 @@ export declare namespace ConfigureConnection {
169
181
  readonly Shubh: "shubh";
170
182
  readonly Ashutosh: "ashutosh";
171
183
  readonly Advait: "advait";
172
- readonly Amelia: "amelia";
173
- readonly Sophia: "sophia";
184
+ readonly Anand: "anand";
185
+ readonly Tanya: "tanya";
186
+ readonly Tarun: "tarun";
187
+ readonly Sunny: "sunny";
188
+ readonly Mani: "mani";
189
+ readonly Gokul: "gokul";
190
+ readonly Vijay: "vijay";
191
+ readonly Shruti: "shruti";
192
+ readonly Suhani: "suhani";
193
+ readonly Mohit: "mohit";
194
+ readonly Kavitha: "kavitha";
195
+ readonly Rehan: "rehan";
196
+ readonly Soham: "soham";
197
+ readonly Rupali: "rupali";
174
198
  };
175
199
  type Speaker = (typeof Speaker)[keyof typeof Speaker];
176
200
  /** Audio codec (currently supports MP3 only, optimized for real-time playback) */
@@ -32,11 +32,17 @@ var ConfigureConnection;
32
32
  /**
33
33
  * The speaker voice to be used for the output audio.
34
34
  *
35
- * **Model Compatibility:**
36
- * - **bulbul:v2:** anushka (default), abhilash, manisha, vidya, arya, karun, hitesh
37
- * - **bulbul:v3:** aditya (default), ritu, priya, neha, rahul, pooja, rohan, simran, kavya, amit, dev, ishita, shreya, ratan, varun, manan, sumit, roopa, kabir, aayan, shubh, ashutosh, advait, amelia, sophia
35
+ * **Default:** shubh (for bulbul:v3), anushka (for bulbul:v2)
36
+ *
37
+ * **Model Compatibility (Speakers compatible with respective model):**
38
+ * - **bulbul:v3:** shubh (default), aditya, ritu, priya, neha, rahul, pooja, rohan, simran, kavya, amit, dev, ishita, shreya, ratan, varun, manan, sumit, roopa, kabir, aayan, ashutosh, advait, anand, tanya, tarun, sunny, mani, gokul, vijay, shruti, suhani, mohit, kavitha, rehan, soham, rupali
39
+ * - **bulbul:v2:**
40
+ * - Female: anushka (default), manisha, vidya, arya
41
+ * - Male: abhilash, karun, hitesh
38
42
  *
39
43
  * **Note:** Speaker selection must match the chosen model version.
44
+ *
45
+ * **Important:** Speaker names are case-sensitive and must be lowercase (e.g., `ritu` not `Ritu`).
40
46
  */
41
47
  Data.Speaker = {
42
48
  Anushka: "anushka",
@@ -69,8 +75,20 @@ var ConfigureConnection;
69
75
  Shubh: "shubh",
70
76
  Ashutosh: "ashutosh",
71
77
  Advait: "advait",
72
- Amelia: "amelia",
73
- Sophia: "sophia",
78
+ Anand: "anand",
79
+ Tanya: "tanya",
80
+ Tarun: "tarun",
81
+ Sunny: "sunny",
82
+ Mani: "mani",
83
+ Gokul: "gokul",
84
+ Vijay: "vijay",
85
+ Shruti: "shruti",
86
+ Suhani: "suhani",
87
+ Mohit: "mohit",
88
+ Kavitha: "kavitha",
89
+ Rehan: "rehan",
90
+ Soham: "soham",
91
+ Rupali: "rupali",
74
92
  };
75
93
  /** Audio codec (currently supports MP3 only, optimized for real-time playback) */
76
94
  Data.OutputAudioCodec = {
@@ -3,8 +3,8 @@ import type * as SarvamAI from "../index.js";
3
3
  * Configuration parameters for Document Intelligence job. Specify the document language and desired output format.
4
4
  */
5
5
  export interface DocDigitizationJobParameters {
6
- /** Primary language of the document in BCP-47 format. This helps optimize text extraction accuracy for the specified language. */
6
+ /** Primary language of the document in BCP-47 format (e.g. en-IN, hi-IN). Use this field name — not language_code (which other Sarvam APIs use). Sending language_code is ignored and defaults to hi-IN. */
7
7
  language?: SarvamAI.DocDigitizationSupportedLanguage | undefined;
8
- /** Output format for the extracted content (delivered as a ZIP file). Use 'html' for structured HTML, 'md' for Markdown, or 'json' for structured JSON data. */
8
+ /** Output format for the extracted content (delivered as a ZIP file). Accepted values: md, html, json. Use md for Markdown — not markdown (returns 400). */
9
9
  output_format?: SarvamAI.DocDigitizationOutputFormat | undefined;
10
10
  }
@@ -7,13 +7,13 @@ export declare const DocDigitizationSupportedLanguage: {
7
7
  readonly KnIn: "kn-IN";
8
8
  readonly MlIn: "ml-IN";
9
9
  readonly MrIn: "mr-IN";
10
- readonly OrIn: "or-IN";
10
+ readonly OdIn: "od-IN";
11
11
  readonly PaIn: "pa-IN";
12
12
  readonly TaIn: "ta-IN";
13
13
  readonly TeIn: "te-IN";
14
14
  readonly UrIn: "ur-IN";
15
15
  readonly AsIn: "as-IN";
16
- readonly BodoIn: "bodo-IN";
16
+ readonly BrxIn: "brx-IN";
17
17
  readonly DoiIn: "doi-IN";
18
18
  readonly KsIn: "ks-IN";
19
19
  readonly KokIn: "kok-IN";
@@ -11,13 +11,13 @@ exports.DocDigitizationSupportedLanguage = {
11
11
  KnIn: "kn-IN",
12
12
  MlIn: "ml-IN",
13
13
  MrIn: "mr-IN",
14
- OrIn: "or-IN",
14
+ OdIn: "od-IN",
15
15
  PaIn: "pa-IN",
16
16
  TaIn: "ta-IN",
17
17
  TeIn: "te-IN",
18
18
  UrIn: "ur-IN",
19
19
  AsIn: "as-IN",
20
- BodoIn: "bodo-IN",
20
+ BrxIn: "brx-IN",
21
21
  DoiIn: "doi-IN",
22
22
  KsIn: "ks-IN",
23
23
  KokIn: "kok-IN",
@@ -3,6 +3,6 @@ export interface ErrorDetails {
3
3
  request_id?: string | undefined;
4
4
  /** Message describing the error */
5
5
  message: string;
6
- /** Error code for the specific error that has occured. Refer to the error code documentation for more details. */
6
+ /** Error code for the specific error that has occurred. Refer to the error code documentation for more details. */
7
7
  code: SarvamAI.ErrorCode;
8
8
  }
@@ -2,7 +2,7 @@ import type * as SarvamAI from "../index.js";
2
2
  export interface ErrorDetails2 {
3
3
  /** Message describing the error */
4
4
  message: string;
5
- /** Error code for the specific error that has occured. Refer to the error code documentation for more details. */
5
+ /** Error code for the specific error that has occurred. Refer to the error code documentation for more details. */
6
6
  code: SarvamAI.ErrorCode2;
7
7
  /** Unique identifier for the request. Format: date_UUID4 */
8
8
  request_id?: string | undefined;
@@ -1,4 +1,9 @@
1
+ /**
2
+ * Request body for bulk job upload/download URL generation. Both job_id and files are required for download.
3
+ */
1
4
  export interface FilesRequest {
5
+ /** UUID of the bulk job returned from job initiation. */
2
6
  job_id: string;
7
+ /** Required. Output filenames to download (e.g. "0.json"). Get these from the job status response: job_details[].outputs[].file_name after the job completes. */
3
8
  files: string[];
4
9
  }
@@ -0,0 +1,10 @@
1
+ export interface JsonSchemaDefinition {
2
+ /** The name of the response format. Must contain only alphanumeric characters, underscores and dashes. */
3
+ name: string;
4
+ /** A description of what the response format is for, used by the model to determine how to respond in the format. */
5
+ description?: string | undefined;
6
+ /** The schema for the response format, described as a JSON Schema object. */
7
+ schema?: Record<string, unknown> | undefined;
8
+ /** Whether to enable strict schema adherence when generating the output. */
9
+ strict?: boolean | undefined;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import type * as SarvamAI from "../index.js";
2
+ export type ResponseFormat = SarvamAI.ResponseFormat.Text | SarvamAI.ResponseFormat.JsonObject | SarvamAI.ResponseFormat.JsonSchema;
3
+ export declare namespace ResponseFormat {
4
+ interface Text extends SarvamAI.ResponseFormatText {
5
+ type: "text";
6
+ }
7
+ interface JsonObject extends SarvamAI.ResponseFormatJsonObject {
8
+ type: "json_object";
9
+ }
10
+ interface JsonSchema extends SarvamAI.ResponseFormatJsonSchema {
11
+ type: "json_schema";
12
+ }
13
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export type ResponseFormatJsonObject = {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import type * as SarvamAI from "../index.js";
2
+ export interface ResponseFormatJsonSchema {
3
+ /** Structured Outputs configuration options, including a JSON Schema. */
4
+ json_schema: SarvamAI.JsonSchemaDefinition;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export type ResponseFormatText = {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +1,6 @@
1
- /** Supported chat completion model IDs. Primary models: `sarvam-30b`, `sarvam-105b`. Legacy: `sarvam-m` (24B); prefer Sarvam-30B or Sarvam-105B for new integrations. */
1
+ /** Supported chat completion model IDs: `sarvam-30b`, `sarvam-105b`. */
2
2
  export declare const SarvamModelIds: {
3
3
  readonly Sarvam105B: "sarvam-105b";
4
4
  readonly Sarvam30B: "sarvam-30b";
5
- readonly SarvamM: "sarvam-m";
6
5
  };
7
6
  export type SarvamModelIds = (typeof SarvamModelIds)[keyof typeof SarvamModelIds];
@@ -2,9 +2,8 @@
2
2
  // This file was auto-generated by Fern from our API Definition.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.SarvamModelIds = void 0;
5
- /** Supported chat completion model IDs. Primary models: `sarvam-30b`, `sarvam-105b`. Legacy: `sarvam-m` (24B); prefer Sarvam-30B or Sarvam-105B for new integrations. */
5
+ /** Supported chat completion model IDs: `sarvam-30b`, `sarvam-105b`. */
6
6
  exports.SarvamModelIds = {
7
7
  Sarvam105B: "sarvam-105b",
8
8
  Sarvam30B: "sarvam-30b",
9
- SarvamM: "sarvam-m",
10
9
  };