@openrouter/sdk 0.8.0 → 0.9.11

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 (135) hide show
  1. package/esm/funcs/chatSend.d.ts +3 -3
  2. package/esm/funcs/chatSend.js +18 -2
  3. package/esm/lib/config.d.ts +2 -2
  4. package/esm/lib/config.js +2 -2
  5. package/esm/models/assistantmessage.d.ts +47 -36
  6. package/esm/models/assistantmessage.js +35 -47
  7. package/esm/models/assistantmessageimages.d.ts +33 -0
  8. package/esm/models/assistantmessageimages.js +44 -0
  9. package/esm/models/chatgenerationparams.d.ts +453 -126
  10. package/esm/models/chatgenerationparams.js +238 -97
  11. package/esm/models/chatgenerationtokenusage.d.ts +48 -0
  12. package/esm/models/chatmessagecontentitem.d.ts +15 -10
  13. package/esm/models/chatmessagecontentitem.js +25 -4
  14. package/esm/models/chatmessagecontentitemaudio.d.ts +20 -2
  15. package/esm/models/chatmessagecontentitemaudio.js +9 -2
  16. package/esm/models/chatmessagecontentitemcachecontrol.d.ts +14 -3
  17. package/esm/models/chatmessagecontentitemcachecontrol.js +9 -2
  18. package/esm/models/chatmessagecontentitemimage.d.ts +26 -3
  19. package/esm/models/chatmessagecontentitemimage.js +12 -2
  20. package/esm/models/chatmessagecontentitemtext.d.ts +17 -2
  21. package/esm/models/chatmessagecontentitemtext.js +9 -2
  22. package/esm/models/chatmessagecontentitemvideo.d.ts +12 -55
  23. package/esm/models/chatmessagecontentitemvideo.js +5 -72
  24. package/esm/models/chatmessagecontentitemvideolegacy.d.ts +28 -0
  25. package/esm/models/chatmessagecontentitemvideolegacy.js +33 -0
  26. package/esm/models/chatmessagetokenlogprob.d.ts +15 -0
  27. package/esm/models/chatmessagetokenlogprobs.d.ts +9 -0
  28. package/esm/models/chatmessagetoolcall.d.ts +23 -2
  29. package/esm/models/chatmessagetoolcall.js +9 -2
  30. package/esm/models/chatresponse.d.ts +29 -1
  31. package/esm/models/chatresponse.js +6 -1
  32. package/esm/models/chatresponsechoice.d.ts +13 -2
  33. package/esm/models/chatresponsechoice.js +1 -2
  34. package/esm/models/chatstreamingchoice.d.ts +13 -2
  35. package/esm/models/chatstreamingchoice.js +1 -2
  36. package/esm/models/chatstreamingmessagechunk.d.ts +29 -2
  37. package/esm/models/chatstreamingmessagechunk.js +5 -2
  38. package/esm/models/chatstreamingmessagetoolcall.d.ts +38 -1
  39. package/esm/models/chatstreamingmessagetoolcall.js +9 -1
  40. package/esm/models/chatstreamingresponsechunk.d.ts +45 -11
  41. package/esm/models/chatstreamingresponsechunk.js +11 -25
  42. package/esm/models/chatstreamoptions.d.ts +8 -0
  43. package/esm/models/debugoptions.d.ts +18 -0
  44. package/esm/models/debugoptions.js +18 -0
  45. package/esm/models/developermessage.d.ts +12 -0
  46. package/esm/models/errors/index.d.ts +0 -1
  47. package/esm/models/errors/index.js +0 -1
  48. package/esm/models/index.d.ts +12 -8
  49. package/esm/models/index.js +12 -8
  50. package/esm/models/jsonschemaconfig.d.ts +17 -2
  51. package/esm/models/jsonschemaconfig.js +1 -1
  52. package/esm/models/message.d.ts +9 -2
  53. package/esm/models/message.js +1 -1
  54. package/esm/models/modelscountresponse.d.ts +4 -4
  55. package/esm/models/modelscountresponse.js +4 -4
  56. package/esm/models/namedtoolchoice.d.ts +15 -2
  57. package/esm/models/namedtoolchoice.js +6 -1
  58. package/esm/models/openairesponsesreasoningconfig.d.ts +1 -1
  59. package/esm/models/openairesponsesreasoningconfig.js +1 -1
  60. package/esm/models/openresponsesnonstreamingresponse.d.ts +4 -4
  61. package/esm/models/openresponsesnonstreamingresponse.js +3 -3
  62. package/esm/models/openresponsesreasoning.d.ts +2 -2
  63. package/esm/models/openresponsesreasoning.js +1 -1
  64. package/esm/models/openresponsesreasoningconfig.d.ts +2 -2
  65. package/esm/models/openresponsesreasoningconfig.js +1 -1
  66. package/esm/models/openresponsesrequest.d.ts +62 -32
  67. package/esm/models/openresponsesrequest.js +61 -36
  68. package/esm/models/operations/createauthkeyscode.d.ts +24 -0
  69. package/esm/models/operations/createauthkeyscode.js +14 -0
  70. package/esm/models/operations/getgeneration.d.ts +2 -0
  71. package/esm/models/operations/getgeneration.js +2 -0
  72. package/esm/models/operations/sendchatcompletionrequest.d.ts +12 -3
  73. package/esm/models/operations/sendchatcompletionrequest.js +20 -2
  74. package/esm/models/providername.d.ts +2 -0
  75. package/esm/models/providername.js +2 -0
  76. package/esm/models/providerpreferences.d.ts +45 -14
  77. package/esm/models/providerpreferences.js +29 -15
  78. package/esm/models/providersort.d.ts +6 -0
  79. package/esm/models/providersort.js +3 -0
  80. package/esm/models/providersortconfig.d.ts +30 -2
  81. package/esm/models/providersortconfig.js +15 -2
  82. package/esm/models/reasoningdetailencrypted.d.ts +42 -0
  83. package/esm/models/reasoningdetailencrypted.js +42 -0
  84. package/esm/models/reasoningdetailsummary.d.ts +42 -0
  85. package/esm/models/reasoningdetailsummary.js +42 -0
  86. package/esm/models/reasoningdetailtext.d.ts +44 -0
  87. package/esm/models/reasoningdetailtext.js +44 -0
  88. package/esm/models/reasoningdetailunion.d.ts +19 -0
  89. package/esm/models/reasoningdetailunion.js +28 -0
  90. package/esm/models/responseformatjsonobject.d.ts +20 -0
  91. package/esm/models/responseformatjsonobject.js +21 -0
  92. package/esm/models/responseformatjsonschema.d.ts +6 -0
  93. package/esm/models/responseformattext.d.ts +15 -0
  94. package/esm/models/responseformattext.js +13 -0
  95. package/esm/models/responseformattextconfig.d.ts +3 -3
  96. package/esm/models/responseformattextconfig.js +3 -3
  97. package/esm/models/responseformattextgrammar.d.ts +6 -0
  98. package/esm/models/responseformattextpython.d.ts +15 -0
  99. package/esm/models/responseformattextpython.js +13 -0
  100. package/esm/models/responseserrorfield.d.ts +4 -4
  101. package/esm/models/responseserrorfield.js +4 -4
  102. package/esm/models/responsesoutputitemreasoning.d.ts +2 -2
  103. package/esm/models/responsesoutputitemreasoning.js +2 -2
  104. package/esm/models/systemmessage.d.ts +12 -0
  105. package/esm/models/toolchoiceoption.d.ts +31 -0
  106. package/esm/models/toolchoiceoption.js +32 -0
  107. package/esm/models/tooldefinitionjson.d.ts +38 -4
  108. package/esm/models/tooldefinitionjson.js +14 -2
  109. package/esm/models/toolresponsemessage.d.ts +12 -0
  110. package/esm/models/usermessage.d.ts +12 -0
  111. package/esm/models/videoinput.d.ts +23 -0
  112. package/esm/models/videoinput.js +22 -0
  113. package/esm/sdk/chat.d.ts +1 -1
  114. package/esm/sdk/sdk.d.ts +2 -2
  115. package/esm/sdk/sdk.js +3 -3
  116. package/jsr.json +1 -1
  117. package/package.json +1 -1
  118. package/esm/models/chaterror.d.ts +0 -17
  119. package/esm/models/chaterror.js +0 -25
  120. package/esm/models/errors/chaterror.d.ts +0 -19
  121. package/esm/models/errors/chaterror.js +0 -32
  122. package/esm/models/providersortunion.d.ts +0 -10
  123. package/esm/models/providersortunion.js +0 -13
  124. package/esm/models/responsesformatjsonobject.d.ts +0 -20
  125. package/esm/models/responsesformatjsonobject.js +0 -21
  126. package/esm/models/schema10.d.ts +0 -33
  127. package/esm/models/schema10.js +0 -30
  128. package/esm/models/schema14.d.ts +0 -8
  129. package/esm/models/schema14.js +0 -12
  130. package/esm/models/schema17.d.ts +0 -102
  131. package/esm/models/schema17.js +0 -95
  132. package/esm/models/schema19.d.ts +0 -92
  133. package/esm/models/schema19.js +0 -109
  134. package/esm/models/schema5.d.ts +0 -86
  135. package/esm/models/schema5.js +0 -89
