@openrouter/sdk 1.5.135 → 1.5.137

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.
@@ -3,77 +3,20 @@
3
3
  */
4
4
  import * as z from "zod/v4";
5
5
  import { remap as remap$ } from "../lib/primitives.js";
6
- import { collectExtraKeys as collectExtraKeys$, safeParse, } from "../lib/schemas.js";
7
- import { discriminatedUnion } from "../types/discriminatedUnion.js";
6
+ import { safeParse } from "../lib/schemas.js";
8
7
  import * as openEnums from "../types/enums.js";
9
- import { Alignment$inboundSchema } from "./alignment.js";
10
8
  import { AnthropicCacheCreation$inboundSchema, } from "./anthropiccachecreation.js";
11
- import { AnthropicContainer$inboundSchema, } from "./anthropiccontainer.js";
12
- import { AnthropicInputTransformation$inboundSchema, } from "./anthropicinputtransformation.js";
13
- import { AnthropicOutputTokensDetails$inboundSchema, } from "./anthropicoutputtokensdetails.js";
14
- import { AnthropicRefusalStopDetails$inboundSchema, } from "./anthropicrefusalstopdetails.js";
15
- import { AnthropicServerToolUsage$inboundSchema, } from "./anthropicservertoolusage.js";
16
- import { AnthropicServiceTier$inboundSchema, } from "./anthropicservicetier.js";
17
9
  import { AnthropicSpeed$inboundSchema, } from "./anthropicspeed.js";
18
10
  import { AnthropicUsageIteration$inboundSchema, } from "./anthropicusageiteration.js";
19
- import { ApiErrorType$inboundSchema } from "./apierrortype.js";
20
- import { ArmorSafeguardResult$inboundSchema, } from "./armorsafeguardresult.js";
21
11
  import { BatchOutputReference$inboundSchema, } from "./batchoutputreference.js";
12
+ import { BatchResult$inboundSchema } from "./batchresult.js";
22
13
  import { CostDetails$inboundSchema } from "./costdetails.js";
23
- import { FinishReason$inboundSchema } from "./finishreason.js";
24
- import { OpenResponsesResult$inboundSchema, } from "./openresponsesresult.js";
25
- import { OpenRouterMetadata$inboundSchema, } from "./openroutermetadata.js";
26
- import { ORAnthropicContentBlock$inboundSchema, } from "./oranthropiccontentblock.js";
27
- import { ORAnthropicStopReason$inboundSchema, } from "./oranthropicstopreason.js";
28
- import { ReasoningDetailEncrypted$inboundSchema, } from "./reasoningdetailencrypted.js";
29
- import { ReasoningDetailServerToolCall$inboundSchema, } from "./reasoningdetailservertoolcall.js";
30
- import { ReasoningDetailSummary$inboundSchema, } from "./reasoningdetailsummary.js";
31
- import { ReasoningDetailText$inboundSchema, } from "./reasoningdetailtext.js";
32
14
  export const BatchObjectCompletionWindow = {
33
15
  TwentyFourh: "24h",
34
16
  };
