sarvamai 1.1.10 → 1.1.11-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 (204) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/Client.d.ts +6 -3
  3. package/dist/cjs/Client.js +34 -29
  4. package/dist/cjs/api/errors/BadGatewayError.d.ts +5 -0
  5. package/dist/cjs/api/errors/BadGatewayError.js +54 -0
  6. package/dist/cjs/api/errors/index.d.ts +1 -0
  7. package/dist/cjs/api/errors/index.js +1 -0
  8. package/dist/cjs/api/resources/chat/client/Client.d.ts +15 -0
  9. package/dist/cjs/api/resources/chat/client/Client.js +106 -0
  10. package/dist/cjs/api/resources/chat/client/requests/ChatCompletionsRequest.d.ts +0 -2
  11. package/dist/cjs/api/resources/{openSourceModels → chat}/client/requests/CreateChatCompletionV2Request.d.ts +17 -13
  12. package/dist/cjs/api/resources/chat/client/requests/index.d.ts +1 -0
  13. package/dist/cjs/api/resources/chatCompletion/client/Client.d.ts +37 -0
  14. package/dist/cjs/api/resources/{openSourceModels → chatCompletion}/client/Client.js +8 -85
  15. package/dist/cjs/api/resources/chatCompletion/exports.d.ts +2 -0
  16. package/dist/cjs/api/resources/{openSourceModels → chatCompletion}/exports.js +2 -2
  17. package/dist/cjs/api/resources/index.d.ts +3 -2
  18. package/dist/cjs/api/resources/index.js +4 -3
  19. package/dist/cjs/api/resources/responses/client/Client.d.ts +42 -0
  20. package/dist/cjs/api/resources/responses/client/Client.js +142 -0
  21. package/dist/cjs/api/resources/responses/client/requests/CreateResponseV2Request.d.ts +60 -0
  22. package/dist/cjs/api/resources/responses/client/requests/index.d.ts +1 -0
  23. package/dist/cjs/api/resources/responses/client/requests/index.js +2 -0
  24. package/dist/cjs/api/resources/responses/exports.d.ts +2 -0
  25. package/dist/cjs/api/resources/responses/exports.js +21 -0
  26. package/dist/cjs/api/resources/responses/index.d.ts +1 -0
  27. package/dist/cjs/api/resources/responses/index.js +17 -0
  28. package/dist/cjs/api/resources/speechToTextRealtimeStreaming/types/SpeechToTextRealtimeStreamingLanguageCode.d.ts +1 -1
  29. package/dist/cjs/api/resources/speechToTextRealtimeStreaming/types/SpeechToTextRealtimeStreamingLanguageCode.js +1 -1
  30. package/dist/cjs/api/resources/speechToTextRealtimeStreaming/types/SpeechToTextRealtimeStreamingModel.d.ts +2 -2
  31. package/dist/cjs/api/resources/speechToTextRealtimeStreaming/types/SpeechToTextRealtimeStreamingModel.js +2 -2
  32. package/dist/cjs/api/types/ChatCompletionRequestDeveloperMessage.d.ts +6 -0
  33. package/dist/cjs/api/types/ChatCompletionRequestDeveloperMessage.js +3 -0
  34. package/dist/cjs/api/types/ChatCompletionRequestGenericMessage.d.ts +2 -2
  35. package/dist/cjs/api/types/ChatCompletionRequestMessage.d.ts +1 -1
  36. package/dist/cjs/api/types/ChatCompletionRequestUserMessage.d.ts +2 -2
  37. package/dist/cjs/api/types/ChatCompletionResponseMessage.d.ts +11 -1
  38. package/dist/cjs/api/types/ChatCompletionResponseMessage.js +11 -0
  39. package/dist/cjs/api/types/ChatStreamOptions.d.ts +4 -0
  40. package/dist/cjs/api/types/ChatStreamOptions.js +3 -0
  41. package/dist/cjs/api/types/CompletionTokensDetails.d.ts +6 -0
  42. package/dist/cjs/api/types/CompletionTokensDetails.js +3 -0
  43. package/dist/cjs/api/types/CompletionUsage.d.ts +2 -1
  44. package/dist/cjs/api/types/CreateResponseV2Response.d.ts +19 -0
  45. package/dist/cjs/api/types/CreateResponseV2Response.js +3 -0
  46. package/dist/cjs/api/types/ReasoningEffort.d.ts +5 -0
  47. package/dist/cjs/api/types/ReasoningEffort.js +5 -0
  48. package/dist/cjs/api/types/ResponseFunctionTool.d.ts +12 -0
  49. package/dist/cjs/api/types/ResponseFunctionTool.js +3 -0
  50. package/dist/cjs/api/types/ResponseIncompleteDetails.d.ts +6 -0
  51. package/dist/cjs/api/types/ResponseIncompleteDetails.js +3 -0
  52. package/dist/cjs/api/types/ResponseInputContentPart.d.ts +5 -0
  53. package/dist/cjs/api/types/ResponseInputContentPart.js +3 -0
  54. package/dist/cjs/api/types/ResponseInputImagePart.d.ts +15 -0
  55. package/dist/cjs/api/types/ResponseInputImagePart.js +12 -0
  56. package/dist/cjs/api/types/ResponseInputItem.d.ts +5 -0
  57. package/dist/cjs/api/types/ResponseInputItem.js +3 -0
  58. package/dist/cjs/api/types/ResponseInputMessage.d.ts +25 -0
  59. package/dist/cjs/api/types/ResponseInputMessage.js +14 -0
  60. package/dist/cjs/api/types/ResponseInputTextPart.d.ts +12 -0
  61. package/dist/cjs/api/types/ResponseInputTextPart.js +12 -0
  62. package/dist/cjs/api/types/ResponseOutputItem.d.ts +5 -0
  63. package/dist/cjs/api/types/ResponseOutputItem.js +3 -0
  64. package/dist/cjs/api/types/ResponseOutputMessage.d.ts +11 -0
  65. package/dist/cjs/api/types/ResponseOutputMessage.js +3 -0
  66. package/dist/cjs/api/types/ResponseOutputTextPart.d.ts +6 -0
  67. package/dist/cjs/api/types/ResponseOutputTextPart.js +3 -0
  68. package/dist/cjs/api/types/ResponsePassThroughItem.d.ts +9 -0
  69. package/dist/cjs/api/types/ResponsePassThroughItem.js +3 -0
  70. package/dist/cjs/api/types/ResponseReasoning.d.ts +16 -0
  71. package/dist/cjs/api/types/ResponseReasoning.js +11 -0
  72. package/dist/cjs/api/types/ResponseReasoningEffort.d.ts +10 -0
  73. package/dist/cjs/api/types/ResponseReasoningEffort.js +13 -0
  74. package/dist/cjs/api/types/ResponseTextConfig.d.ts +6 -0
  75. package/dist/cjs/api/types/ResponseTextConfig.js +3 -0
  76. package/dist/cjs/api/types/ResponseTextFormat.d.ts +19 -0
  77. package/dist/cjs/api/types/ResponseTextFormat.js +12 -0
  78. package/dist/cjs/api/types/ResponseUsage.d.ts +17 -0
  79. package/dist/cjs/api/types/ResponseUsage.js +3 -0
  80. package/dist/cjs/api/types/V2ErrorObject.d.ts +12 -0
  81. package/dist/cjs/api/types/V2ErrorObject.js +3 -0
  82. package/dist/cjs/api/types/V2ErrorResponse.d.ts +4 -0
  83. package/dist/cjs/api/types/V2ErrorResponse.js +3 -0
  84. package/dist/cjs/api/types/V2ModelIds.d.ts +5 -9
  85. package/dist/cjs/api/types/V2ModelIds.js +5 -9
  86. package/dist/cjs/api/types/index.d.ts +22 -1
  87. package/dist/cjs/api/types/index.js +22 -1
  88. package/dist/cjs/version.d.ts +1 -1
  89. package/dist/cjs/version.js +1 -1
  90. package/dist/esm/BaseClient.mjs +2 -2
  91. package/dist/esm/Client.d.mts +6 -3
  92. package/dist/esm/Client.mjs +8 -3
  93. package/dist/esm/api/errors/BadGatewayError.d.mts +5 -0
  94. package/dist/esm/api/errors/BadGatewayError.mjs +17 -0
  95. package/dist/esm/api/errors/index.d.mts +1 -0
  96. package/dist/esm/api/errors/index.mjs +1 -0
  97. package/dist/esm/api/resources/chat/client/Client.d.mts +15 -0
  98. package/dist/esm/api/resources/chat/client/Client.mjs +106 -0
  99. package/dist/esm/api/resources/chat/client/requests/ChatCompletionsRequest.d.mts +0 -2
  100. package/dist/esm/api/resources/{openSourceModels → chat}/client/requests/CreateChatCompletionV2Request.d.mts +17 -13
  101. package/dist/esm/api/resources/chat/client/requests/index.d.mts +1 -0
  102. package/dist/esm/api/resources/chatCompletion/client/Client.d.mts +37 -0
  103. package/dist/esm/api/resources/{openSourceModels → chatCompletion}/client/Client.mjs +6 -83
  104. package/dist/esm/api/resources/chatCompletion/client/index.d.mts +1 -0
  105. package/dist/esm/api/resources/chatCompletion/client/index.mjs +1 -0
  106. package/dist/esm/api/resources/chatCompletion/exports.d.mts +2 -0
  107. package/dist/esm/api/resources/{openSourceModels → chatCompletion}/exports.mjs +1 -1
  108. package/dist/esm/api/resources/index.d.mts +3 -2
  109. package/dist/esm/api/resources/index.mjs +3 -2
  110. package/dist/esm/api/resources/responses/client/Client.d.mts +42 -0
  111. package/dist/esm/api/resources/responses/client/Client.mjs +105 -0
  112. package/dist/esm/api/resources/responses/client/requests/CreateResponseV2Request.d.mts +60 -0
  113. package/dist/esm/api/resources/responses/client/requests/index.d.mts +1 -0
  114. package/dist/esm/api/resources/responses/client/requests/index.mjs +1 -0
  115. package/dist/esm/api/resources/responses/exports.d.mts +2 -0
  116. package/dist/esm/api/resources/responses/exports.mjs +3 -0
  117. package/dist/esm/api/resources/responses/index.d.mts +1 -0
  118. package/dist/esm/api/resources/responses/index.mjs +1 -0
  119. package/dist/esm/api/resources/speechToTextRealtimeStreaming/types/SpeechToTextRealtimeStreamingLanguageCode.d.mts +1 -1
  120. package/dist/esm/api/resources/speechToTextRealtimeStreaming/types/SpeechToTextRealtimeStreamingLanguageCode.mjs +1 -1
  121. package/dist/esm/api/resources/speechToTextRealtimeStreaming/types/SpeechToTextRealtimeStreamingModel.d.mts +2 -2
  122. package/dist/esm/api/resources/speechToTextRealtimeStreaming/types/SpeechToTextRealtimeStreamingModel.mjs +2 -2
  123. package/dist/esm/api/types/ChatCompletionRequestDeveloperMessage.d.mts +6 -0
  124. package/dist/esm/api/types/ChatCompletionRequestDeveloperMessage.mjs +2 -0
  125. package/dist/esm/api/types/ChatCompletionRequestGenericMessage.d.mts +2 -2
  126. package/dist/esm/api/types/ChatCompletionRequestMessage.d.mts +1 -1
  127. package/dist/esm/api/types/ChatCompletionRequestUserMessage.d.mts +2 -2
  128. package/dist/esm/api/types/ChatCompletionResponseMessage.d.mts +11 -1
  129. package/dist/esm/api/types/ChatCompletionResponseMessage.mjs +10 -1
  130. package/dist/esm/api/types/ChatStreamOptions.d.mts +4 -0
  131. package/dist/esm/api/types/ChatStreamOptions.mjs +2 -0
  132. package/dist/esm/api/types/CompletionTokensDetails.d.mts +6 -0
  133. package/dist/esm/api/types/CompletionTokensDetails.mjs +2 -0
  134. package/dist/esm/api/types/CompletionUsage.d.mts +2 -1
  135. package/dist/esm/api/types/CreateResponseV2Response.d.mts +19 -0
  136. package/dist/esm/api/types/CreateResponseV2Response.mjs +2 -0
  137. package/dist/esm/api/types/ReasoningEffort.d.mts +5 -0
  138. package/dist/esm/api/types/ReasoningEffort.mjs +5 -0
  139. package/dist/esm/api/types/ResponseFunctionTool.d.mts +12 -0
  140. package/dist/esm/api/types/ResponseFunctionTool.mjs +2 -0
  141. package/dist/esm/api/types/ResponseIncompleteDetails.d.mts +6 -0
  142. package/dist/esm/api/types/ResponseIncompleteDetails.mjs +2 -0
  143. package/dist/esm/api/types/ResponseInputContentPart.d.mts +5 -0
  144. package/dist/esm/api/types/ResponseInputContentPart.mjs +2 -0
  145. package/dist/esm/api/types/ResponseInputImagePart.d.mts +15 -0
  146. package/dist/esm/api/types/ResponseInputImagePart.mjs +9 -0
  147. package/dist/esm/api/types/ResponseInputItem.d.mts +5 -0
  148. package/dist/esm/api/types/ResponseInputItem.mjs +2 -0
  149. package/dist/esm/api/types/ResponseInputMessage.d.mts +25 -0
  150. package/dist/esm/api/types/ResponseInputMessage.mjs +11 -0
  151. package/dist/esm/api/types/ResponseInputTextPart.d.mts +12 -0
  152. package/dist/esm/api/types/ResponseInputTextPart.mjs +9 -0
  153. package/dist/esm/api/types/ResponseOutputItem.d.mts +5 -0
  154. package/dist/esm/api/types/ResponseOutputItem.mjs +2 -0
  155. package/dist/esm/api/types/ResponseOutputMessage.d.mts +11 -0
  156. package/dist/esm/api/types/ResponseOutputMessage.mjs +2 -0
  157. package/dist/esm/api/types/ResponseOutputTextPart.d.mts +6 -0
  158. package/dist/esm/api/types/ResponseOutputTextPart.mjs +2 -0
  159. package/dist/esm/api/types/ResponsePassThroughItem.d.mts +9 -0
  160. package/dist/esm/api/types/ResponsePassThroughItem.mjs +2 -0
  161. package/dist/esm/api/types/ResponseReasoning.d.mts +16 -0
  162. package/dist/esm/api/types/ResponseReasoning.mjs +8 -0
  163. package/dist/esm/api/types/ResponseReasoningEffort.d.mts +10 -0
  164. package/dist/esm/api/types/ResponseReasoningEffort.mjs +10 -0
  165. package/dist/esm/api/types/ResponseTextConfig.d.mts +6 -0
  166. package/dist/esm/api/types/ResponseTextConfig.mjs +2 -0
  167. package/dist/esm/api/types/ResponseTextFormat.d.mts +19 -0
  168. package/dist/esm/api/types/ResponseTextFormat.mjs +9 -0
  169. package/dist/esm/api/types/ResponseUsage.d.mts +17 -0
  170. package/dist/esm/api/types/ResponseUsage.mjs +2 -0
  171. package/dist/esm/api/types/V2ErrorObject.d.mts +12 -0
  172. package/dist/esm/api/types/V2ErrorObject.mjs +2 -0
  173. package/dist/esm/api/types/V2ErrorResponse.d.mts +4 -0
  174. package/dist/esm/api/types/V2ErrorResponse.mjs +2 -0
  175. package/dist/esm/api/types/V2ModelIds.d.mts +5 -9
  176. package/dist/esm/api/types/V2ModelIds.mjs +5 -9
  177. package/dist/esm/api/types/index.d.mts +22 -1
  178. package/dist/esm/api/types/index.mjs +22 -1
  179. package/dist/esm/version.d.mts +1 -1
  180. package/dist/esm/version.mjs +1 -1
  181. package/package.json +20 -8
  182. package/reference.md +91 -19
  183. package/dist/cjs/api/resources/openSourceModels/client/Client.d.ts +0 -63
  184. package/dist/cjs/api/resources/openSourceModels/client/requests/index.d.ts +0 -1
  185. package/dist/cjs/api/resources/openSourceModels/exports.d.ts +0 -2
  186. package/dist/cjs/api/types/Role.d.ts +0 -1
  187. package/dist/esm/api/resources/openSourceModels/client/Client.d.mts +0 -63
  188. package/dist/esm/api/resources/openSourceModels/client/requests/index.d.mts +0 -1
  189. package/dist/esm/api/resources/openSourceModels/exports.d.mts +0 -2
  190. package/dist/esm/api/types/Role.d.mts +0 -1
  191. /package/dist/cjs/api/resources/{openSourceModels → chat}/client/requests/CreateChatCompletionV2Request.js +0 -0
  192. /package/dist/{esm/api/resources/openSourceModels/client/requests/index.mjs → cjs/api/resources/chatCompletion/client/index.d.ts} +0 -0
  193. /package/dist/cjs/api/resources/{openSourceModels/client/requests → chatCompletion/client}/index.js +0 -0
  194. /package/dist/cjs/api/resources/{openSourceModels → chatCompletion}/index.d.ts +0 -0
  195. /package/dist/cjs/api/resources/{openSourceModels → chatCompletion}/index.js +0 -0
  196. /package/dist/cjs/api/resources/{openSourceModels → responses}/client/index.d.ts +0 -0
  197. /package/dist/cjs/api/resources/{openSourceModels → responses}/client/index.js +0 -0
  198. /package/dist/cjs/api/{types/Role.js → resources/responses/client/requests/CreateResponseV2Request.js} +0 -0
  199. /package/dist/esm/api/resources/{openSourceModels → chat}/client/requests/CreateChatCompletionV2Request.mjs +0 -0
  200. /package/dist/esm/api/resources/{openSourceModels → chatCompletion}/index.d.mts +0 -0
  201. /package/dist/esm/api/resources/{openSourceModels → chatCompletion}/index.mjs +0 -0
  202. /package/dist/esm/api/resources/{openSourceModels → responses}/client/index.d.mts +0 -0
  203. /package/dist/esm/api/resources/{openSourceModels → responses}/client/index.mjs +0 -0
  204. /package/dist/esm/api/{types/Role.mjs → resources/responses/client/requests/CreateResponseV2Request.mjs} +0 -0