@@ -6,34 +6,58 @@ import * as z from "zod/v4";
6
6
  import { remap as remap$ } from "../lib/primitives.js";
7
7
  import * as openEnums from "../types/enums.js";
8
8
  import { ChatStreamOptions$outboundSchema, } from "./chatstreamoptions.js";
9
+ import { DataCollection$outboundSchema, } from "./datacollection.js";
10
+ import { DebugOptions$outboundSchema, } from "./debugoptions.js";
9
11
  import { Message$outboundSchema, } from "./message.js";
10
- import { ProviderSortUnion$outboundSchema, } from "./providersortunion.js";
11
- import { ReasoningSummaryVerbosity$outboundSchema, } from "./reasoningsummaryverbosity.js";
12
+ import { PDFParserOptions$outboundSchema, } from "./pdfparseroptions.js";
13
+ import { PreferredMaxLatency$outboundSchema, } from "./preferredmaxlatency.js";
14
+ import { PreferredMinThroughput$outboundSchema, } from "./preferredminthroughput.js";
15
+ import { ProviderName$outboundSchema } from "./providername.js";
16
+ import { Quantization$outboundSchema } from "./quantization.js";
17
+ import { ResponseFormatJSONObject$outboundSchema, } from "./responseformatjsonobject.js";
12
18
  import { ResponseFormatJSONSchema$outboundSchema, } from "./responseformatjsonschema.js";
19
+ import { ResponseFormatText$outboundSchema, } from "./responseformattext.js";
13
20
  import { ResponseFormatTextGrammar$outboundSchema, } from "./responseformattextgrammar.js";
14
- import { Schema10$outboundSchema, } from "./schema10.js";
15
- import { Schema17$outboundSchema, } from "./schema17.js";
16
- import { Schema5$outboundSchema, } from "./schema5.js";
21
+ import { ResponseFormatTextPython$outboundSchema, } from "./responseformattextpython.js";
22
+ import { ToolChoiceOption$outboundSchema, } from "./toolchoiceoption.js";
17
23
  import { ToolDefinitionJson$outboundSchema, } from "./tooldefinitionjson.js";