35
- export const BatchObjectObjectBatch = {
17
+ export const BatchObjectObject = {
36
18
  Batch: "batch",
37
19
  };
38
- export const BatchObjectFormat2 = {
39
- Pcm: "pcm",
40
- };
41
- export const BatchObjectFormat1 = {
42
- Pcm: "pcm",
43
- };
44
- export const ObjectAudioSpeech = {
45
- AudioSpeech: "audio.speech",
46
- };
47
- export const ObjectEmbedding = {
48
- Embedding: "embedding",
49
- };
50
- export const BodyObjectList = {
51
- List: "list",
52
- };
53
- export const BatchObjectRole = {
54
- Assistant: "assistant",
55
- };
56
- export const BatchObjectTypeMessage = {
57
- Message: "message",
58
- };
59
- export const ChoiceTypeImageURLEnum = {
60
- ImageUrl: "image_url",
61
- };
62
- export const ChoiceRole = {
63
- Assistant: "assistant",
64
- };
65
- export const ChoiceTypeFunction = {
66
- Function: "function",
67
- };
68
- export const BatchObjectEvent = {
69
- AdapterRequest: "adapter_request",
70
- UpstreamHeadersReceived: "upstream_headers_received",
71
- FirstTokenReceived: "first_token_received",
72
- UpstreamBodyEnded: "upstream_body_ended",
73
- };
74
- export const BodyObjectChatCompletion = {
75
- ChatCompletion: "chat.completion",
76
- };
77
20
  export const BatchObjectStatus = {
78
21
  Validating: "validating",
79
22
  InProgress: "in_progress",
@@ -94,7 +37,7 @@ export function batchObjectErrorFromJSON(jsonString) {
94
37
  return safeParse(jsonString, (x) => BatchObjectError$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObjectError' from JSON`);
95
38
  }
96
39
  /** @internal */
97
- export const BatchObjectObjectBatch$inboundSchema = z.enum(BatchObjectObjectBatch);
40
+ export const BatchObjectObject$inboundSchema = z.enum(BatchObjectObject);
98
41
  /** @internal */
99
42
  export const BatchObjectRequestCounts$inboundSchema = z.object({
100
43
  completed: z.int(),
@@ -105,698 +48,6 @@ export function batchObjectRequestCountsFromJSON(jsonString) {
105
48
  return safeParse(jsonString, (x) => BatchObjectRequestCounts$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObjectRequestCounts' from JSON`);
106
49
  }
107
50
  /** @internal */
108
- export const ResultError$inboundSchema = z
109
- .object({
110
- error_type: ApiErrorType$inboundSchema.optional(),
111
- message: z.string(),
112
- param: z.nullable(z.string()),
113
- type: z.string(),
114
- }).transform((v) => {
115
- return remap$(v, {
116
- "error_type": "errorType",
117
- });
118
- });
119
- export function resultErrorFromJSON(jsonString) {
120
- return safeParse(jsonString, (x) => ResultError$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResultError' from JSON`);
121
- }
122
- /** @internal */
123
- export const BatchObjectFormat2$inboundSchema = z.enum(BatchObjectFormat2);
124
- /** @internal */
125
- export const AudioPcm2$inboundSchema = z.object({
126
- bits_per_sample: z.number(),
127
- byte_length: z.int(),
128
- channels: z.int(),
129
- format: BatchObjectFormat2$inboundSchema,
130
- sample_rate: z.int(),
131
- sha256: z.string(),
132
- }).transform((v) => {
133
- return remap$(v, {
134
- "bits_per_sample": "bitsPerSample",
135
- "byte_length": "byteLength",
136
- "sample_rate": "sampleRate",
137
- });
138
- });
139
- export function audioPcm2FromJSON(jsonString) {
140
- return safeParse(jsonString, (x) => AudioPcm2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AudioPcm2' from JSON`);
141
- }
142
- /** @internal */
143
- export const BatchObjectFormat1$inboundSchema = z.enum(BatchObjectFormat1);
144
- /** @internal */
145
- export const AudioPcm1$inboundSchema = z.object({
146
- bits_per_sample: z.number(),
147
- channels: z.int(),
148
- data: z.string(),
149
- format: BatchObjectFormat1$inboundSchema,
150
- sample_rate: z.int(),
151
- }).transform((v) => {
152
- return remap$(v, {
153
- "bits_per_sample": "bitsPerSample",
154
- "sample_rate": "sampleRate",
155
- });
156
- });
157
- export function audioPcm1FromJSON(jsonString) {
158
- return safeParse(jsonString, (x) => AudioPcm1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AudioPcm1' from JSON`);
159
- }
160
- /** @internal */
161
- export const Audio$inboundSchema = z.union([
162
- z.lazy(() => AudioPcm2$inboundSchema),
163
- z.lazy(() => AudioPcm1$inboundSchema),
164
- ]);
165
- export function audioFromJSON(jsonString) {
166
- return safeParse(jsonString, (x) => Audio$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Audio' from JSON`);
167
- }
168
- /** @internal */
169
- export const ObjectAudioSpeech$inboundSchema = z.enum(ObjectAudioSpeech);
170
- /** @internal */
171
- export const BodyUsage4$inboundSchema = z
172
- .object({
173
- completion_tokens: z.int(),
174
- prompt_tokens: z.int(),
175
- total_tokens: z.int(),
176
- }).transform((v) => {
177
- return remap$(v, {
178
- "completion_tokens": "completionTokens",
179
- "prompt_tokens": "promptTokens",
180
- "total_tokens": "totalTokens",
181
- });
182
- });
183
- export function bodyUsage4FromJSON(jsonString) {
184
- return safeParse(jsonString, (x) => BodyUsage4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyUsage4' from JSON`);
185
- }
186
- /** @internal */
187
- export const BodyAudioSpeech$inboundSchema = z.object({
188
- audio: z.union([
189
- z.lazy(() => AudioPcm2$inboundSchema),
190
- z.lazy(() => AudioPcm1$inboundSchema),
191
- ]),
192
- model: z.string(),
193
- object: ObjectAudioSpeech$inboundSchema,
194
- usage: z.lazy(() => BodyUsage4$inboundSchema),
195
- });
196
- export function bodyAudioSpeechFromJSON(jsonString) {
197
- return safeParse(jsonString, (x) => BodyAudioSpeech$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyAudioSpeech' from JSON`);
198
- }
199
- /** @internal */
200
- export const Embedding$inboundSchema = z.union([
201
- z.array(z.number()),
202
- z.string(),
203
- ]);
204
- export function embeddingFromJSON(jsonString) {
205
- return safeParse(jsonString, (x) => Embedding$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Embedding' from JSON`);
206
- }
207
- /** @internal */
208
- export const ObjectEmbedding$inboundSchema = z.enum(ObjectEmbedding);
209
- /** @internal */
210
- export const BatchObjectData$inboundSchema = z.object({
211
- document_index: z.int().optional(),
212
- embedding: z.union([z.array(z.number()), z.string()]),
213
- index: z.int().optional(),
214
- object: ObjectEmbedding$inboundSchema,
215
- }).transform((v) => {
216
- return remap$(v, {
217
- "document_index": "documentIndex",
218
- });
219
- });
220
- export function batchObjectDataFromJSON(jsonString) {
221
- return safeParse(jsonString, (x) => BatchObjectData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObjectData' from JSON`);
222
- }
223
- /** @internal */
224
- export const BodyObjectList$inboundSchema = z
225
- .enum(BodyObjectList);
226
- /** @internal */
227
- export const BodyPromptTokensDetails2$inboundSchema = z.object({
228
- audio_tokens: z.int().optional(),
229
- file_tokens: z.int().optional(),
230
- image_tokens: z.int().optional(),
231
- text_tokens: z.int().optional(),
232
- video_tokens: z.int().optional(),
233
- }).transform((v) => {
234
- return remap$(v, {
235
- "audio_tokens": "audioTokens",
236
- "file_tokens": "fileTokens",
237
- "image_tokens": "imageTokens",
238
- "text_tokens": "textTokens",
239
- "video_tokens": "videoTokens",
240
- });
241
- });
242
- export function bodyPromptTokensDetails2FromJSON(jsonString) {
243
- return safeParse(jsonString, (x) => BodyPromptTokensDetails2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyPromptTokensDetails2' from JSON`);
244
- }
245
- /** @internal */
246
- export const BodyUsage3$inboundSchema = z
247
- .object({
248
- cost: z.number().optional(),
249
- cost_details: z.nullable(CostDetails$inboundSchema).optional(),
250
- is_byok: z.boolean().optional(),
251
- prompt_tokens: z.int(),
252
- prompt_tokens_details: z.lazy(() => BodyPromptTokensDetails2$inboundSchema)
253
- .optional(),
254
- total_tokens: z.int(),
255
- }).transform((v) => {
256
- return remap$(v, {
257
- "cost_details": "costDetails",
258
- "is_byok": "isByok",
259
- "prompt_tokens": "promptTokens",
260
- "prompt_tokens_details": "promptTokensDetails",
261
- "total_tokens": "totalTokens",
262
- });
263
- });
264
- export function bodyUsage3FromJSON(jsonString) {
265
- return safeParse(jsonString, (x) => BodyUsage3$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyUsage3' from JSON`);
266
- }
267
- /** @internal */
268
- export const BodyList$inboundSchema = z.object({
269
- data: z.array(z.lazy(() => BatchObjectData$inboundSchema)),
270
- id: z.string().optional(),
271
- model: z.string(),
272
- object: BodyObjectList$inboundSchema,
273
- usage: z.lazy(() => BodyUsage3$inboundSchema).optional(),
274
- });
275
- export function bodyListFromJSON(jsonString) {
276
- return safeParse(jsonString, (x) => BodyList$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyList' from JSON`);
277
- }
278
- /** @internal */
279
- export const BatchObjectRole$inboundSchema = z.enum(BatchObjectRole);
280
- /** @internal */
281
- export const BatchObjectTypeMessage$inboundSchema = z.enum(BatchObjectTypeMessage);
282
- /** @internal */
283
- export const BodyUsage2$inboundSchema = z
284
- .object({
285
- cache_creation: z.nullable(AnthropicCacheCreation$inboundSchema),
286
- cache_creation_input_tokens: z.nullable(z.int()),
287
- cache_read_input_tokens: z.nullable(z.int()),
288
- inference_geo: z.nullable(z.string()),
289
- input_tokens: z.int(),
290
- output_tokens: z.int(),
291
- output_tokens_details: z.nullable(AnthropicOutputTokensDetails$inboundSchema),
292
- server_tool_use: z.nullable(AnthropicServerToolUsage$inboundSchema),
293
- service_tier: z.nullable(AnthropicServiceTier$inboundSchema),
294
- iterations: z.array(AnthropicUsageIteration$inboundSchema).optional(),
295
- speed: z.nullable(AnthropicSpeed$inboundSchema).optional(),
296
- }).transform((v) => {
297
- return remap$(v, {
298
- "cache_creation": "cacheCreation",
299
- "cache_creation_input_tokens": "cacheCreationInputTokens",
300
- "cache_read_input_tokens": "cacheReadInputTokens",
301
- "inference_geo": "inferenceGeo",
302
- "input_tokens": "inputTokens",
303
- "output_tokens": "outputTokens",
304
- "output_tokens_details": "outputTokensDetails",
305
- "server_tool_use": "serverToolUse",
306
- "service_tier": "serviceTier",
307
- });
308
- });
309
- export function bodyUsage2FromJSON(jsonString) {
310
- return safeParse(jsonString, (x) => BodyUsage2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyUsage2' from JSON`);
311
- }
312
- /** @internal */
313
- export const BodyMessage$inboundSchema = z
314
- .object({
315
- container: z.nullable(AnthropicContainer$inboundSchema),
316
- content: z.array(ORAnthropicContentBlock$inboundSchema),
317
- id: z.string(),
318
- input_transformations: z.nullable(z.array(AnthropicInputTransformation$inboundSchema)).optional(),
319
- model: z.string(),
320
- role: BatchObjectRole$inboundSchema,
321
- stop_details: z.nullable(AnthropicRefusalStopDetails$inboundSchema),
322
- stop_reason: z.nullable(ORAnthropicStopReason$inboundSchema),
323
- stop_sequence: z.nullable(z.string()),
324
- type: BatchObjectTypeMessage$inboundSchema,
325
- usage: z.lazy(() => BodyUsage2$inboundSchema),
326
- }).transform((v) => {
327
- return remap$(v, {
328
- "input_transformations": "inputTransformations",
329
- "stop_details": "stopDetails",
330
- "stop_reason": "stopReason",
331
- "stop_sequence": "stopSequence",
332
- });
333
- });
334
- export function bodyMessageFromJSON(jsonString) {
335
- return safeParse(jsonString, (x) => BodyMessage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyMessage' from JSON`);
336
- }
337
- /** @internal */
338
- export const ContentTopLogprob$inboundSchema = z.object({
339
- bytes: z.nullable(z.array(z.int())),
340
- logprob: z.number(),
341
- token: z.string(),
342
- });
343
- export function contentTopLogprobFromJSON(jsonString) {
344
- return safeParse(jsonString, (x) => ContentTopLogprob$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentTopLogprob' from JSON`);
345
- }
346
- /** @internal */
347
- export const LogprobsContent$inboundSchema = z.object({
348
- bytes: z.nullable(z.array(z.int())),
349
- logprob: z.number(),
350
- token: z.string(),
351
- top_logprobs: z.array(z.lazy(() => ContentTopLogprob$inboundSchema)),
352
- }).transform((v) => {
353
- return remap$(v, {
354
- "top_logprobs": "topLogprobs",
355
- });
356
- });
357
- export function logprobsContentFromJSON(jsonString) {
358
- return safeParse(jsonString, (x) => LogprobsContent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LogprobsContent' from JSON`);
359
- }
360
- /** @internal */
361
- export const RefusalTopLogprob$inboundSchema = z.object({
362
- bytes: z.nullable(z.array(z.int())),
363
- logprob: z.number(),
364
- token: z.string(),
365
- });
366
- export function refusalTopLogprobFromJSON(jsonString) {
367
- return safeParse(jsonString, (x) => RefusalTopLogprob$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RefusalTopLogprob' from JSON`);
368
- }
369
- /** @internal */
370
- export const Refusal$inboundSchema = z.object({
371
- bytes: z.nullable(z.array(z.int())),
372
- logprob: z.number(),
373
- token: z.string(),
374
- top_logprobs: z.array(z.lazy(() => RefusalTopLogprob$inboundSchema)),
375
- }).transform((v) => {
376
- return remap$(v, {
377
- "top_logprobs": "topLogprobs",
378
- });
379
- });
380
- export function refusalFromJSON(jsonString) {
381
- return safeParse(jsonString, (x) => Refusal$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Refusal' from JSON`);
382
- }
383
- /** @internal */
384
- export const Logprobs$inboundSchema = z.object({
385
- content: z.nullable(z.array(z.lazy(() => LogprobsContent$inboundSchema))),
386
- refusal: z.nullable(z.array(z.lazy(() => Refusal$inboundSchema))).optional(),
387
- });
388
- export function logprobsFromJSON(jsonString) {
389
- return safeParse(jsonString, (x) => Logprobs$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Logprobs' from JSON`);
390
- }
391
- /** @internal */
392
- export const WebSearchCitation$inboundSchema = z.object({
393
- cited_text: z.string().optional(),
394
- encrypted_index: z.string().optional(),
395
- title: z.nullable(z.string()),
396
- url: z.string(),
397
- }).transform((v) => {
398
- return remap$(v, {
399
- "cited_text": "citedText",
400
- "encrypted_index": "encryptedIndex",
401
- });
402
- });
403
- export function webSearchCitationFromJSON(jsonString) {
404
- return safeParse(jsonString, (x) => WebSearchCitation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebSearchCitation' from JSON`);
405
- }
406
- /** @internal */
407
- export const AnnotationWebSearchCitation$inboundSchema = z.object({
408
- type: z.literal("web_search_citation"),
409
- web_search_citation: z.lazy(() => WebSearchCitation$inboundSchema),
410
- }).transform((v) => {
411
- return remap$(v, {
412
- "web_search_citation": "webSearchCitation",
413
- });
414
- });
415
- export function annotationWebSearchCitationFromJSON(jsonString) {
416
- return safeParse(jsonString, (x) => AnnotationWebSearchCitation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AnnotationWebSearchCitation' from JSON`);
417
- }
418
- /** @internal */
419
- export const BatchObjectUrlCitation$inboundSchema = z.object({
420
- content: z.string().optional(),
421
- end_index: z.int(),
422
- start_index: z.int(),
423
- title: z.string(),
424
- uncited: z.literal(true).optional(),
425
- url: z.string(),
426
- }).transform((v) => {
427
- return remap$(v, {
428
- "end_index": "endIndex",
429
- "start_index": "startIndex",
430
- });
431
- });
432
- export function batchObjectUrlCitationFromJSON(jsonString) {
433
- return safeParse(jsonString, (x) => BatchObjectUrlCitation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObjectUrlCitation' from JSON`);
434
- }
435
- /** @internal */
436
- export const AnnotationURLCitation$inboundSchema = z.object({
437
- type: z.literal("url_citation"),
438
- url_citation: z.lazy(() => BatchObjectUrlCitation$inboundSchema),
439
- }).transform((v) => {
440
- return remap$(v, {
441
- "url_citation": "urlCitation",
442
- });
443
- });
444
- export function annotationURLCitationFromJSON(jsonString) {
445
- return safeParse(jsonString, (x) => AnnotationURLCitation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AnnotationURLCitation' from JSON`);
446
- }
447
- /** @internal */
448
- export const ContentImageUrlImageUrl$inboundSchema = z.object({
449
- url: z.string(),
450
- });
451
- export function contentImageUrlImageUrlFromJSON(jsonString) {
452
- return safeParse(jsonString, (x) => ContentImageUrlImageUrl$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentImageUrlImageUrl' from JSON`);
453
- }
454
- /** @internal */
455
- export const ContentImageURL$inboundSchema = z.object({
456
- image_url: z.lazy(() => ContentImageUrlImageUrl$inboundSchema),
457
- type: z.literal("image_url"),
458
- }).transform((v) => {
459
- return remap$(v, {
460
- "image_url": "imageUrl",
461
- });
462
- });
463
- export function contentImageURLFromJSON(jsonString) {
464
- return safeParse(jsonString, (x) => ContentImageURL$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentImageURL' from JSON`);
465
- }
466
- /** @internal */
467
- export const ContentText$inboundSchema = z
468
- .object({
469
- text: z.string(),
470
- type: z.literal("text"),
471
- });
472
- export function contentTextFromJSON(jsonString) {
473
- return safeParse(jsonString, (x) => ContentText$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ContentText' from JSON`);
474
- }
475
- /** @internal */
476
- export const AnnotationContentUnion$inboundSchema = discriminatedUnion("type", {
477
- text: z.lazy(() => ContentText$inboundSchema),
478
- image_url: z.lazy(() => ContentImageURL$inboundSchema),
479
- });
480
- export function annotationContentUnionFromJSON(jsonString) {
481
- return safeParse(jsonString, (x) => AnnotationContentUnion$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AnnotationContentUnion' from JSON`);
482
- }
483
- /** @internal */
484
- export const BatchObjectFile$inboundSchema = z.object({
485
- content: z.array(discriminatedUnion("type", {
486
- text: z.lazy(() => ContentText$inboundSchema),
487
- image_url: z.lazy(() => ContentImageURL$inboundSchema),
488
- })),
489
- hash: z.string(),
490
- name: z.string().optional(),
491
- });
492
- export function batchObjectFileFromJSON(jsonString) {
493
- return safeParse(jsonString, (x) => BatchObjectFile$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObjectFile' from JSON`);
494
- }
495
- /** @internal */
496
- export const AnnotationFile$inboundSchema = z.object({
497
- file: z.lazy(() => BatchObjectFile$inboundSchema),
498
- type: z.literal("file"),
499
- });
500
- export function annotationFileFromJSON(jsonString) {
501
- return safeParse(jsonString, (x) => AnnotationFile$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AnnotationFile' from JSON`);
502
- }
503
- /** @internal */
504
- export const Annotation$inboundSchema = discriminatedUnion("type", {
505
- file: z.lazy(() => AnnotationFile$inboundSchema),
506
- url_citation: z.lazy(() => AnnotationURLCitation$inboundSchema),
507
- web_search_citation: z.lazy(() => AnnotationWebSearchCitation$inboundSchema),
508
- });
509
- export function annotationFromJSON(jsonString) {
510
- return safeParse(jsonString, (x) => Annotation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Annotation' from JSON`);
511
- }
512
- /** @internal */
513
- export const BatchObjectImageUrl$inboundSchema = z.object({
514
- url: z.string(),
515
- });
516
- export function batchObjectImageUrlFromJSON(jsonString) {
517
- return safeParse(jsonString, (x) => BatchObjectImageUrl$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObjectImageUrl' from JSON`);
518
- }
519
- /** @internal */
520
- export const ChoiceTypeImageURLEnum$inboundSchema = z.enum(ChoiceTypeImageURLEnum);
521
- /** @internal */
522
- export const Image$inboundSchema = z.object({
523
- image_url: z.lazy(() => BatchObjectImageUrl$inboundSchema),
524
- type: ChoiceTypeImageURLEnum$inboundSchema,
525
- }).transform((v) => {
526
- return remap$(v, {
527
- "image_url": "imageUrl",
528
- });
529
- });
530
- export function imageFromJSON(jsonString) {
531
- return safeParse(jsonString, (x) => Image$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Image' from JSON`);
532
- }
533
- /** @internal */
534
- export const ReasoningDetail$inboundSchema = discriminatedUnion("type", {
535
- ["reasoning.summary"]: ReasoningDetailSummary$inboundSchema,
536
- ["reasoning.encrypted"]: ReasoningDetailEncrypted$inboundSchema,
537
- ["reasoning.text"]: ReasoningDetailText$inboundSchema,
538
- ["reasoning.server_tool_call"]: ReasoningDetailServerToolCall$inboundSchema,
539
- });
540
- export function reasoningDetailFromJSON(jsonString) {
541
- return safeParse(jsonString, (x) => ReasoningDetail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ReasoningDetail' from JSON`);
542
- }
543
- /** @internal */
544
- export const ChoiceRole$inboundSchema = z.enum(ChoiceRole);
545
- /** @internal */
546
- export const BatchObjectFunction$inboundSchema = z.object({
547
- arguments: z.string(),
548
- name: z.string(),
549
- });
550
- export function batchObjectFunctionFromJSON(jsonString) {
551
- return safeParse(jsonString, (x) => BatchObjectFunction$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObjectFunction' from JSON`);
552
- }
553
- /** @internal */
554
- export const ChoiceTypeFunction$inboundSchema = z.enum(ChoiceTypeFunction);
555
- /** @internal */
556
- export const ToolCall$inboundSchema = z.object({
557
- function: z.lazy(() => BatchObjectFunction$inboundSchema),
558
- id: z.string(),
559
- index: z.int(),
560
- type: ChoiceTypeFunction$inboundSchema,
561
- });
562
- export function toolCallFromJSON(jsonString) {
563
- return safeParse(jsonString, (x) => ToolCall$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ToolCall' from JSON`);
564
- }
565
- /** @internal */
566
- export const Message$inboundSchema = z.object({
567
- annotations: z.array(discriminatedUnion("type", {
568
- file: z.lazy(() => AnnotationFile$inboundSchema),
569
- url_citation: z.lazy(() => AnnotationURLCitation$inboundSchema),
570
- web_search_citation: z.lazy(() => AnnotationWebSearchCitation$inboundSchema),
571
- })).optional(),
572
- content: z.nullable(z.string()),
573
- images: z.nullable(z.array(z.lazy(() => Image$inboundSchema))).optional(),
574
- reasoning: z.nullable(z.string()).optional(),
575
- reasoning_details: z.nullable(z.array(z.nullable(discriminatedUnion("type", {
576
- ["reasoning.summary"]: ReasoningDetailSummary$inboundSchema,
577
- ["reasoning.encrypted"]: ReasoningDetailEncrypted$inboundSchema,
578
- ["reasoning.text"]: ReasoningDetailText$inboundSchema,
579
- ["reasoning.server_tool_call"]: ReasoningDetailServerToolCall$inboundSchema,
580
- })))).optional(),
581
- refusal: z.nullable(z.string()),
582
- role: ChoiceRole$inboundSchema,
583
- tool_calls: z.array(z.lazy(() => ToolCall$inboundSchema)).optional(),
584
- }).transform((v) => {
585
- return remap$(v, {
586
- "reasoning_details": "reasoningDetails",
587
- "tool_calls": "toolCalls",
588
- });
589
- });
590
- export function messageFromJSON(jsonString) {
591
- return safeParse(jsonString, (x) => Message$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Message' from JSON`);
592
- }
593
- /** @internal */
594
- export const Choice$inboundSchema = z.object({
595
- finish_reason: FinishReason$inboundSchema,
596
- index: z.int(),
597
- logprobs: z.nullable(z.lazy(() => Logprobs$inboundSchema)),
598
- message: z.lazy(() => Message$inboundSchema),
599
- native_finish_reason: z.nullable(z.string()),
600
- }).transform((v) => {
601
- return remap$(v, {
602
- "finish_reason": "finishReason",
603
- "native_finish_reason": "nativeFinishReason",
604
- });
605
- });
606
- export function choiceFromJSON(jsonString) {
607
- return safeParse(jsonString, (x) => Choice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Choice' from JSON`);
608
- }
609
- /** @internal */
610
- export const BatchObjectEvent$inboundSchema = openEnums.inboundSchema(BatchObjectEvent);
611
- /** @internal */
612
- export const BatchObjectTimings$inboundSchema = z.object({
613
- epoch_ms: z.int(),
614
- event: BatchObjectEvent$inboundSchema,
615
- start_ms: z.int(),
616
- }).transform((v) => {
617
- return remap$(v, {
618
- "epoch_ms": "epochMs",
619
- "start_ms": "startMs",
620
- });
621
- });
622
- export function batchObjectTimingsFromJSON(jsonString) {
623
- return safeParse(jsonString, (x) => BatchObjectTimings$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObjectTimings' from JSON`);
624
- }
625
- /** @internal */
626
- export const BatchObjectDebug$inboundSchema = collectExtraKeys$(z.object({
627
- echo_upstream_body: z.record(z.string(), z.any()).optional(),
628
- timings: z.lazy(() => BatchObjectTimings$inboundSchema).optional(),
629
- }).catchall(z.any()), "additionalProperties", true).transform((v) => {
630
- return remap$(v, {
631
- "echo_upstream_body": "echoUpstreamBody",
632
- });
633
- });
634
- export function batchObjectDebugFromJSON(jsonString) {
635
- return safeParse(jsonString, (x) => BatchObjectDebug$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObjectDebug' from JSON`);
636
- }
637
- /** @internal */
638
- export const BodyObjectChatCompletion$inboundSchema = z.enum(BodyObjectChatCompletion);
639
- /** @internal */
640
- export const BodyCompletionTokensDetails$inboundSchema = z.object({
641
- audio_tokens: z.nullable(z.int()).optional(),
642
- image_tokens: z.nullable(z.int()).optional(),
643
- reasoning_tokens: z.nullable(z.int()).optional(),
644
- }).transform((v) => {
645
- return remap$(v, {
646
- "audio_tokens": "audioTokens",
647
- "image_tokens": "imageTokens",
648
- "reasoning_tokens": "reasoningTokens",
649
- });
650
- });
651
- export function bodyCompletionTokensDetailsFromJSON(jsonString) {
652
- return safeParse(jsonString, (x) => BodyCompletionTokensDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyCompletionTokensDetails' from JSON`);
653
- }
654
- /** @internal */
655
- export const BodyPromptTokensDetails1$inboundSchema = z.object({
656
- audio_tokens: z.nullable(z.int()).optional(),
657
- cache_write_tokens: z.nullable(z.int()).optional(),
658
- cached_tokens: z.nullable(z.int()).optional(),
659
- file_tokens: z.nullable(z.int()).optional(),
660
- video_tokens: z.nullable(z.int()).optional(),
661
- }).transform((v) => {
662
- return remap$(v, {
663
- "audio_tokens": "audioTokens",
664
- "cache_write_tokens": "cacheWriteTokens",
665
- "cached_tokens": "cachedTokens",
666
- "file_tokens": "fileTokens",
667
- "video_tokens": "videoTokens",
668
- });
669
- });
670
- export function bodyPromptTokensDetails1FromJSON(jsonString) {
671
- return safeParse(jsonString, (x) => BodyPromptTokensDetails1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyPromptTokensDetails1' from JSON`);
672
- }
673
- /** @internal */
674
- export const BodyServerToolUse$inboundSchema = z.object({
675
- tool_calls_executed: z.nullable(z.int()).optional(),
676
- tool_calls_requested: z.nullable(z.int()).optional(),
677
- web_search_requests: z.nullable(z.int()).optional(),
678
- }).transform((v) => {
679
- return remap$(v, {
680
- "tool_calls_executed": "toolCallsExecuted",
681
- "tool_calls_requested": "toolCallsRequested",
682
- "web_search_requests": "webSearchRequests",
683
- });
684
- });
685
- export function bodyServerToolUseFromJSON(jsonString) {
686
- return safeParse(jsonString, (x) => BodyServerToolUse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyServerToolUse' from JSON`);
687
- }
688
- /** @internal */
689
- export const BatchObjectServerToolUseDetails$inboundSchema = z.object({
690
- tool_calls_executed: z.nullable(z.int()).optional(),
691
- tool_calls_requested: z.nullable(z.int()).optional(),
692
- web_search_requests: z.nullable(z.int()).optional(),
693
- }).transform((v) => {
694
- return remap$(v, {
695
- "tool_calls_executed": "toolCallsExecuted",
696
- "tool_calls_requested": "toolCallsRequested",
697
- "web_search_requests": "webSearchRequests",
698
- });
699
- });
700
- export function batchObjectServerToolUseDetailsFromJSON(jsonString) {
701
- return safeParse(jsonString, (x) => BatchObjectServerToolUseDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObjectServerToolUseDetails' from JSON`);
702
- }
703
- /** @internal */
704
- export const BodyUsage1$inboundSchema = z
705
- .object({
706
- completion_tokens: z.int(),
707
- completion_tokens_details: z.nullable(z.lazy(() => BodyCompletionTokensDetails$inboundSchema)).optional(),
708
- prompt_tokens: z.int(),
709
- prompt_tokens_details: z.nullable(z.lazy(() => BodyPromptTokensDetails1$inboundSchema)).optional(),
710
- server_tool_use: z.nullable(z.lazy(() => BodyServerToolUse$inboundSchema))
711
- .optional(),
712
- server_tool_use_details: z.nullable(z.lazy(() => BatchObjectServerToolUseDetails$inboundSchema)).optional(),
713
- total_tokens: z.int(),
714
- }).transform((v) => {
715
- return remap$(v, {
716
- "completion_tokens": "completionTokens",
717
- "completion_tokens_details": "completionTokensDetails",
718
- "prompt_tokens": "promptTokens",
719
- "prompt_tokens_details": "promptTokensDetails",
720
- "server_tool_use": "serverToolUse",
721
- "server_tool_use_details": "serverToolUseDetails",
722
- "total_tokens": "totalTokens",
723
- });
724
- });
725
- export function bodyUsage1FromJSON(jsonString) {
726
- return safeParse(jsonString, (x) => BodyUsage1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyUsage1' from JSON`);
727
- }
728
- /** @internal */
729
- export const BodyChatCompletion$inboundSchema = z.object({
730
- alignment: Alignment$inboundSchema.optional(),
731
- choices: z.array(z.lazy(() => Choice$inboundSchema)),
732
- created: z.int(),
733
- debug: z.lazy(() => BatchObjectDebug$inboundSchema).optional(),
734
- id: z.string(),
735
- model: z.string(),
736
- object: BodyObjectChatCompletion$inboundSchema,
737
- openrouter_metadata: OpenRouterMetadata$inboundSchema.optional(),
738
- provider: z.nullable(z.string()).optional(),
739
- safeguard_results: z.array(ArmorSafeguardResult$inboundSchema).optional(),
740
- service_tier: z.nullable(z.string()).optional(),
741
- system_fingerprint: z.nullable(z.string()).optional(),
742
- usage: z.lazy(() => BodyUsage1$inboundSchema).optional(),
743
- }).transform((v) => {
744
- return remap$(v, {
745
- "openrouter_metadata": "openrouterMetadata",
746
- "safeguard_results": "safeguardResults",
747
- "service_tier": "serviceTier",
748
- "system_fingerprint": "systemFingerprint",
749
- });
750
- });
751
- export function bodyChatCompletionFromJSON(jsonString) {
752
- return safeParse(jsonString, (x) => BodyChatCompletion$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyChatCompletion' from JSON`);
753
- }
754
- /** @internal */
755
- export const Body$inboundSchema = z.union([
756
- OpenResponsesResult$inboundSchema,
757
- z.lazy(() => BodyMessage$inboundSchema),
758
- z.lazy(() => BodyChatCompletion$inboundSchema),
759
- z.lazy(() => BodyAudioSpeech$inboundSchema),
760
- z.lazy(() => BodyList$inboundSchema),
761
- ]);
762
- export function bodyFromJSON(jsonString) {
763
- return safeParse(jsonString, (x) => Body$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Body' from JSON`);
764
- }
765
- /** @internal */
766
- export const BatchObjectResponse$inboundSchema = z.object({
767
- body: z.union([
768
- OpenResponsesResult$inboundSchema,
769
- z.lazy(() => BodyMessage$inboundSchema),
770
- z.lazy(() => BodyChatCompletion$inboundSchema),
771
- z.lazy(() => BodyAudioSpeech$inboundSchema),
772
- z.lazy(() => BodyList$inboundSchema),
773
- ]),
774
- request_id: z.nullable(z.string()),
775
- status_code: z.int(),
776
- }).transform((v) => {
777
- return remap$(v, {
778
- "request_id": "requestId",
779
- "status_code": "statusCode",
780
- });
781
- });
782
- export function batchObjectResponseFromJSON(jsonString) {
783
- return safeParse(jsonString, (x) => BatchObjectResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObjectResponse' from JSON`);
784
- }
785
- /** @internal */
786
- export const Result$inboundSchema = z.object({
787
- custom_id: z.string(),
788
- error: z.nullable(z.lazy(() => ResultError$inboundSchema)),
789
- id: z.string(),
790
- response: z.nullable(z.lazy(() => BatchObjectResponse$inboundSchema)),
791
- }).transform((v) => {
792
- return remap$(v, {
793
- "custom_id": "customId",
794
- });
795
- });
796
- export function resultFromJSON(jsonString) {
797
- return safeParse(jsonString, (x) => Result$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Result' from JSON`);
798
- }
799
- /** @internal */
800
51
  export const BatchObjectStatus$inboundSchema = openEnums.inboundSchema(BatchObjectStatus);
801
52
  /** @internal */
802
53
  export const BatchObjectCompletionTokensDetails$inboundSchema = z.object({
@@ -891,11 +142,11 @@ export const BatchObject$inboundSchema = z
891
142
  finalized_at: z.nullable(z.int()),
892
143
  id: z.string(),
893
144
  model: z.string(),
894
- object: BatchObjectObjectBatch$inboundSchema,
145
+ object: BatchObjectObject$inboundSchema,
895
146
  output: BatchOutputReference$inboundSchema.optional(),
896
147
  provider: z.nullable(z.string()),
897
148
  request_counts: z.lazy(() => BatchObjectRequestCounts$inboundSchema),
898
- results: z.nullable(z.array(z.lazy(() => Result$inboundSchema))),
149
+ results: z.nullable(z.array(BatchResult$inboundSchema)),
899
150
  status: BatchObjectStatus$inboundSchema,
900
151
  usage: z.nullable(z.lazy(() => BatchObjectUsage$inboundSchema)),
901
152
  }).transform((v) => {