@@ -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.10",
47
- "User-Agent": "sarvamai/1.1.10",
46
+ "X-Fern-SDK-Version": "1.1.11-alpha.2",
47
+ "User-Agent": "sarvamai/1.1.11-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);
@@ -1,10 +1,11 @@
1
1
  import { ChatClient } from "./api/resources/chat/client/Client.js";
2
+ import { ChatCompletionClient } from "./api/resources/chatCompletion/client/Client.js";
2
3
  import { DocAiClient } from "./api/resources/docAi/client/Client.js";
3
4
  import { DocumentIntelligenceClient } from "./api/resources/documentIntelligence/client/Client.js";
4
5
  import { DocumentTranslationClient } from "./api/resources/documentTranslation/client/Client.js";
5
6
  import { DubbingClient } from "./api/resources/dubbing/client/Client.js";
6
- import { OpenSourceModelsClient } from "./api/resources/openSourceModels/client/Client.js";
7
7
  import { PronunciationDictionaryClient } from "./api/resources/pronunciationDictionary/client/Client.js";
8
+ import { ResponsesClient } from "./api/resources/responses/client/Client.js";
8
9
  import { SpeechToTextClient } from "./api/resources/speechToText/client/Client.js";
9
10
  import { SpeechToTextJobClient } from "./api/resources/speechToTextJob/client/Client.js";