18
- export const Schema3 = {
19
- Deny: "deny",
20
- Allow: "allow",
24
+ import { WebSearchEngine$outboundSchema, } from "./websearchengine.js";
25
+ export const ChatGenerationParamsSortEnum = {
26
+ Price: "price",
27
+ Throughput: "throughput",
28
+ Latency: "latency",
21
29
  };
22
- export const Schema8 = {
23
- Int4: "int4",
24
- Int8: "int8",
25
- Fp4: "fp4",
26
- Fp6: "fp6",
27
- Fp8: "fp8",
28
- Fp16: "fp16",
29
- Bf16: "bf16",
30
- Fp32: "fp32",
31
- Unknown: "unknown",
30
+ export const ChatGenerationParamsProviderSortConfigEnum = {
31
+ Price: "price",
32
+ Throughput: "throughput",
33
+ Latency: "latency",
32
34
  };
33
- export const Route = {
34
- Fallback: "fallback",
35
- Sort: "sort",
35
+ /**
36
+ * The provider sorting strategy (price, throughput, latency)
37
+ */
38
+ export const ChatGenerationParamsBy = {
39
+ Price: "price",
40
+ Throughput: "throughput",
41
+ Latency: "latency",
42
+ };
43
+ /**
44
+ * Partitioning strategy for sorting: "model" (default) groups endpoints by model before sorting (fallback models remain fallbacks), "none" sorts all endpoints together regardless of model.
45
+ */
46
+ export const ChatGenerationParamsPartition = {
47
+ Model: "model",
48
+ None: "none",
36
49
  };
50
+ /**
51
+ * The provider sorting strategy (price, throughput, latency)
52
+ */
53
+ export const ChatGenerationParamsProviderSort = {
54
+ Price: "price",
55
+ Throughput: "throughput",
56
+ Latency: "latency",
57
+ };
58
+ /**
59
+ * Constrains effort on reasoning for reasoning models
60
+ */
37
61
  export const Effort = {
38
62
  Xhigh: "xhigh",
39
63
  High: "high",
@@ -47,43 +71,97 @@ export const Modality = {
47
71
  Image: "image",
48
72
  };
49
73
  /** @internal */
50
- export const Schema3$outboundSchema = openEnums
51
- .outboundSchema(Schema3);
74
+ export const ChatGenerationParamsOrder$outboundSchema = z.union([ProviderName$outboundSchema, z.string()]);
75
+ export function chatGenerationParamsOrderToJSON(chatGenerationParamsOrder) {
76
+ return JSON.stringify(ChatGenerationParamsOrder$outboundSchema.parse(chatGenerationParamsOrder));
77
+ }
78
+ /** @internal */
79
+ export const ChatGenerationParamsOnly$outboundSchema = z.union([ProviderName$outboundSchema, z.string()]);
80
+ export function chatGenerationParamsOnlyToJSON(chatGenerationParamsOnly) {
81
+ return JSON.stringify(ChatGenerationParamsOnly$outboundSchema.parse(chatGenerationParamsOnly));
82
+ }
83
+ /** @internal */
84
+ export const ChatGenerationParamsIgnore$outboundSchema = z.union([ProviderName$outboundSchema, z.string()]);
85
+ export function chatGenerationParamsIgnoreToJSON(chatGenerationParamsIgnore) {
86
+ return JSON.stringify(ChatGenerationParamsIgnore$outboundSchema.parse(chatGenerationParamsIgnore));
87
+ }
88
+ /** @internal */
89
+ export const ChatGenerationParamsSortEnum$outboundSchema = openEnums.outboundSchema(ChatGenerationParamsSortEnum);
90
+ /** @internal */
91
+ export const ChatGenerationParamsProviderSortConfigEnum$outboundSchema = z.enum(ChatGenerationParamsProviderSortConfigEnum);
92
+ /** @internal */
93
+ export const ChatGenerationParamsBy$outboundSchema = openEnums.outboundSchema(ChatGenerationParamsBy);
52
94
  /** @internal */
53
- export const Schema8$outboundSchema = openEnums
54
- .outboundSchema(Schema8);
95
+ export const ChatGenerationParamsPartition$outboundSchema = openEnums.outboundSchema(ChatGenerationParamsPartition);
55
96
  /** @internal */
56
- export const Schema15$outboundSchema = z
57
- .object({
58
- p50: z.nullable(z.number()).optional(),
59
- p75: z.nullable(z.number()).optional(),
60
- p90: z.nullable(z.number()).optional(),
61
- p99: z.nullable(z.number()).optional(),
97
+ export const ChatGenerationParamsProviderSortConfig$outboundSchema = z.object({
98
+ by: z.nullable(ChatGenerationParamsBy$outboundSchema).optional(),
99
+ partition: z.nullable(ChatGenerationParamsPartition$outboundSchema)
100
+ .optional(),
62
101
  });
63
- export function schema15ToJSON(schema15) {
64
- return JSON.stringify(Schema15$outboundSchema.parse(schema15));
102
+ export function chatGenerationParamsProviderSortConfigToJSON(chatGenerationParamsProviderSortConfig) {
103
+ return JSON.stringify(ChatGenerationParamsProviderSortConfig$outboundSchema.parse(chatGenerationParamsProviderSortConfig));
65
104
  }
66
105
  /** @internal */
67
- export const Schema15Union$outboundSchema = z.union([z.number(), z.lazy(() => Schema15$outboundSchema)]);
68
- export function schema15UnionToJSON(schema15Union) {
69
- return JSON.stringify(Schema15Union$outboundSchema.parse(schema15Union));
106
+ export const ChatGenerationParamsProviderSortConfigUnion$outboundSchema = z.union([
107
+ z.lazy(() => ChatGenerationParamsProviderSortConfig$outboundSchema),
108
+ ChatGenerationParamsProviderSortConfigEnum$outboundSchema,
109
+ ]);
110
+ export function chatGenerationParamsProviderSortConfigUnionToJSON(chatGenerationParamsProviderSortConfigUnion) {
111
+ return JSON.stringify(ChatGenerationParamsProviderSortConfigUnion$outboundSchema.parse(chatGenerationParamsProviderSortConfigUnion));
112
+ }
113
+ /** @internal */
114
+ export const ChatGenerationParamsProviderSort$outboundSchema = openEnums.outboundSchema(ChatGenerationParamsProviderSort);
115
+ /** @internal */
116
+ export const ChatGenerationParamsSortUnion$outboundSchema = z.union([
117
+ ChatGenerationParamsProviderSort$outboundSchema,
118
+ z.union([
119
+ z.lazy(() => ChatGenerationParamsProviderSortConfig$outboundSchema),
120
+ ChatGenerationParamsProviderSortConfigEnum$outboundSchema,
121
+ ]),
122
+ ChatGenerationParamsSortEnum$outboundSchema,
123
+ ]);
124
+ export function chatGenerationParamsSortUnionToJSON(chatGenerationParamsSortUnion) {
125
+ return JSON.stringify(ChatGenerationParamsSortUnion$outboundSchema.parse(chatGenerationParamsSortUnion));
126
+ }
127
+ /** @internal */
128
+ export const ChatGenerationParamsMaxPrice$outboundSchema = z.object({
129
+ prompt: z.string().optional(),
130
+ completion: z.string().optional(),
131
+ image: z.string().optional(),
132
+ audio: z.string().optional(),
133
+ request: z.string().optional(),
134
+ });
135
+ export function chatGenerationParamsMaxPriceToJSON(chatGenerationParamsMaxPrice) {
136
+ return JSON.stringify(ChatGenerationParamsMaxPrice$outboundSchema.parse(chatGenerationParamsMaxPrice));
70
137
  }
71
138
  /** @internal */
72
- export const Schema0$outboundSchema = z
73
- .object({
139
+ export const ChatGenerationParamsProvider$outboundSchema = z.object({
74
140
  allowFallbacks: z.nullable(z.boolean()).optional(),
75
141
  requireParameters: z.nullable(z.boolean()).optional(),
76
- dataCollection: z.nullable(Schema3$outboundSchema).optional(),
142
+ dataCollection: z.nullable(DataCollection$outboundSchema).optional(),
77
143
  zdr: z.nullable(z.boolean()).optional(),
78
144
  enforceDistillableText: z.nullable(z.boolean()).optional(),
79
- order: z.nullable(z.array(Schema5$outboundSchema)).optional(),
80
- only: z.nullable(z.array(Schema5$outboundSchema)).optional(),
81
- ignore: z.nullable(z.array(Schema5$outboundSchema)).optional(),
82
- quantizations: z.nullable(z.array(Schema8$outboundSchema)).optional(),
83
- sort: z.nullable(ProviderSortUnion$outboundSchema).optional(),
84
- maxPrice: Schema10$outboundSchema.optional(),
85
- preferredMinThroughput: z.nullable(z.union([z.number(), z.lazy(() => Schema15$outboundSchema)])).optional(),
86
- preferredMaxLatency: z.nullable(z.union([z.number(), z.lazy(() => Schema15$outboundSchema)])).optional(),
145
+ order: z.nullable(z.array(z.union([ProviderName$outboundSchema, z.string()])))
146
+ .optional(),
147
+ only: z.nullable(z.array(z.union([ProviderName$outboundSchema, z.string()])))
148
+ .optional(),
149
+ ignore: z.nullable(z.array(z.union([ProviderName$outboundSchema, z.string()]))).optional(),
150
+ quantizations: z.nullable(z.array(Quantization$outboundSchema)).optional(),
151
+ sort: z.nullable(z.union([
152
+ ChatGenerationParamsProviderSort$outboundSchema,
153
+ z.union([
154
+ z.lazy(() => ChatGenerationParamsProviderSortConfig$outboundSchema),
155
+ ChatGenerationParamsProviderSortConfigEnum$outboundSchema,
156
+ ]),
157
+ ChatGenerationParamsSortEnum$outboundSchema,
158
+ ])).optional(),
159
+ maxPrice: z.lazy(() => ChatGenerationParamsMaxPrice$outboundSchema)
160
+ .optional(),
161
+ preferredMinThroughput: z.nullable(PreferredMinThroughput$outboundSchema)
162
+ .optional(),
163
+ preferredMaxLatency: z.nullable(PreferredMaxLatency$outboundSchema)
164
+ .optional(),
87
165
  }).transform((v) => {
88
166
  return remap$(v, {
89
167
  allowFallbacks: "allow_fallbacks",
@@ -95,51 +173,115 @@ export const Schema0$outboundSchema = z
95
173
  preferredMaxLatency: "preferred_max_latency",
96
174
  });
97
175
  });
98
- export function schema0ToJSON(schema0) {
99
- return JSON.stringify(Schema0$outboundSchema.parse(schema0));
176
+ export function chatGenerationParamsProviderToJSON(chatGenerationParamsProvider) {
177
+ return JSON.stringify(ChatGenerationParamsProvider$outboundSchema.parse(chatGenerationParamsProvider));
100
178
  }
101
179
  /** @internal */
102
- export const Route$outboundSchema = openEnums
103
- .outboundSchema(Route);
180
+ export const ChatGenerationParamsPluginResponseHealing$outboundSchema = z.object({
181
+ id: z.literal("response-healing"),
182
+ enabled: z.boolean().optional(),
183
+ });
184
+ export function chatGenerationParamsPluginResponseHealingToJSON(chatGenerationParamsPluginResponseHealing) {
185
+ return JSON.stringify(ChatGenerationParamsPluginResponseHealing$outboundSchema.parse(chatGenerationParamsPluginResponseHealing));
186
+ }
104
187
  /** @internal */
105
- export const Effort$outboundSchema = openEnums
106
- .outboundSchema(Effort);
188
+ export const ChatGenerationParamsPluginFileParser$outboundSchema = z.object({
189
+ id: z.literal("file-parser"),
190
+ enabled: z.boolean().optional(),
191
+ pdf: PDFParserOptions$outboundSchema.optional(),
192
+ });
193
+ export function chatGenerationParamsPluginFileParserToJSON(chatGenerationParamsPluginFileParser) {
194
+ return JSON.stringify(ChatGenerationParamsPluginFileParser$outboundSchema.parse(chatGenerationParamsPluginFileParser));
195
+ }
107
196
  /** @internal */
108
- export const Reasoning$outboundSchema = z.object({
109
- effort: z.nullable(Effort$outboundSchema).optional(),
110
- summary: z.nullable(ReasoningSummaryVerbosity$outboundSchema).optional(),
197
+ export const ChatGenerationParamsPluginWeb$outboundSchema = z.object({
198
+ id: z.literal("web"),
199
+ enabled: z.boolean().optional(),
200
+ maxResults: z.number().optional(),
201
+ searchPrompt: z.string().optional(),
202
+ engine: WebSearchEngine$outboundSchema.optional(),
203
+ }).transform((v) => {
204
+ return remap$(v, {
205
+ maxResults: "max_results",
206
+ searchPrompt: "search_prompt",
207
+ });
111
208
  });
112
- export function reasoningToJSON(reasoning) {
113
- return JSON.stringify(Reasoning$outboundSchema.parse(reasoning));
209
+ export function chatGenerationParamsPluginWebToJSON(chatGenerationParamsPluginWeb) {
210
+ return JSON.stringify(ChatGenerationParamsPluginWeb$outboundSchema.parse(chatGenerationParamsPluginWeb));
114
211
  }
115
212
  /** @internal */
116
- export const ResponseFormatPython$outboundSchema = z.object({
117
- type: z.literal("python"),
213
+ export const ChatGenerationParamsPluginModeration$outboundSchema = z.object({
214
+ id: z.literal("moderation"),
118
215
  });
119
- export function responseFormatPythonToJSON(responseFormatPython) {
120
- return JSON.stringify(ResponseFormatPython$outboundSchema.parse(responseFormatPython));
216
+ export function chatGenerationParamsPluginModerationToJSON(chatGenerationParamsPluginModeration) {
217
+ return JSON.stringify(ChatGenerationParamsPluginModeration$outboundSchema.parse(chatGenerationParamsPluginModeration));
121
218
  }
122
219
  /** @internal */
123
- export const ResponseFormatJSONObject$outboundSchema = z.object({
124
- type: z.literal("json_object"),
220
+ export const ChatGenerationParamsPluginAutoRouter$outboundSchema = z.object({
221
+ id: z.literal("auto-router"),
222
+ enabled: z.boolean().optional(),
223
+ allowedModels: z.array(z.string()).optional(),
224
+ }).transform((v) => {
225
+ return remap$(v, {
226
+ allowedModels: "allowed_models",
227
+ });
125
228
  });
126
- export function responseFormatJSONObjectToJSON(responseFormatJSONObject) {
127
- return JSON.stringify(ResponseFormatJSONObject$outboundSchema.parse(responseFormatJSONObject));
229
+ export function chatGenerationParamsPluginAutoRouterToJSON(chatGenerationParamsPluginAutoRouter) {
230
+ return JSON.stringify(ChatGenerationParamsPluginAutoRouter$outboundSchema.parse(chatGenerationParamsPluginAutoRouter));
231
+ }
232
+ /** @internal */
233
+ export const ChatGenerationParamsPluginUnion$outboundSchema = z.union([
234
+ z.lazy(() => ChatGenerationParamsPluginAutoRouter$outboundSchema),
235
+ z.lazy(() => ChatGenerationParamsPluginModeration$outboundSchema),
236
+ z.lazy(() => ChatGenerationParamsPluginWeb$outboundSchema),
237
+ z.lazy(() => ChatGenerationParamsPluginFileParser$outboundSchema),
238
+ z.lazy(() => ChatGenerationParamsPluginResponseHealing$outboundSchema),
239
+ ]);
240
+ export function chatGenerationParamsPluginUnionToJSON(chatGenerationParamsPluginUnion) {
241
+ return JSON.stringify(ChatGenerationParamsPluginUnion$outboundSchema.parse(chatGenerationParamsPluginUnion));
128
242
  }
129
243
  /** @internal */
130
- export const ResponseFormatText$outboundSchema = z.object({
131
- type: z.literal("text"),
244
+ export const ChatGenerationParamsTrace$outboundSchema = z.object({
245
+ traceId: z.string().optional(),
246
+ traceName: z.string().optional(),
247
+ spanName: z.string().optional(),
248
+ generationName: z.string().optional(),
249
+ parentSpanId: z.string().optional(),
250
+ additionalProperties: z.record(z.string(), z.nullable(z.any())).optional(),
251
+ }).transform((v) => {
252
+ return {
253
+ ...v.additionalProperties,
254
+ ...remap$(v, {
255
+ traceId: "trace_id",
256
+ traceName: "trace_name",
257
+ spanName: "span_name",
258
+ generationName: "generation_name",
259
+ parentSpanId: "parent_span_id",
260
+ additionalProperties: null,
261
+ }),
262
+ };
132
263
  });
133
- export function responseFormatTextToJSON(responseFormatText) {
134
- return JSON.stringify(ResponseFormatText$outboundSchema.parse(responseFormatText));
264
+ export function chatGenerationParamsTraceToJSON(chatGenerationParamsTrace) {
265
+ return JSON.stringify(ChatGenerationParamsTrace$outboundSchema.parse(chatGenerationParamsTrace));
266
+ }
267
+ /** @internal */
268
+ export const Effort$outboundSchema = openEnums
269
+ .outboundSchema(Effort);
270
+ /** @internal */
271
+ export const Reasoning$outboundSchema = z.object({
272
+ effort: z.nullable(Effort$outboundSchema).optional(),
273
+ summary: z.nullable(z.any()).optional(),
274
+ });
275
+ export function reasoningToJSON(reasoning) {
276
+ return JSON.stringify(Reasoning$outboundSchema.parse(reasoning));
135
277
  }
136
278
  /** @internal */
137
279
  export const ResponseFormat$outboundSchema = z.union([
138
- z.lazy(() => ResponseFormatText$outboundSchema),
139
- z.lazy(() => ResponseFormatJSONObject$outboundSchema),
280
+ ResponseFormatText$outboundSchema,
281
+ ResponseFormatJSONObject$outboundSchema,
140
282
  ResponseFormatJSONSchema$outboundSchema,
141
283
  ResponseFormatTextGrammar$outboundSchema,
142
- z.lazy(() => ResponseFormatPython$outboundSchema),
284
+ ResponseFormatTextPython$outboundSchema,
143
285
  ]);
144
286
  export function responseFormatToJSON(responseFormat) {
145
287
  return JSON.stringify(ResponseFormat$outboundSchema.parse(responseFormat));
@@ -148,23 +290,13 @@ export function responseFormatToJSON(responseFormat) {
148
290
  export const Stop$outboundSchema = z.union([
149
291
  z.string(),
150
292
  z.array(z.string()),
293
+ z.any(),
151
294
  ]);
152
295
  export function stopToJSON(stop) {
153
296
  return JSON.stringify(Stop$outboundSchema.parse(stop));
154
297
  }
155
298
  /** @internal */
156
- export const Debug$outboundSchema = z.object({
157
- echoUpstreamBody: z.boolean().optional(),
158
- }).transform((v) => {
159
- return remap$(v, {
160
- echoUpstreamBody: "echo_upstream_body",
161
- });
162
- });
163
- export function debugToJSON(debug) {
164
- return JSON.stringify(Debug$outboundSchema.parse(debug));
165
- }
166
- /** @internal */
167
- export const ChatGenerationParamsImageConfig$outboundSchema = z.union([z.string(), z.number(), z.array(z.any())]);
299
+ export const ChatGenerationParamsImageConfig$outboundSchema = z.union([z.string(), z.number(), z.array(z.nullable(z.any()))]);
168
300
  export function chatGenerationParamsImageConfigToJSON(chatGenerationParamsImageConfig) {
169
301
  return JSON.stringify(ChatGenerationParamsImageConfig$outboundSchema.parse(chatGenerationParamsImageConfig));
170
302
  }
@@ -173,11 +305,17 @@ export const Modality$outboundSchema = openEnums
173
305
  .outboundSchema(Modality);
174
306
  /** @internal */
175
307
  export const ChatGenerationParams$outboundSchema = z.object({
176
- provider: z.nullable(z.lazy(() => Schema0$outboundSchema)).optional(),
177
- plugins: z.array(Schema17$outboundSchema).optional(),
178
- route: z.nullable(Route$outboundSchema).optional(),
308
+ provider: z.nullable(z.lazy(() => ChatGenerationParamsProvider$outboundSchema)).optional(),
309
+ plugins: z.array(z.union([
310
+ z.lazy(() => ChatGenerationParamsPluginAutoRouter$outboundSchema),
311
+ z.lazy(() => ChatGenerationParamsPluginModeration$outboundSchema),
312
+ z.lazy(() => ChatGenerationParamsPluginWeb$outboundSchema),
313
+ z.lazy(() => ChatGenerationParamsPluginFileParser$outboundSchema),
314
+ z.lazy(() => ChatGenerationParamsPluginResponseHealing$outboundSchema),
315
+ ])).optional(),
179
316
  user: z.string().optional(),
180
317
  sessionId: z.string().optional(),
318
+ trace: z.lazy(() => ChatGenerationParamsTrace$outboundSchema).optional(),
181
319
  messages: z.array(Message$outboundSchema),
182
320
  model: z.string().optional(),
183
321
  models: z.array(z.string()).optional(),
@@ -191,22 +329,24 @@ export const ChatGenerationParams$outboundSchema = z.object({
191
329
  presencePenalty: z.nullable(z.number()).optional(),
192
330
  reasoning: z.lazy(() => Reasoning$outboundSchema).optional(),
193
331
  responseFormat: z.union([
194
- z.lazy(() => ResponseFormatText$outboundSchema),
195
- z.lazy(() => ResponseFormatJSONObject$outboundSchema),
332
+ ResponseFormatText$outboundSchema,
333
+ ResponseFormatJSONObject$outboundSchema,
196
334
  ResponseFormatJSONSchema$outboundSchema,
197
335
  ResponseFormatTextGrammar$outboundSchema,
198
- z.lazy(() => ResponseFormatPython$outboundSchema),
336
+ ResponseFormatTextPython$outboundSchema,
199
337
  ]).optional(),
200
338
  seed: z.nullable(z.int()).optional(),
201
- stop: z.nullable(z.union([z.string(), z.array(z.string())])).optional(),
339
+ stop: z.nullable(z.union([z.string(), z.array(z.string()), z.any()]))
340
+ .optional(),
202
341
  stream: z.boolean().default(false),
203
342
  streamOptions: z.nullable(ChatStreamOptions$outboundSchema).optional(),
204
- temperature: z.nullable(z.number()).optional(),
205
- toolChoice: z.any().optional(),
343
+ temperature: z.nullable(z.number().default(1)),
344
+ parallelToolCalls: z.nullable(z.boolean()).optional(),
345
+ toolChoice: ToolChoiceOption$outboundSchema.optional(),
206
346
  tools: z.array(ToolDefinitionJson$outboundSchema).optional(),
207
- topP: z.nullable(z.number()).optional(),
208
- debug: z.lazy(() => Debug$outboundSchema).optional(),
209
- imageConfig: z.record(z.string(), z.union([z.string(), z.number(), z.array(z.any())])).optional(),
347
+ topP: z.nullable(z.number().default(1)),
348
+ debug: DebugOptions$outboundSchema.optional(),
349
+ imageConfig: z.record(z.string(), z.union([z.string(), z.number(), z.array(z.nullable(z.any()))])).optional(),
210
350
  modalities: z.array(Modality$outboundSchema).optional(),
211
351
  }).transform((v) => {
212
352
  return remap$(v, {
@@ -219,6 +359,7 @@ export const ChatGenerationParams$outboundSchema = z.object({
219
359
  presencePenalty: "presence_penalty",
220
360
  responseFormat: "response_format",
221
361
  streamOptions: "stream_options",
362
+ parallelToolCalls: "parallel_tool_calls",
222
363
  toolChoice: "tool_choice",
223
364
  topP: "top_p",
224
365
  imageConfig: "image_config",
@@ -1,23 +1,71 @@
1
1
  import * as z from "zod/v4";
2
2
  import { Result as SafeParseResult } from "../types/fp.js";
3
3
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
4
+ /**
5
+ * Detailed completion token usage
6
+ */
4
7
  export type CompletionTokensDetails = {
8
+ /**
9
+ * Tokens used for reasoning
10
+ */
5
11
  reasoningTokens?: number | null | undefined;
12
+ /**
13
+ * Tokens used for audio output
14
+ */
6
15
  audioTokens?: number | null | undefined;
16
+ /**
17
+ * Accepted prediction tokens
18
+ */
7
19
  acceptedPredictionTokens?: number | null | undefined;
20
+ /**
21
+ * Rejected prediction tokens
22
+ */
8
23
  rejectedPredictionTokens?: number | null | undefined;
9
24
  };
25
+ /**
26
+ * Detailed prompt token usage
27
+ */
10
28
  export type PromptTokensDetails = {
29
+ /**
30
+ * Cached prompt tokens
31
+ */
11
32
  cachedTokens?: number | undefined;
33
+ /**
34
+ * Tokens written to cache. Only returned for models with explicit caching and cache write pricing.
35
+ */
12
36
  cacheWriteTokens?: number | undefined;
37
+ /**
38
+ * Audio input tokens
39
+ */
13
40
  audioTokens?: number | undefined;
41
+ /**
42
+ * Video input tokens
43
+ */
14
44
  videoTokens?: number | undefined;
15
45
  };
46
+ /**
47
+ * Token usage statistics
48
+ */
16
49
  export type ChatGenerationTokenUsage = {
50
+ /**
51
+ * Number of tokens in the completion
52
+ */
17
53
  completionTokens: number;
54
+ /**
55
+ * Number of tokens in the prompt
56
+ */
18
57
  promptTokens: number;
58
+ /**
59
+ * Total number of tokens
60
+ */
19
61
  totalTokens: number;
62
+ /**
63
+ * Detailed completion token usage
64
+ */
20
65
  completionTokensDetails?: CompletionTokensDetails | null | undefined;
66
+ /**
67
+ * Detailed prompt token usage
68
+ */
21
69
  promptTokensDetails?: PromptTokensDetails | null | undefined;
22
70
  };
23
71
  /** @internal */
@@ -4,20 +4,25 @@ import { ChatMessageContentItemAudio, ChatMessageContentItemAudio$Outbound } fro
4
4
  import { ChatMessageContentItemImage, ChatMessageContentItemImage$Outbound } from "./chatmessagecontentitemimage.js";
5
5
  import { ChatMessageContentItemText, ChatMessageContentItemText$Outbound } from "./chatmessagecontentitemtext.js";
6
6
  import { ChatMessageContentItemVideo, ChatMessageContentItemVideo$Outbound } from "./chatmessagecontentitemvideo.js";
7
+ import { ChatMessageContentItemVideoLegacy, ChatMessageContentItemVideoLegacy$Outbound } from "./chatmessagecontentitemvideolegacy.js";
7
8
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
8
- export type ChatMessageContentItem = ChatMessageContentItemText | ChatMessageContentItemImage | ChatMessageContentItemAudio | (ChatMessageContentItemVideo & {
9
- type: "input_video";
10
- }) | (ChatMessageContentItemVideo & {
11
- type: "video_url";
12
- });
9
+ export type ChatMessageContentItem1 = ChatMessageContentItemVideoLegacy | ChatMessageContentItemVideo;
10
+ /**
11
+ * Content part for chat completion messages
12
+ */
13
+ export type ChatMessageContentItem = ChatMessageContentItemText | ChatMessageContentItemImage | ChatMessageContentItemAudio | ChatMessageContentItemVideoLegacy | ChatMessageContentItemVideo;
14
+ /** @internal */
15
+ export declare const ChatMessageContentItem1$inboundSchema: z.ZodType<ChatMessageContentItem1, unknown>;
16
+ /** @internal */
17
+ export type ChatMessageContentItem1$Outbound = ChatMessageContentItemVideoLegacy$Outbound | ChatMessageContentItemVideo$Outbound;
18
+ /** @internal */
19
+ export declare const ChatMessageContentItem1$outboundSchema: z.ZodType<ChatMessageContentItem1$Outbound, ChatMessageContentItem1>;
20
+ export declare function chatMessageContentItem1ToJSON(chatMessageContentItem1: ChatMessageContentItem1): string;
21
+ export declare function chatMessageContentItem1FromJSON(jsonString: string): SafeParseResult<ChatMessageContentItem1, SDKValidationError>;
13
22
  /** @internal */
14
23
  export declare const ChatMessageContentItem$inboundSchema: z.ZodType<ChatMessageContentItem, unknown>;
15
24
  /** @internal */
16
- export type ChatMessageContentItem$Outbound = ChatMessageContentItemText$Outbound | ChatMessageContentItemImage$Outbound | ChatMessageContentItemAudio$Outbound | (ChatMessageContentItemVideo$Outbound & {
17
- type: "input_video";
18
- }) | (ChatMessageContentItemVideo$Outbound & {
19
- type: "video_url";
20
- });
25
+ export type ChatMessageContentItem$Outbound = ChatMessageContentItemText$Outbound | ChatMessageContentItemImage$Outbound | ChatMessageContentItemAudio$Outbound | ChatMessageContentItemVideoLegacy$Outbound | ChatMessageContentItemVideo$Outbound;
21
26
  /** @internal */
22
27
  export declare const ChatMessageContentItem$outboundSchema: z.ZodType<ChatMessageContentItem$Outbound, ChatMessageContentItem>;
23
28
  export declare function chatMessageContentItemToJSON(chatMessageContentItem: ChatMessageContentItem): string;
@@ -8,21 +8,42 @@ import { ChatMessageContentItemAudio$inboundSchema, ChatMessageContentItemAudio$
8
8
  import { ChatMessageContentItemImage$inboundSchema, ChatMessageContentItemImage$outboundSchema, } from "./chatmessagecontentitemimage.js";
9
9
  import { ChatMessageContentItemText$inboundSchema, ChatMessageContentItemText$outboundSchema, } from "./chatmessagecontentitemtext.js";
10
10
  import { ChatMessageContentItemVideo$inboundSchema, ChatMessageContentItemVideo$outboundSchema, } from "./chatmessagecontentitemvideo.js";
11
+ import { ChatMessageContentItemVideoLegacy$inboundSchema, ChatMessageContentItemVideoLegacy$outboundSchema, } from "./chatmessagecontentitemvideolegacy.js";
12
+ /** @internal */
13
+ export const ChatMessageContentItem1$inboundSchema = z.union([
14
+ ChatMessageContentItemVideoLegacy$inboundSchema,
15
+ ChatMessageContentItemVideo$inboundSchema,
16
+ ]);
17
+ /** @internal */
18
+ export const ChatMessageContentItem1$outboundSchema = z.union([
19
+ ChatMessageContentItemVideoLegacy$outboundSchema,
20
+ ChatMessageContentItemVideo$outboundSchema,
21
+ ]);
22
+ export function chatMessageContentItem1ToJSON(chatMessageContentItem1) {
23
+ return JSON.stringify(ChatMessageContentItem1$outboundSchema.parse(chatMessageContentItem1));
24
+ }
25
+ export function chatMessageContentItem1FromJSON(jsonString) {
26
+ return safeParse(jsonString, (x) => ChatMessageContentItem1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatMessageContentItem1' from JSON`);
27
+ }
11
28
  /** @internal */
12
29
  export const ChatMessageContentItem$inboundSchema = z.union([
13
30
  ChatMessageContentItemText$inboundSchema,
14
31
  ChatMessageContentItemImage$inboundSchema,
15
32
  ChatMessageContentItemAudio$inboundSchema,
16
- ChatMessageContentItemVideo$inboundSchema.and(z.object({ type: z.literal("input_video") })),
17
- z.lazy(() => ChatMessageContentItemVideo$inboundSchema).and(z.object({ type: z.literal("video_url") })),
33
+ z.union([
34
+ ChatMessageContentItemVideoLegacy$inboundSchema,
35
+ ChatMessageContentItemVideo$inboundSchema,
36
+ ]),
18
37
  ]);
19
38
  /** @internal */
20
39
  export const ChatMessageContentItem$outboundSchema = z.union([
21
40
  ChatMessageContentItemText$outboundSchema,
22
41
  ChatMessageContentItemImage$outboundSchema,
23
42
  ChatMessageContentItemAudio$outboundSchema,
24
- ChatMessageContentItemVideo$outboundSchema.and(z.object({ type: z.literal("input_video") })),
25
- z.lazy(() => ChatMessageContentItemVideo$outboundSchema).and(z.object({ type: z.literal("video_url") })),
43
+ z.union([
44
+ ChatMessageContentItemVideoLegacy$outboundSchema,
45
+ ChatMessageContentItemVideo$outboundSchema,
46
+ ]),
26
47
  ]);
27
48
  export function chatMessageContentItemToJSON(chatMessageContentItem) {
28
49
  return JSON.stringify(ChatMessageContentItem$outboundSchema.parse(chatMessageContentItem));
@@ -1,15 +1,33 @@
1
1
  import * as z from "zod/v4";
2
+ import { ClosedEnum } from "../types/enums.js";
2
3
  import { Result as SafeParseResult } from "../types/fp.js";
3
4
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
5
+ export declare const ChatMessageContentItemAudioType: {
6
+ readonly InputAudio: "input_audio";
7
+ };
8
+ export type ChatMessageContentItemAudioType = ClosedEnum<typeof ChatMessageContentItemAudioType>;
4
9
  export type ChatMessageContentItemAudioInputAudio = {
10
+ /**
11
+ * Base64 encoded audio data
12
+ */
5
13
  data: string;
14
+ /**
15
+ * Audio format (e.g., wav, mp3, flac, m4a, ogg, aiff, aac, pcm16, pcm24). Supported formats vary by provider.
16
+ */
6
17
  format: string;
7
18
  };
19
+ /**
20
+ * Audio input content part. Supported audio formats vary by provider.
21
+ */
8
22
  export type ChatMessageContentItemAudio = {
9
- type: "input_audio";
23
+ type: ChatMessageContentItemAudioType;
10
24
  inputAudio: ChatMessageContentItemAudioInputAudio;
11
25
  };
12
26
  /** @internal */
27
+ export declare const ChatMessageContentItemAudioType$inboundSchema: z.ZodEnum<typeof ChatMessageContentItemAudioType>;
28
+ /** @internal */
29
+ export declare const ChatMessageContentItemAudioType$outboundSchema: z.ZodEnum<typeof ChatMessageContentItemAudioType>;
30
+ /** @internal */
13
31
  export declare const ChatMessageContentItemAudioInputAudio$inboundSchema: z.ZodType<ChatMessageContentItemAudioInputAudio, unknown>;
14
32
  /** @internal */
15
33
  export type ChatMessageContentItemAudioInputAudio$Outbound = {
@@ -24,7 +42,7 @@ export declare function chatMessageContentItemAudioInputAudioFromJSON(jsonString
24
42
  export declare const ChatMessageContentItemAudio$inboundSchema: z.ZodType<ChatMessageContentItemAudio, unknown>;
25
43
  /** @internal */
26
44
  export type ChatMessageContentItemAudio$Outbound = {
27
- type: "input_audio";
45
+ type: string;
28
46
  input_audio: ChatMessageContentItemAudioInputAudio$Outbound;
29
47
  };
30
48
  /** @internal */