10
11
  import { SpeechToTextRealtimeStreamingClient } from "./api/resources/speechToTextRealtimeStreaming/client/Client.js";
@@ -34,7 +35,8 @@ export declare class SarvamAIClient {
34
35
  protected _speechToTextTranslateJob: SpeechToTextTranslateJobClient | undefined;
35
36
  protected _documentIntelligence: DocumentIntelligenceClient | undefined;
36
37
  protected _docAi: DocAiClient | undefined;
37
- protected _openSourceModels: OpenSourceModelsClient | undefined;
38
+ protected _responses: ResponsesClient | undefined;
39
+ protected _chatCompletion: ChatCompletionClient | undefined;
38
40
  protected _speechToTextStreaming: SpeechToTextStreamingClient | undefined;
39
41
  protected _speechToTextTranslateStreaming: SpeechToTextTranslateStreamingClient | undefined;
40
42
  protected _speechToTextRealtimeStreaming: SpeechToTextRealtimeStreamingClient | undefined;
@@ -51,7 +53,8 @@ export declare class SarvamAIClient {
51
53
  get speechToTextTranslateJob(): SpeechToTextTranslateJobClient;
52
54
  get documentIntelligence(): DocumentIntelligenceClient;
53
55
  get docAi(): DocAiClient;
54
- get openSourceModels(): OpenSourceModelsClient;
56
+ get responses(): ResponsesClient;
57
+ get chatCompletion(): ChatCompletionClient;
55
58
  get speechToTextStreaming(): SpeechToTextStreamingClient;
56
59
  get speechToTextTranslateStreaming(): SpeechToTextTranslateStreamingClient;
57
60
  get speechToTextRealtimeStreaming(): SpeechToTextRealtimeStreamingClient;
@@ -3,21 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.SarvamAIClient = void 0;
5
5
  const Client_js_1 = require("./api/resources/chat/client/Client.js");
6
- const Client_js_2 = require("./api/resources/docAi/client/Client.js");
7
- const Client_js_3 = require("./api/resources/documentIntelligence/client/Client.js");
8
- const Client_js_4 = require("./api/resources/documentTranslation/client/Client.js");
9
- const Client_js_5 = require("./api/resources/dubbing/client/Client.js");
10
- const Client_js_6 = require("./api/resources/openSourceModels/client/Client.js");
6
+ const Client_js_2 = require("./api/resources/chatCompletion/client/Client.js");
7
+ const Client_js_3 = require("./api/resources/docAi/client/Client.js");
8
+ const Client_js_4 = require("./api/resources/documentIntelligence/client/Client.js");
9
+ const Client_js_5 = require("./api/resources/documentTranslation/client/Client.js");
10
+ const Client_js_6 = require("./api/resources/dubbing/client/Client.js");
11
11
  const Client_js_7 = require("./api/resources/pronunciationDictionary/client/Client.js");
12
- const Client_js_8 = require("./api/resources/speechToText/client/Client.js");
13
- const Client_js_9 = require("./api/resources/speechToTextJob/client/Client.js");
14
- const Client_js_10 = require("./api/resources/speechToTextRealtimeStreaming/client/Client.js");
15
- const Client_js_11 = require("./api/resources/speechToTextStreaming/client/Client.js");
16
- const Client_js_12 = require("./api/resources/speechToTextTranslateJob/client/Client.js");
17
- const Client_js_13 = require("./api/resources/speechToTextTranslateStreaming/client/Client.js");
18
- const Client_js_14 = require("./api/resources/text/client/Client.js");
19
- const Client_js_15 = require("./api/resources/textToSpeech/client/Client.js");
20
- const Client_js_16 = require("./api/resources/textToSpeechStreaming/client/Client.js");
12
+ const Client_js_8 = require("./api/resources/responses/client/Client.js");
13
+ const Client_js_9 = require("./api/resources/speechToText/client/Client.js");
14
+ const Client_js_10 = require("./api/resources/speechToTextJob/client/Client.js");
15
+ const Client_js_11 = require("./api/resources/speechToTextRealtimeStreaming/client/Client.js");
16
+ const Client_js_12 = require("./api/resources/speechToTextStreaming/client/Client.js");
17
+ const Client_js_13 = require("./api/resources/speechToTextTranslateJob/client/Client.js");
18
+ const Client_js_14 = require("./api/resources/speechToTextTranslateStreaming/client/Client.js");
19
+ const Client_js_15 = require("./api/resources/text/client/Client.js");
20
+ const Client_js_16 = require("./api/resources/textToSpeech/client/Client.js");
21
+ const Client_js_17 = require("./api/resources/textToSpeechStreaming/client/Client.js");
21
22
  const BaseClient_js_1 = require("./BaseClient.js");
22
23
  class SarvamAIClient {
23
24
  constructor(options = {}) {
@@ -25,23 +26,23 @@ class SarvamAIClient {
25
26
  }
26
27
  get dubbing() {
27
28
  var _a;
28
- return ((_a = this._dubbing) !== null && _a !== void 0 ? _a : (this._dubbing = new Client_js_5.DubbingClient(this._options)));
29
+ return ((_a = this._dubbing) !== null && _a !== void 0 ? _a : (this._dubbing = new Client_js_6.DubbingClient(this._options)));
29
30
  }
30
31
  get documentTranslation() {
31
32
  var _a;
32
- return ((_a = this._documentTranslation) !== null && _a !== void 0 ? _a : (this._documentTranslation = new Client_js_4.DocumentTranslationClient(this._options)));
33
+ return ((_a = this._documentTranslation) !== null && _a !== void 0 ? _a : (this._documentTranslation = new Client_js_5.DocumentTranslationClient(this._options)));
33
34
  }
34
35
  get text() {
35
36
  var _a;
36
- return ((_a = this._text) !== null && _a !== void 0 ? _a : (this._text = new Client_js_14.TextClient(this._options)));
37
+ return ((_a = this._text) !== null && _a !== void 0 ? _a : (this._text = new Client_js_15.TextClient(this._options)));
37
38
  }
38
39
  get speechToText() {
39
40
  var _a;
40
- return ((_a = this._speechToText) !== null && _a !== void 0 ? _a : (this._speechToText = new Client_js_8.SpeechToTextClient(this._options)));
41
+ return ((_a = this._speechToText) !== null && _a !== void 0 ? _a : (this._speechToText = new Client_js_9.SpeechToTextClient(this._options)));
41
42
  }
42
43
  get textToSpeech() {
43
44
  var _a;
44
- return ((_a = this._textToSpeech) !== null && _a !== void 0 ? _a : (this._textToSpeech = new Client_js_15.TextToSpeechClient(this._options)));
45
+ return ((_a = this._textToSpeech) !== null && _a !== void 0 ? _a : (this._textToSpeech = new Client_js_16.TextToSpeechClient(this._options)));
45
46
  }
46
47
  get pronunciationDictionary() {
47
48
  var _a;
@@ -53,39 +54,43 @@ class SarvamAIClient {
53
54
  }
54
55
  get speechToTextJob() {
55
56
  var _a;
56
- return ((_a = this._speechToTextJob) !== null && _a !== void 0 ? _a : (this._speechToTextJob = new Client_js_9.SpeechToTextJobClient(this._options)));
57
+ return ((_a = this._speechToTextJob) !== null && _a !== void 0 ? _a : (this._speechToTextJob = new Client_js_10.SpeechToTextJobClient(this._options)));
57
58
  }
58
59
  get speechToTextTranslateJob() {
59
60
  var _a;
60
- return ((_a = this._speechToTextTranslateJob) !== null && _a !== void 0 ? _a : (this._speechToTextTranslateJob = new Client_js_12.SpeechToTextTranslateJobClient(this._options)));
61
+ return ((_a = this._speechToTextTranslateJob) !== null && _a !== void 0 ? _a : (this._speechToTextTranslateJob = new Client_js_13.SpeechToTextTranslateJobClient(this._options)));
61
62
  }
62
63
  get documentIntelligence() {
63
64
  var _a;
64
- return ((_a = this._documentIntelligence) !== null && _a !== void 0 ? _a : (this._documentIntelligence = new Client_js_3.DocumentIntelligenceClient(this._options)));
65
+ return ((_a = this._documentIntelligence) !== null && _a !== void 0 ? _a : (this._documentIntelligence = new Client_js_4.DocumentIntelligenceClient(this._options)));
65
66
  }
66
67
  get docAi() {
67
68
  var _a;
68
- return ((_a = this._docAi) !== null && _a !== void 0 ? _a : (this._docAi = new Client_js_2.DocAiClient(this._options)));
69
+ return ((_a = this._docAi) !== null && _a !== void 0 ? _a : (this._docAi = new Client_js_3.DocAiClient(this._options)));
69
70
  }
70
- get openSourceModels() {
71
+ get responses() {
71
72
  var _a;
72
- return ((_a = this._openSourceModels) !== null && _a !== void 0 ? _a : (this._openSourceModels = new Client_js_6.OpenSourceModelsClient(this._options)));
73
+ return ((_a = this._responses) !== null && _a !== void 0 ? _a : (this._responses = new Client_js_8.ResponsesClient(this._options)));
74
+ }
75
+ get chatCompletion() {
76
+ var _a;
77
+ return ((_a = this._chatCompletion) !== null && _a !== void 0 ? _a : (this._chatCompletion = new Client_js_2.ChatCompletionClient(this._options)));
73
78
  }
74
79
  get speechToTextStreaming() {
75
80
  var _a;
76
- return ((_a = this._speechToTextStreaming) !== null && _a !== void 0 ? _a : (this._speechToTextStreaming = new Client_js_11.SpeechToTextStreamingClient(this._options)));
81
+ return ((_a = this._speechToTextStreaming) !== null && _a !== void 0 ? _a : (this._speechToTextStreaming = new Client_js_12.SpeechToTextStreamingClient(this._options)));
77
82
  }
78
83
  get speechToTextTranslateStreaming() {
79
84
  var _a;
80
- return ((_a = this._speechToTextTranslateStreaming) !== null && _a !== void 0 ? _a : (this._speechToTextTranslateStreaming = new Client_js_13.SpeechToTextTranslateStreamingClient(this._options)));
85
+ return ((_a = this._speechToTextTranslateStreaming) !== null && _a !== void 0 ? _a : (this._speechToTextTranslateStreaming = new Client_js_14.SpeechToTextTranslateStreamingClient(this._options)));
81
86
  }
82
87
  get speechToTextRealtimeStreaming() {
83
88
  var _a;
84
- return ((_a = this._speechToTextRealtimeStreaming) !== null && _a !== void 0 ? _a : (this._speechToTextRealtimeStreaming = new Client_js_10.SpeechToTextRealtimeStreamingClient(this._options)));
89
+ return ((_a = this._speechToTextRealtimeStreaming) !== null && _a !== void 0 ? _a : (this._speechToTextRealtimeStreaming = new Client_js_11.SpeechToTextRealtimeStreamingClient(this._options)));
85
90
  }
86
91
  get textToSpeechStreaming() {
87
92
  var _a;
88
- return ((_a = this._textToSpeechStreaming) !== null && _a !== void 0 ? _a : (this._textToSpeechStreaming = new Client_js_16.TextToSpeechStreamingClient(this._options)));
93
+ return ((_a = this._textToSpeechStreaming) !== null && _a !== void 0 ? _a : (this._textToSpeechStreaming = new Client_js_17.TextToSpeechStreamingClient(this._options)));
89
94
  }
90
95
  }
91
96
  exports.SarvamAIClient = SarvamAIClient;
@@ -0,0 +1,5 @@
1
+ import type * as core from "../../core/index.js";
2
+ import * as errors from "../../errors/index.js";
3
+ export declare class BadGatewayError extends errors.SarvamAIError {
4
+ constructor(body?: unknown, rawResponse?: core.RawResponse);
5
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.BadGatewayError = void 0;
38
+ const errors = __importStar(require("../../errors/index.js"));
39
+ class BadGatewayError extends errors.SarvamAIError {
40
+ constructor(body, rawResponse) {
41
+ super({
42
+ message: "BadGatewayError",
43
+ statusCode: 502,
44
+ body: body,
45
+ rawResponse: rawResponse,
46
+ });
47
+ Object.setPrototypeOf(this, new.target.prototype);
48
+ if (Error.captureStackTrace) {
49
+ Error.captureStackTrace(this, this.constructor);
50
+ }
51
+ this.name = this.constructor.name;
52
+ }
53
+ }
54
+ exports.BadGatewayError = BadGatewayError;
@@ -1,3 +1,4 @@
1
+ export * from "./BadGatewayError.js";
1
2
  export * from "./BadRequestError.js";
2
3
  export * from "./ConflictError.js";
3
4
  export * from "./ContentTooLargeError.js";
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./BadGatewayError.js"), exports);
17
18
  __exportStar(require("./BadRequestError.js"), exports);
18
19
  __exportStar(require("./ConflictError.js"), exports);
19
20
  __exportStar(require("./ContentTooLargeError.js"), exports);
@@ -64,6 +64,21 @@ export declare class ChatClient {
64
64
  stream?: false | undefined;
65
65
  }, requestOptions?: ChatClient.RequestOptions): core.HttpResponsePromise<SarvamAI.CreateChatCompletionResponse>;
66
66
  completions(request: SarvamAI.ChatCompletionsRequest, requestOptions?: ChatClient.RequestOptions): core.HttpResponsePromise<SarvamAI.CreateChatCompletionResponse> | Promise<AsyncIterable<ChatCompletionChunk>>;
67
+ /**
68
+ * Create a V2 chat completion. Supports both streaming and non-streaming modes.
69
+ *
70
+ * @param {SarvamAI.CreateChatCompletionV2Request} request
71
+ * @param {ChatClient.RequestOptions} requestOptions - Request-specific configuration.
72
+ */
73
+ completionsV2(request: SarvamAI.CreateChatCompletionV2Request & {
74
+ stream: true;
75
+ }, requestOptions?: ChatClient.RequestOptions): Promise<AsyncIterable<ChatCompletionChunk>>;
76
+ completionsV2(request: SarvamAI.CreateChatCompletionV2Request & {
77
+ stream?: false | undefined;
78
+ }, requestOptions?: ChatClient.RequestOptions): core.HttpResponsePromise<SarvamAI.CreateChatCompletionV2Response>;
79
+ completionsV2(request: SarvamAI.CreateChatCompletionV2Request, requestOptions?: ChatClient.RequestOptions): core.HttpResponsePromise<SarvamAI.CreateChatCompletionV2Response> | Promise<AsyncIterable<ChatCompletionChunk>>;
80
+ private __completionsV2;
81
+ private __completionsV2Stream;
67
82
  private __completions;
68
83
  private __completionsStream;
69
84
  private _parseSSEStream;
@@ -73,6 +73,106 @@ class ChatClient {
73
73
  }
74
74
  return core.HttpResponsePromise.fromPromise(this.__completions(request, requestOptions));
75
75
  }
76
+ completionsV2(request, requestOptions) {
77
+ if (request.stream === true) {
78
+ return this.__completionsV2Stream(request, requestOptions);
79
+ }
80
+ return core.HttpResponsePromise.fromPromise(this.__completionsV2(request, requestOptions));
81
+ }
82
+ __completionsV2(request, requestOptions) {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
85
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
86
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
87
+ const _response = yield core.fetcher({
88
+ url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SarvamAIEnvironment.Production).base, "v2/chat/completions"),
89
+ method: "POST",
90
+ headers: _headers,
91
+ contentType: "application/json",
92
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
93
+ requestType: "json",
94
+ body: request,
95
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
96
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
97
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
98
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
99
+ logging: this._options.logging,
100
+ });
101
+ if (_response.ok) {
102
+ return {
103
+ data: _response.body,
104
+ rawResponse: _response.rawResponse,
105
+ };
106
+ }
107
+ if (_response.error.reason === "status-code") {
108
+ this._throwStatusCodeError(_response.error.statusCode, _response.error.body, _response.rawResponse);
109
+ }
110
+ switch (_response.error.reason) {
111
+ case "non-json":
112
+ throw new errors.SarvamAIError({
113
+ statusCode: _response.error.statusCode,
114
+ body: _response.error.rawBody,
115
+ rawResponse: _response.rawResponse,
116
+ });
117
+ case "body-is-null":
118
+ throw new errors.SarvamAIError({
119
+ statusCode: _response.error.statusCode,
120
+ rawResponse: _response.rawResponse,
121
+ });
122
+ case "timeout":
123
+ throw new errors.SarvamAITimeoutError("Timeout exceeded when calling POST /v2/chat/completions.");
124
+ case "unknown":
125
+ throw new errors.SarvamAIError({
126
+ message: _response.error.errorMessage,
127
+ rawResponse: _response.rawResponse,
128
+ });
129
+ }
130
+ });
131
+ }
132
+ __completionsV2Stream(request, requestOptions) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ var _a, _b, _c, _d, _e;
135
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
136
+ const _headers = {};
137
+ for (const headers of [_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers]) {
138
+ if (!headers)
139
+ continue;
140
+ for (const [key, value] of Object.entries(headers)) {
141
+ if (value != null) {
142
+ _headers[key] = String(value);
143
+ }
144
+ }
145
+ }
146
+ _headers["Content-Type"] = "application/json";
147
+ _headers["Accept"] = "text/event-stream";
148
+ const baseUrl = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SarvamAIEnvironment.Production).base;
149
+ const url = core.url.join(baseUrl, "v2/chat/completions");
150
+ const fetchFn = (_e = (_d = this._options) === null || _d === void 0 ? void 0 : _d.fetch) !== null && _e !== void 0 ? _e : (typeof fetch !== "undefined" ? fetch : undefined);
151
+ if (!fetchFn) {
152
+ throw new Error("No fetch function available. Please provide a fetch function in client options.");
153
+ }
154
+ const response = yield fetchFn(url, {
155
+ method: "POST",
156
+ headers: _headers,
157
+ body: JSON.stringify(request),
158
+ signal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
159
+ });
160
+ if (!response.ok) {
161
+ let errorBody;
162
+ try {
163
+ errorBody = yield response.json();
164
+ }
165
+ catch (_f) {
166
+ errorBody = yield response.text();
167
+ }
168
+ this._throwStatusCodeError(response.status, errorBody, (0, RawResponse_js_1.toRawResponse)(response));
169
+ }
170
+ if (!response.body) {
171
+ throw new errors.SarvamAIError({ message: "Response body is null for streaming request." });
172
+ }
173
+ return this._parseSSEStream(response.body);
174
+ });
175
+ }
76
176
  __completions(request, requestOptions) {
77
177
  return __awaiter(this, void 0, void 0, function* () {
78
178
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
@@ -239,14 +339,20 @@ class ChatClient {
239
339
  switch (statusCode) {
240
340
  case 400:
241
341
  throw new SarvamAI.BadRequestError(body, rawResponse);
342
+ case 401:
343
+ throw new SarvamAI.UnauthorizedError(body, rawResponse);
242
344
  case 403:
243
345
  throw new SarvamAI.ForbiddenError(body, rawResponse);
346
+ case 413:
347
+ throw new SarvamAI.ContentTooLargeError(body, rawResponse);
244
348
  case 422:
245
349
  throw new SarvamAI.UnprocessableEntityError(body, rawResponse);
246
350
  case 429:
247
351
  throw new SarvamAI.TooManyRequestsError(body, rawResponse);
248
352
  case 500:
249
353
  throw new SarvamAI.InternalServerError(body, rawResponse);
354
+ case 503:
355
+ throw new SarvamAI.ServiceUnavailableError(body, rawResponse);
250
356
  default:
251
357
  throw new errors.SarvamAIError({
252
358
  statusCode,
@@ -58,8 +58,6 @@ export interface ChatCompletionsRequest {
58
58
  * to talk about new topics.
59
59
  */
60
60
  presence_penalty?: number;
61
- /** If set to true, the model response will be wiki grounded. */
62
- wiki_grounding?: boolean;
63
61
  /** A list of tools the model may call. Currently, only functions are supported as a tool. */
64
62
  tools?: SarvamAI.ChatCompletionTool[];
65
63
  /** Controls which (if any) tool is called by the model. */
@@ -6,11 +6,11 @@ import type * as SarvamAI from "../../../../index.js";
6
6
  * role: "user",
7
7
  * content: "Summarise the causes of the 2008 financial crisis."
8
8
  * }],
9
- * model: "glm5.2"
9
+ * model: "glm5.3"
10
10
  * }
11
11
  */
12
12
  export interface CreateChatCompletionV2Request {
13
- /** A list of messages comprising the conversation so far. */
13
+ /** A list of messages comprising the conversation so far. Roles: `system`, `developer`, `user`, `assistant`, `tool`. An assistant message as the last turn is a prior turn, not token-level prefill. */
14
14
  messages: SarvamAI.ChatCompletionRequestMessage[];
15
15
  model: SarvamAI.V2ModelIds;
16
16
  /**
@@ -19,22 +19,16 @@ export interface CreateChatCompletionV2Request {
19
19
  */
20
20
  temperature?: number;
21
21
  /**
22
- * An alternative to sampling with temperature, called nucleus sampling,
23
- * where the model considers the results of the tokens with top_p probability
24
- * mass. So 0.1 means only the tokens comprising the top 10% probability mass
25
- * are considered.
22
+ * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
26
23
  *
27
- * We generally recommend altering this or `temperature` but not both.
24
+ * Must be greater than 0 and at most 1. `0` is invalid; current serving returns `503 model_overloaded` rather than a clean `400`. Prefer altering this or `temperature` but not both.
28
25
  */
29
26
  top_p?: number;
30
- /** The effort to use for reasoning */
27
+ /** Reasoning effort. Chat accepts `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Reasoning models such as `glm5.3` still think when this is unset. `extra_body.chat_template_kwargs.enable_thinking: false` is accepted but currently does not disable `glm5.3` thinking; `low` is the practical way to keep the trace short. */
31
28
  reasoning_effort?: SarvamAI.ReasoningEffort;
32
29
  /** The maximum number of tokens that can be generated in the chat completion. */
33
30
  max_tokens?: number;
34
- /**
35
- * If set to true, the model response data will be streamed to the client
36
- * as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
37
- */
31
+ /** If set to true, the model response data will be streamed to the client as it is generated using server-sent events. The chat stream ends with a `[DONE]` line. Pair with `stream_options.include_usage` to receive a usage chunk (including `reasoning_tokens`). */
38
32
  stream?: boolean;
39
33
  stop?: SarvamAI.StopConfiguration;
40
34
  /** How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. */
@@ -63,6 +57,16 @@ export interface CreateChatCompletionV2Request {
63
57
  tool_choice?: SarvamAI.ToolChoiceOption;
64
58
  /** 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. */
65
59
  response_format?: SarvamAI.ResponseFormat;
66
- /** Extra body to be sent to the model. */
60
+ /** Extra body forwarded to the model. Must not repeat any modelled field and must not carry `stream_options` — a collision is `400`. `chat_template_kwargs.enable_thinking` is accepted; on live `glm5.3` it does not currently turn thinking off. */
67
61
  extra_body?: Record<string, unknown>;
62
+ /** Top-k sampling. `null` or `-1` disables it. `0` is `400`. Values `>= 1` are accepted; there is no enforced cap at 100. */
63
+ top_k?: number;
64
+ /** Minimum probability mass. Must be between 0 and 1 inclusive. Outside that range is `400`. */
65
+ min_p?: number;
66
+ /** Repetition penalty. Must be greater than 0 and at most 2. `0` and values above 2 are `400`. */
67
+ repetition_penalty?: number;
68
+ /** Whether the model may emit more than one tool call in one turn. Accepted. On live `glm5.3`, `false` does not serialize two requested calls into one. */
69
+ parallel_tool_calls?: boolean;
70
+ /** Only valid with `stream: true` (otherwise `400`). Put this at the top level, not inside `extra_body`. */
71
+ stream_options?: SarvamAI.ChatStreamOptions;
68
72
  }
@@ -1 +1,2 @@
1
1
  export type { ChatCompletionsRequest } from "./ChatCompletionsRequest.js";
2
+ export type { CreateChatCompletionV2Request } from "./CreateChatCompletionV2Request.js";
@@ -0,0 +1,37 @@
1
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
3
+ import * as core from "../../../../core/index.js";
4
+ import * as SarvamAI from "../../../index.js";
5
+ export declare namespace ChatCompletionClient {
6
+ type Options = BaseClientOptions;
7
+ interface RequestOptions extends BaseRequestOptions {
8
+ }
9
+ }
10
+ export declare class ChatCompletionClient {
11
+ protected readonly _options: NormalizedClientOptionsWithAuth<ChatCompletionClient.Options>;
12
+ constructor(options?: ChatCompletionClient.Options);
13
+ /**
14
+ * Lists the model IDs this deployment currently serves. A model is only served where its backend is configured, so the list is environment-specific — fetch it rather than hardcoding IDs.
15
+ *
16
+ * @param {ChatCompletionClient.RequestOptions} requestOptions - Request-specific configuration.
17
+ *
18
+ * @example
19
+ * await client.chatCompletion.listModelsV2()
20
+ */
21
+ listModelsV2(requestOptions?: ChatCompletionClient.RequestOptions): core.HttpResponsePromise<SarvamAI.ModelListResponse>;
22
+ private __listModelsV2;
23
+ /**
24
+ * Retrieves one served model by ID.
25
+ *
26
+ * @param {string} model_id - A model ID from `GET /v2/models`, e.g. `glm5.3`.
27
+ * @param {ChatCompletionClient.RequestOptions} requestOptions - Request-specific configuration.
28
+ *
29
+ * @throws {@link SarvamAI.NotFoundError}
30
+ * @throws {@link SarvamAI.UnprocessableEntityError}
31
+ *
32
+ * @example
33
+ * await client.chatCompletion.getModelV2("model_id")
34
+ */
35
+ getModelV2(model_id: string, requestOptions?: ChatCompletionClient.RequestOptions): core.HttpResponsePromise<SarvamAI.ModelObject>;
36
+ private __getModelV2;
37
+ }
@@ -43,7 +43,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  });
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.OpenSourceModelsClient = void 0;
46
+ exports.ChatCompletionClient = void 0;
47
47
  const BaseClient_js_1 = require("../../../../BaseClient.js");
48
48
  const headers_js_1 = require("../../../../core/headers.js");
49
49
  const core = __importStar(require("../../../../core/index.js"));
@@ -51,94 +51,17 @@ const environments = __importStar(require("../../../../environments.js"));
51
51
  const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
52
52
  const errors = __importStar(require("../../../../errors/index.js"));
53
53
  const SarvamAI = __importStar(require("../../../index.js"));
54
- class OpenSourceModelsClient {
54
+ class ChatCompletionClient {
55
55
  constructor(options = {}) {
56
56
  this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
57
57
  }
58
- /**
59
- * Creates a model response for the given chat conversation. OpenAI-compatible request and response shape; differences from OpenAI are called out in the Open-Source Models documentation.
60
- *
61
- * Requires `api-subscription-key`. Keys without beta access to this endpoint receive `400 invalid_request_error` before the model is called. Set `"stream": true` to receive the reply incrementally as server-sent events. Reasoning models return their chain-of-thought in a separate `reasoning_content` field on the message (`delta.reasoning_content` when streaming); reasoning tokens count against `max_tokens`.
62
- *
63
- * @param {SarvamAI.CreateChatCompletionV2Request} request
64
- * @param {OpenSourceModelsClient.RequestOptions} requestOptions - Request-specific configuration.
65
- *
66
- * @throws {@link SarvamAI.BadRequestError}
67
- * @throws {@link SarvamAI.UnauthorizedError}
68
- * @throws {@link SarvamAI.ForbiddenError}
69
- * @throws {@link SarvamAI.ContentTooLargeError}
70
- * @throws {@link SarvamAI.UnprocessableEntityError}
71
- * @throws {@link SarvamAI.TooManyRequestsError}
72
- *
73
- * @example
74
- * await client.openSourceModels.chatCompletionsV2({
75
- * messages: [{
76
- * role: "user",
77
- * content: "Summarise the causes of the 2008 financial crisis."
78
- * }],
79
- * model: "glm5.2"
80
- * })
81
- */
82
- chatCompletionsV2(request, requestOptions) {
83
- return core.HttpResponsePromise.fromPromise(this.__chatCompletionsV2(request, requestOptions));
84
- }
85
- __chatCompletionsV2(request, requestOptions) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
88
- const _authRequest = yield this._options.authProvider.getAuthRequest();
89
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
90
- const _response = yield core.fetcher({
91
- url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.SarvamAIEnvironment.Production).base, "v2/chat/completions"),
92
- method: "POST",
93
- headers: _headers,
94
- contentType: "application/json",
95
- queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
96
- requestType: "json",
97
- body: request,
98
- timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
99
- maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
100
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
101
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
102
- logging: this._options.logging,
103
- });
104
- if (_response.ok) {
105
- return {
106
- data: _response.body,
107
- rawResponse: _response.rawResponse,
108
- };
109
- }
110
- if (_response.error.reason === "status-code") {
111
- switch (_response.error.statusCode) {
112
- case 400:
113
- throw new SarvamAI.BadRequestError(_response.error.body, _response.rawResponse);
114
- case 401:
115
- throw new SarvamAI.UnauthorizedError(_response.error.body, _response.rawResponse);
116
- case 403:
117
- throw new SarvamAI.ForbiddenError(_response.error.body, _response.rawResponse);
118
- case 413:
119
- throw new SarvamAI.ContentTooLargeError(_response.error.body, _response.rawResponse);
120
- case 422:
121
- throw new SarvamAI.UnprocessableEntityError(_response.error.body, _response.rawResponse);
122
- case 429:
123
- throw new SarvamAI.TooManyRequestsError(_response.error.body, _response.rawResponse);
124
- default:
125
- throw new errors.SarvamAIError({
126
- statusCode: _response.error.statusCode,
127
- body: _response.error.body,
128
- rawResponse: _response.rawResponse,
129
- });
130
- }
131
- }
132
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/v2/chat/completions");
133
- });
134
- }
135
58
  /**
136
59
  * Lists the model IDs this deployment currently serves. A model is only served where its backend is configured, so the list is environment-specific — fetch it rather than hardcoding IDs.
137
60
  *
138
- * @param {OpenSourceModelsClient.RequestOptions} requestOptions - Request-specific configuration.
61
+ * @param {ChatCompletionClient.RequestOptions} requestOptions - Request-specific configuration.
139
62
  *
140
63
  * @example
141
- * await client.openSourceModels.listModelsV2()
64
+ * await client.chatCompletion.listModelsV2()
142
65
  */
143
66
  listModelsV2(requestOptions) {
144
67
  return core.HttpResponsePromise.fromPromise(this.__listModelsV2(requestOptions));
@@ -175,14 +98,14 @@ class OpenSourceModelsClient {
175
98
  /**
176
99
  * Retrieves one served model by ID.
177
100
  *
178
- * @param {string} model_id - A model ID from `GET /v2/models`, e.g. `glm5.2`.
179
- * @param {OpenSourceModelsClient.RequestOptions} requestOptions - Request-specific configuration.
101
+ * @param {string} model_id - A model ID from `GET /v2/models`, e.g. `glm5.3`.
102
+ * @param {ChatCompletionClient.RequestOptions} requestOptions - Request-specific configuration.
180
103
  *
181
104
  * @throws {@link SarvamAI.NotFoundError}
182
105
  * @throws {@link SarvamAI.UnprocessableEntityError}
183
106
  *
184
107
  * @example
185
- * await client.openSourceModels.getModelV2("model_id")
108
+ * await client.chatCompletion.getModelV2("model_id")
186
109
  */
187
110
  getModelV2(model_id, requestOptions) {
188
111
  return core.HttpResponsePromise.fromPromise(this.__getModelV2(model_id, requestOptions));
@@ -224,4 +147,4 @@ class OpenSourceModelsClient {
224
147
  });
225
148
  }
226
149
  }
227
- exports.OpenSourceModelsClient = OpenSourceModelsClient;
150
+ exports.ChatCompletionClient = ChatCompletionClient;