@adaline/gateway 0.0.1

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.
@@ -0,0 +1,4021 @@
1
+ import { z } from 'zod';
2
+ import { ChatModelV1, EmbeddingModelV1 } from '@adaline/provider';
3
+ import { AxiosInstance } from 'axios';
4
+
5
+ declare class GatewayError extends Error {
6
+ status: number;
7
+ data: unknown;
8
+ constructor(message: string, status?: number, data?: unknown);
9
+ }
10
+
11
+ interface HttpClient {
12
+ stream<T>(url: string, method: "get" | "post", data?: Record<string, unknown>, headers?: Record<string, string>, options?: {
13
+ abortSignal?: AbortSignal;
14
+ }): AsyncGenerator<T, void, unknown>;
15
+ get<T>(url: string, params?: Record<string, unknown>, headers?: Record<string, string | undefined>): Promise<HttpClientResponse<T>>;
16
+ post<T>(url: string, data?: Record<string, unknown>, headers?: Record<string, string | undefined>): Promise<HttpClientResponse<T>>;
17
+ put<T>(url: string, data?: Record<string, unknown>, headers?: Record<string, string | undefined>): Promise<HttpClientResponse<T>>;
18
+ delete<T>(url: string, params?: Record<string, unknown>, headers?: Record<string, string | undefined>): Promise<HttpClientResponse<T>>;
19
+ patch<T>(url: string, data?: Record<string, unknown>, headers?: Record<string, string | undefined>): Promise<HttpClientResponse<T>>;
20
+ }
21
+ interface HttpClientResponse<T> {
22
+ data: T;
23
+ headers: Record<string, string>;
24
+ status: {
25
+ code: number;
26
+ text: string;
27
+ };
28
+ }
29
+
30
+ interface HttpClientConfig {
31
+ timeoutInMilliseconds?: number;
32
+ axiosInstance?: AxiosInstance;
33
+ }
34
+ declare class IsomorphicHttpClientError extends Error {
35
+ status: number;
36
+ data: unknown;
37
+ constructor(message: string, status?: number, data?: unknown);
38
+ }
39
+ declare class IsomorphicHttpClient implements HttpClient {
40
+ private defaultTimeout?;
41
+ private client;
42
+ constructor(config: HttpClientConfig);
43
+ isNodeEnvironment: () => boolean;
44
+ private makeRequest;
45
+ stream<T>(url: string, method: "get" | "post", data?: Record<string, unknown>, headers?: Record<string, string>, // TODO: remove 'undefined', fix in stream-chat.handler.ts
46
+ options?: {
47
+ abortSignal?: AbortSignal;
48
+ }): AsyncGenerator<T, void, unknown>;
49
+ get<T>(url: string, params?: Record<string, unknown>, headers?: Record<string, string | undefined>): Promise<HttpClientResponse<T>>;
50
+ post<T>(url: string, data?: Record<string, unknown>, headers?: Record<string, string | undefined>): Promise<HttpClientResponse<T>>;
51
+ put<T>(url: string, data?: Record<string, unknown>, headers?: Record<string, string | undefined>): Promise<HttpClientResponse<T>>;
52
+ delete<T>(url: string, params?: Record<string, unknown>, headers?: Record<string, string | undefined>): Promise<HttpClientResponse<T>>;
53
+ patch<T>(url: string, data?: Record<string, unknown>, headers?: Record<string, string | undefined>): Promise<HttpClientResponse<T>>;
54
+ static IsomorphicHttpClientError: typeof IsomorphicHttpClientError;
55
+ }
56
+
57
+ type Task<Request, Response> = {
58
+ tryCount: number;
59
+ modelIndex: number;
60
+ inputTokens: number;
61
+ queueTime: number;
62
+ attemptTime: number;
63
+ request: Request;
64
+ queuePriority: number | undefined;
65
+ resolve: (value: Response) => void;
66
+ execute: (request: {
67
+ modelIndex: number;
68
+ data: Request;
69
+ resolve: (value: Response) => void;
70
+ reject: (error: any) => void;
71
+ }) => Promise<void>;
72
+ reject: (error: any) => void;
73
+ };
74
+ interface Queue<Request, Response> {
75
+ enqueue(task: Task<Request, Response>): void;
76
+ }
77
+
78
+ type QueueOptions = {
79
+ maxRetries?: number;
80
+ tokensPerMinute?: number;
81
+ timeout?: number;
82
+ backOffInitialDelay?: number;
83
+ backOffMultiplier?: number;
84
+ rateLimitRetryTimeout?: number;
85
+ shouldRetry?: (status: number) => boolean;
86
+ };
87
+ declare class SimpleQueue<Req, Res> implements Queue<Req, Res> {
88
+ private queue;
89
+ private isProcessing;
90
+ private maxRetries;
91
+ private tokensPerMinute;
92
+ private timeout;
93
+ private backOffInitialDelay;
94
+ private backOffMultiplier;
95
+ private rateLimitRetryTimeout;
96
+ private shouldRetry;
97
+ constructor(options: QueueOptions);
98
+ enqueue(task: Task<Req, Res>): void;
99
+ private calculateBackoff;
100
+ private processQueue;
101
+ private execute;
102
+ }
103
+
104
+ declare const CompleteChatHandlerRequest: z.ZodObject<{
105
+ model: z.ZodType<ChatModelV1<{
106
+ name: string;
107
+ description: string;
108
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
109
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
110
+ maxInputTokens: number;
111
+ maxOutputTokens: number;
112
+ config: {
113
+ def: Record<string, {
114
+ type: "multi-string";
115
+ param: string;
116
+ title: string;
117
+ description: string;
118
+ max: number;
119
+ } | {
120
+ type: "range";
121
+ param: string;
122
+ title: string;
123
+ description: string;
124
+ max: number;
125
+ min: number;
126
+ step: number;
127
+ default: number;
128
+ } | {
129
+ type: "select-string";
130
+ param: string;
131
+ title: string;
132
+ description: string;
133
+ default: string;
134
+ choices: string[];
135
+ } | {
136
+ type: "object-schema";
137
+ param: string;
138
+ title: string;
139
+ description: string;
140
+ objectSchema?: any;
141
+ }>;
142
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
143
+ };
144
+ }>, z.ZodTypeDef, ChatModelV1<{
145
+ name: string;
146
+ description: string;
147
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
148
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
149
+ maxInputTokens: number;
150
+ maxOutputTokens: number;
151
+ config: {
152
+ def: Record<string, {
153
+ type: "multi-string";
154
+ param: string;
155
+ title: string;
156
+ description: string;
157
+ max: number;
158
+ } | {
159
+ type: "range";
160
+ param: string;
161
+ title: string;
162
+ description: string;
163
+ max: number;
164
+ min: number;
165
+ step: number;
166
+ default: number;
167
+ } | {
168
+ type: "select-string";
169
+ param: string;
170
+ title: string;
171
+ description: string;
172
+ default: string;
173
+ choices: string[];
174
+ } | {
175
+ type: "object-schema";
176
+ param: string;
177
+ title: string;
178
+ description: string;
179
+ objectSchema?: any;
180
+ }>;
181
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
182
+ };
183
+ }>>;
184
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
185
+ messages: z.ZodArray<z.ZodObject<{
186
+ role: z.ZodEnum<["system", "user", "assistant", "tool"]>;
187
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"modality", [z.ZodObject<{
188
+ modality: z.ZodLiteral<"text">;
189
+ value: z.ZodString;
190
+ metadata: z.ZodUndefined;
191
+ }, "strip", z.ZodTypeAny, {
192
+ value: string;
193
+ modality: "text";
194
+ metadata?: undefined;
195
+ }, {
196
+ value: string;
197
+ modality: "text";
198
+ metadata?: undefined;
199
+ }>, z.ZodObject<{
200
+ modality: z.ZodLiteral<"image">;
201
+ detail: z.ZodEnum<["low", "medium", "high", "auto"]>;
202
+ value: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
203
+ type: z.ZodLiteral<"base64">;
204
+ base64: z.ZodString;
205
+ }, "strip", z.ZodTypeAny, {
206
+ type: "base64";
207
+ base64: string;
208
+ }, {
209
+ type: "base64";
210
+ base64: string;
211
+ }>, z.ZodObject<{
212
+ type: z.ZodLiteral<"url">;
213
+ url: z.ZodString;
214
+ }, "strip", z.ZodTypeAny, {
215
+ type: "url";
216
+ url: string;
217
+ }, {
218
+ type: "url";
219
+ url: string;
220
+ }>]>;
221
+ metadata: z.ZodUndefined;
222
+ }, "strip", z.ZodTypeAny, {
223
+ value: {
224
+ type: "base64";
225
+ base64: string;
226
+ } | {
227
+ type: "url";
228
+ url: string;
229
+ };
230
+ modality: "image";
231
+ detail: "low" | "medium" | "high" | "auto";
232
+ metadata?: undefined;
233
+ }, {
234
+ value: {
235
+ type: "base64";
236
+ base64: string;
237
+ } | {
238
+ type: "url";
239
+ url: string;
240
+ };
241
+ modality: "image";
242
+ detail: "low" | "medium" | "high" | "auto";
243
+ metadata?: undefined;
244
+ }>, z.ZodObject<{
245
+ modality: z.ZodLiteral<"tool-call">;
246
+ index: z.ZodNumber;
247
+ id: z.ZodString;
248
+ name: z.ZodString;
249
+ arguments: z.ZodString;
250
+ metadata: z.ZodUndefined;
251
+ }, "strip", z.ZodTypeAny, {
252
+ name: string;
253
+ modality: "tool-call";
254
+ index: number;
255
+ id: string;
256
+ arguments: string;
257
+ metadata?: undefined;
258
+ }, {
259
+ name: string;
260
+ modality: "tool-call";
261
+ index: number;
262
+ id: string;
263
+ arguments: string;
264
+ metadata?: undefined;
265
+ }>, z.ZodObject<{
266
+ modality: z.ZodLiteral<"tool-response">;
267
+ index: z.ZodNumber;
268
+ id: z.ZodString;
269
+ name: z.ZodString;
270
+ data: z.ZodString;
271
+ metadata: z.ZodUndefined;
272
+ }, "strip", z.ZodTypeAny, {
273
+ data: string;
274
+ name: string;
275
+ modality: "tool-response";
276
+ index: number;
277
+ id: string;
278
+ metadata?: undefined;
279
+ }, {
280
+ data: string;
281
+ name: string;
282
+ modality: "tool-response";
283
+ index: number;
284
+ id: string;
285
+ metadata?: undefined;
286
+ }>]>, "many">;
287
+ metadata: z.ZodUndefined;
288
+ }, "strip", z.ZodTypeAny, {
289
+ role: "system" | "user" | "assistant" | "tool";
290
+ content: ({
291
+ value: string;
292
+ modality: "text";
293
+ metadata?: undefined;
294
+ } | {
295
+ value: {
296
+ type: "base64";
297
+ base64: string;
298
+ } | {
299
+ type: "url";
300
+ url: string;
301
+ };
302
+ modality: "image";
303
+ detail: "low" | "medium" | "high" | "auto";
304
+ metadata?: undefined;
305
+ } | {
306
+ name: string;
307
+ modality: "tool-call";
308
+ index: number;
309
+ id: string;
310
+ arguments: string;
311
+ metadata?: undefined;
312
+ } | {
313
+ data: string;
314
+ name: string;
315
+ modality: "tool-response";
316
+ index: number;
317
+ id: string;
318
+ metadata?: undefined;
319
+ })[];
320
+ metadata?: undefined;
321
+ }, {
322
+ role: "system" | "user" | "assistant" | "tool";
323
+ content: ({
324
+ value: string;
325
+ modality: "text";
326
+ metadata?: undefined;
327
+ } | {
328
+ value: {
329
+ type: "base64";
330
+ base64: string;
331
+ } | {
332
+ type: "url";
333
+ url: string;
334
+ };
335
+ modality: "image";
336
+ detail: "low" | "medium" | "high" | "auto";
337
+ metadata?: undefined;
338
+ } | {
339
+ name: string;
340
+ modality: "tool-call";
341
+ index: number;
342
+ id: string;
343
+ arguments: string;
344
+ metadata?: undefined;
345
+ } | {
346
+ data: string;
347
+ name: string;
348
+ modality: "tool-response";
349
+ index: number;
350
+ id: string;
351
+ metadata?: undefined;
352
+ })[];
353
+ metadata?: undefined;
354
+ }>, "many">;
355
+ tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<z.objectUtil.extendShape<{
356
+ type: z.ZodEnum<["function"]>;
357
+ definition: z.ZodObject<{
358
+ schema: z.ZodObject<{
359
+ name: z.ZodString;
360
+ description: z.ZodString;
361
+ parameters: z.ZodAny;
362
+ strict: z.ZodOptional<z.ZodBoolean>;
363
+ }, "strip", z.ZodTypeAny, {
364
+ name: string;
365
+ description: string;
366
+ strict?: boolean | undefined;
367
+ parameters?: any;
368
+ }, {
369
+ name: string;
370
+ description: string;
371
+ strict?: boolean | undefined;
372
+ parameters?: any;
373
+ }>;
374
+ }, "strip", z.ZodTypeAny, {
375
+ schema: {
376
+ name: string;
377
+ description: string;
378
+ strict?: boolean | undefined;
379
+ parameters?: any;
380
+ };
381
+ }, {
382
+ schema: {
383
+ name: string;
384
+ description: string;
385
+ strict?: boolean | undefined;
386
+ parameters?: any;
387
+ };
388
+ }>;
389
+ }, {
390
+ metadata: z.ZodTypeAny;
391
+ }>, "strip", z.ZodTypeAny, {
392
+ type: "function";
393
+ definition: {
394
+ schema: {
395
+ name: string;
396
+ description: string;
397
+ strict?: boolean | undefined;
398
+ parameters?: any;
399
+ };
400
+ };
401
+ metadata?: any;
402
+ }, {
403
+ type: "function";
404
+ definition: {
405
+ schema: {
406
+ name: string;
407
+ description: string;
408
+ strict?: boolean | undefined;
409
+ parameters?: any;
410
+ };
411
+ };
412
+ metadata?: any;
413
+ }>]>, "many">>;
414
+ callbacks: z.ZodOptional<z.ZodArray<z.ZodType<CompleteChatCallbackType<any>, z.ZodTypeDef, CompleteChatCallbackType<any>>, "atleastone">>;
415
+ metadataForCallbacks: z.ZodOptional<z.ZodAny>;
416
+ }, "strip", z.ZodTypeAny, {
417
+ config: Record<string, any>;
418
+ model: ChatModelV1<{
419
+ name: string;
420
+ description: string;
421
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
422
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
423
+ maxInputTokens: number;
424
+ maxOutputTokens: number;
425
+ config: {
426
+ def: Record<string, {
427
+ type: "multi-string";
428
+ param: string;
429
+ title: string;
430
+ description: string;
431
+ max: number;
432
+ } | {
433
+ type: "range";
434
+ param: string;
435
+ title: string;
436
+ description: string;
437
+ max: number;
438
+ min: number;
439
+ step: number;
440
+ default: number;
441
+ } | {
442
+ type: "select-string";
443
+ param: string;
444
+ title: string;
445
+ description: string;
446
+ default: string;
447
+ choices: string[];
448
+ } | {
449
+ type: "object-schema";
450
+ param: string;
451
+ title: string;
452
+ description: string;
453
+ objectSchema?: any;
454
+ }>;
455
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
456
+ };
457
+ }>;
458
+ messages: {
459
+ role: "system" | "user" | "assistant" | "tool";
460
+ content: ({
461
+ value: string;
462
+ modality: "text";
463
+ metadata?: undefined;
464
+ } | {
465
+ value: {
466
+ type: "base64";
467
+ base64: string;
468
+ } | {
469
+ type: "url";
470
+ url: string;
471
+ };
472
+ modality: "image";
473
+ detail: "low" | "medium" | "high" | "auto";
474
+ metadata?: undefined;
475
+ } | {
476
+ name: string;
477
+ modality: "tool-call";
478
+ index: number;
479
+ id: string;
480
+ arguments: string;
481
+ metadata?: undefined;
482
+ } | {
483
+ data: string;
484
+ name: string;
485
+ modality: "tool-response";
486
+ index: number;
487
+ id: string;
488
+ metadata?: undefined;
489
+ })[];
490
+ metadata?: undefined;
491
+ }[];
492
+ tools?: {
493
+ type: "function";
494
+ definition: {
495
+ schema: {
496
+ name: string;
497
+ description: string;
498
+ strict?: boolean | undefined;
499
+ parameters?: any;
500
+ };
501
+ };
502
+ metadata?: any;
503
+ }[] | undefined;
504
+ callbacks?: [CompleteChatCallbackType<any>, ...CompleteChatCallbackType<any>[]] | undefined;
505
+ metadataForCallbacks?: any;
506
+ }, {
507
+ config: Record<string, any>;
508
+ model: ChatModelV1<{
509
+ name: string;
510
+ description: string;
511
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
512
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
513
+ maxInputTokens: number;
514
+ maxOutputTokens: number;
515
+ config: {
516
+ def: Record<string, {
517
+ type: "multi-string";
518
+ param: string;
519
+ title: string;
520
+ description: string;
521
+ max: number;
522
+ } | {
523
+ type: "range";
524
+ param: string;
525
+ title: string;
526
+ description: string;
527
+ max: number;
528
+ min: number;
529
+ step: number;
530
+ default: number;
531
+ } | {
532
+ type: "select-string";
533
+ param: string;
534
+ title: string;
535
+ description: string;
536
+ default: string;
537
+ choices: string[];
538
+ } | {
539
+ type: "object-schema";
540
+ param: string;
541
+ title: string;
542
+ description: string;
543
+ objectSchema?: any;
544
+ }>;
545
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
546
+ };
547
+ }>;
548
+ messages: {
549
+ role: "system" | "user" | "assistant" | "tool";
550
+ content: ({
551
+ value: string;
552
+ modality: "text";
553
+ metadata?: undefined;
554
+ } | {
555
+ value: {
556
+ type: "base64";
557
+ base64: string;
558
+ } | {
559
+ type: "url";
560
+ url: string;
561
+ };
562
+ modality: "image";
563
+ detail: "low" | "medium" | "high" | "auto";
564
+ metadata?: undefined;
565
+ } | {
566
+ name: string;
567
+ modality: "tool-call";
568
+ index: number;
569
+ id: string;
570
+ arguments: string;
571
+ metadata?: undefined;
572
+ } | {
573
+ data: string;
574
+ name: string;
575
+ modality: "tool-response";
576
+ index: number;
577
+ id: string;
578
+ metadata?: undefined;
579
+ })[];
580
+ metadata?: undefined;
581
+ }[];
582
+ tools?: {
583
+ type: "function";
584
+ definition: {
585
+ schema: {
586
+ name: string;
587
+ description: string;
588
+ strict?: boolean | undefined;
589
+ parameters?: any;
590
+ };
591
+ };
592
+ metadata?: any;
593
+ }[] | undefined;
594
+ callbacks?: [CompleteChatCallbackType<any>, ...CompleteChatCallbackType<any>[]] | undefined;
595
+ metadataForCallbacks?: any;
596
+ }>;
597
+ type CompleteChatHandlerRequestType = z.infer<typeof CompleteChatHandlerRequest>;
598
+ declare const CompleteChatHandlerResponse: z.ZodObject<{
599
+ request: z.ZodObject<{
600
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
601
+ messages: z.ZodArray<z.ZodObject<{
602
+ role: z.ZodEnum<["system", "user", "assistant", "tool"]>;
603
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"modality", [z.ZodObject<{
604
+ modality: z.ZodLiteral<"text">;
605
+ value: z.ZodString;
606
+ metadata: z.ZodUndefined;
607
+ }, "strip", z.ZodTypeAny, {
608
+ value: string;
609
+ modality: "text";
610
+ metadata?: undefined;
611
+ }, {
612
+ value: string;
613
+ modality: "text";
614
+ metadata?: undefined;
615
+ }>, z.ZodObject<{
616
+ modality: z.ZodLiteral<"image">;
617
+ detail: z.ZodEnum<["low", "medium", "high", "auto"]>;
618
+ value: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
619
+ type: z.ZodLiteral<"base64">;
620
+ base64: z.ZodString;
621
+ }, "strip", z.ZodTypeAny, {
622
+ type: "base64";
623
+ base64: string;
624
+ }, {
625
+ type: "base64";
626
+ base64: string;
627
+ }>, z.ZodObject<{
628
+ type: z.ZodLiteral<"url">;
629
+ url: z.ZodString;
630
+ }, "strip", z.ZodTypeAny, {
631
+ type: "url";
632
+ url: string;
633
+ }, {
634
+ type: "url";
635
+ url: string;
636
+ }>]>;
637
+ metadata: z.ZodUndefined;
638
+ }, "strip", z.ZodTypeAny, {
639
+ value: {
640
+ type: "base64";
641
+ base64: string;
642
+ } | {
643
+ type: "url";
644
+ url: string;
645
+ };
646
+ modality: "image";
647
+ detail: "low" | "medium" | "high" | "auto";
648
+ metadata?: undefined;
649
+ }, {
650
+ value: {
651
+ type: "base64";
652
+ base64: string;
653
+ } | {
654
+ type: "url";
655
+ url: string;
656
+ };
657
+ modality: "image";
658
+ detail: "low" | "medium" | "high" | "auto";
659
+ metadata?: undefined;
660
+ }>, z.ZodObject<{
661
+ modality: z.ZodLiteral<"tool-call">;
662
+ index: z.ZodNumber;
663
+ id: z.ZodString;
664
+ name: z.ZodString;
665
+ arguments: z.ZodString;
666
+ metadata: z.ZodUndefined;
667
+ }, "strip", z.ZodTypeAny, {
668
+ name: string;
669
+ modality: "tool-call";
670
+ index: number;
671
+ id: string;
672
+ arguments: string;
673
+ metadata?: undefined;
674
+ }, {
675
+ name: string;
676
+ modality: "tool-call";
677
+ index: number;
678
+ id: string;
679
+ arguments: string;
680
+ metadata?: undefined;
681
+ }>, z.ZodObject<{
682
+ modality: z.ZodLiteral<"tool-response">;
683
+ index: z.ZodNumber;
684
+ id: z.ZodString;
685
+ name: z.ZodString;
686
+ data: z.ZodString;
687
+ metadata: z.ZodUndefined;
688
+ }, "strip", z.ZodTypeAny, {
689
+ data: string;
690
+ name: string;
691
+ modality: "tool-response";
692
+ index: number;
693
+ id: string;
694
+ metadata?: undefined;
695
+ }, {
696
+ data: string;
697
+ name: string;
698
+ modality: "tool-response";
699
+ index: number;
700
+ id: string;
701
+ metadata?: undefined;
702
+ }>]>, "many">;
703
+ metadata: z.ZodUndefined;
704
+ }, "strip", z.ZodTypeAny, {
705
+ role: "system" | "user" | "assistant" | "tool";
706
+ content: ({
707
+ value: string;
708
+ modality: "text";
709
+ metadata?: undefined;
710
+ } | {
711
+ value: {
712
+ type: "base64";
713
+ base64: string;
714
+ } | {
715
+ type: "url";
716
+ url: string;
717
+ };
718
+ modality: "image";
719
+ detail: "low" | "medium" | "high" | "auto";
720
+ metadata?: undefined;
721
+ } | {
722
+ name: string;
723
+ modality: "tool-call";
724
+ index: number;
725
+ id: string;
726
+ arguments: string;
727
+ metadata?: undefined;
728
+ } | {
729
+ data: string;
730
+ name: string;
731
+ modality: "tool-response";
732
+ index: number;
733
+ id: string;
734
+ metadata?: undefined;
735
+ })[];
736
+ metadata?: undefined;
737
+ }, {
738
+ role: "system" | "user" | "assistant" | "tool";
739
+ content: ({
740
+ value: string;
741
+ modality: "text";
742
+ metadata?: undefined;
743
+ } | {
744
+ value: {
745
+ type: "base64";
746
+ base64: string;
747
+ } | {
748
+ type: "url";
749
+ url: string;
750
+ };
751
+ modality: "image";
752
+ detail: "low" | "medium" | "high" | "auto";
753
+ metadata?: undefined;
754
+ } | {
755
+ name: string;
756
+ modality: "tool-call";
757
+ index: number;
758
+ id: string;
759
+ arguments: string;
760
+ metadata?: undefined;
761
+ } | {
762
+ data: string;
763
+ name: string;
764
+ modality: "tool-response";
765
+ index: number;
766
+ id: string;
767
+ metadata?: undefined;
768
+ })[];
769
+ metadata?: undefined;
770
+ }>, "many">;
771
+ tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<z.objectUtil.extendShape<{
772
+ type: z.ZodEnum<["function"]>;
773
+ definition: z.ZodObject<{
774
+ schema: z.ZodObject<{
775
+ name: z.ZodString;
776
+ description: z.ZodString;
777
+ parameters: z.ZodAny;
778
+ strict: z.ZodOptional<z.ZodBoolean>;
779
+ }, "strip", z.ZodTypeAny, {
780
+ name: string;
781
+ description: string;
782
+ strict?: boolean | undefined;
783
+ parameters?: any;
784
+ }, {
785
+ name: string;
786
+ description: string;
787
+ strict?: boolean | undefined;
788
+ parameters?: any;
789
+ }>;
790
+ }, "strip", z.ZodTypeAny, {
791
+ schema: {
792
+ name: string;
793
+ description: string;
794
+ strict?: boolean | undefined;
795
+ parameters?: any;
796
+ };
797
+ }, {
798
+ schema: {
799
+ name: string;
800
+ description: string;
801
+ strict?: boolean | undefined;
802
+ parameters?: any;
803
+ };
804
+ }>;
805
+ }, {
806
+ metadata: z.ZodTypeAny;
807
+ }>, "strip", z.ZodTypeAny, {
808
+ type: "function";
809
+ definition: {
810
+ schema: {
811
+ name: string;
812
+ description: string;
813
+ strict?: boolean | undefined;
814
+ parameters?: any;
815
+ };
816
+ };
817
+ metadata?: any;
818
+ }, {
819
+ type: "function";
820
+ definition: {
821
+ schema: {
822
+ name: string;
823
+ description: string;
824
+ strict?: boolean | undefined;
825
+ parameters?: any;
826
+ };
827
+ };
828
+ metadata?: any;
829
+ }>]>, "many">>;
830
+ }, "strip", z.ZodTypeAny, {
831
+ config: Record<string, any>;
832
+ messages: {
833
+ role: "system" | "user" | "assistant" | "tool";
834
+ content: ({
835
+ value: string;
836
+ modality: "text";
837
+ metadata?: undefined;
838
+ } | {
839
+ value: {
840
+ type: "base64";
841
+ base64: string;
842
+ } | {
843
+ type: "url";
844
+ url: string;
845
+ };
846
+ modality: "image";
847
+ detail: "low" | "medium" | "high" | "auto";
848
+ metadata?: undefined;
849
+ } | {
850
+ name: string;
851
+ modality: "tool-call";
852
+ index: number;
853
+ id: string;
854
+ arguments: string;
855
+ metadata?: undefined;
856
+ } | {
857
+ data: string;
858
+ name: string;
859
+ modality: "tool-response";
860
+ index: number;
861
+ id: string;
862
+ metadata?: undefined;
863
+ })[];
864
+ metadata?: undefined;
865
+ }[];
866
+ tools?: {
867
+ type: "function";
868
+ definition: {
869
+ schema: {
870
+ name: string;
871
+ description: string;
872
+ strict?: boolean | undefined;
873
+ parameters?: any;
874
+ };
875
+ };
876
+ metadata?: any;
877
+ }[] | undefined;
878
+ }, {
879
+ config: Record<string, any>;
880
+ messages: {
881
+ role: "system" | "user" | "assistant" | "tool";
882
+ content: ({
883
+ value: string;
884
+ modality: "text";
885
+ metadata?: undefined;
886
+ } | {
887
+ value: {
888
+ type: "base64";
889
+ base64: string;
890
+ } | {
891
+ type: "url";
892
+ url: string;
893
+ };
894
+ modality: "image";
895
+ detail: "low" | "medium" | "high" | "auto";
896
+ metadata?: undefined;
897
+ } | {
898
+ name: string;
899
+ modality: "tool-call";
900
+ index: number;
901
+ id: string;
902
+ arguments: string;
903
+ metadata?: undefined;
904
+ } | {
905
+ data: string;
906
+ name: string;
907
+ modality: "tool-response";
908
+ index: number;
909
+ id: string;
910
+ metadata?: undefined;
911
+ })[];
912
+ metadata?: undefined;
913
+ }[];
914
+ tools?: {
915
+ type: "function";
916
+ definition: {
917
+ schema: {
918
+ name: string;
919
+ description: string;
920
+ strict?: boolean | undefined;
921
+ parameters?: any;
922
+ };
923
+ };
924
+ metadata?: any;
925
+ }[] | undefined;
926
+ }>;
927
+ response: z.ZodArray<z.ZodObject<{
928
+ role: z.ZodEnum<["system", "user", "assistant", "tool"]>;
929
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"modality", [z.ZodObject<{
930
+ modality: z.ZodLiteral<"text">;
931
+ value: z.ZodString;
932
+ metadata: z.ZodUndefined;
933
+ }, "strip", z.ZodTypeAny, {
934
+ value: string;
935
+ modality: "text";
936
+ metadata?: undefined;
937
+ }, {
938
+ value: string;
939
+ modality: "text";
940
+ metadata?: undefined;
941
+ }>, z.ZodObject<{
942
+ modality: z.ZodLiteral<"image">;
943
+ detail: z.ZodEnum<["low", "medium", "high", "auto"]>;
944
+ value: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
945
+ type: z.ZodLiteral<"base64">;
946
+ base64: z.ZodString;
947
+ }, "strip", z.ZodTypeAny, {
948
+ type: "base64";
949
+ base64: string;
950
+ }, {
951
+ type: "base64";
952
+ base64: string;
953
+ }>, z.ZodObject<{
954
+ type: z.ZodLiteral<"url">;
955
+ url: z.ZodString;
956
+ }, "strip", z.ZodTypeAny, {
957
+ type: "url";
958
+ url: string;
959
+ }, {
960
+ type: "url";
961
+ url: string;
962
+ }>]>;
963
+ metadata: z.ZodUndefined;
964
+ }, "strip", z.ZodTypeAny, {
965
+ value: {
966
+ type: "base64";
967
+ base64: string;
968
+ } | {
969
+ type: "url";
970
+ url: string;
971
+ };
972
+ modality: "image";
973
+ detail: "low" | "medium" | "high" | "auto";
974
+ metadata?: undefined;
975
+ }, {
976
+ value: {
977
+ type: "base64";
978
+ base64: string;
979
+ } | {
980
+ type: "url";
981
+ url: string;
982
+ };
983
+ modality: "image";
984
+ detail: "low" | "medium" | "high" | "auto";
985
+ metadata?: undefined;
986
+ }>, z.ZodObject<{
987
+ modality: z.ZodLiteral<"tool-call">;
988
+ index: z.ZodNumber;
989
+ id: z.ZodString;
990
+ name: z.ZodString;
991
+ arguments: z.ZodString;
992
+ metadata: z.ZodUndefined;
993
+ }, "strip", z.ZodTypeAny, {
994
+ name: string;
995
+ modality: "tool-call";
996
+ index: number;
997
+ id: string;
998
+ arguments: string;
999
+ metadata?: undefined;
1000
+ }, {
1001
+ name: string;
1002
+ modality: "tool-call";
1003
+ index: number;
1004
+ id: string;
1005
+ arguments: string;
1006
+ metadata?: undefined;
1007
+ }>, z.ZodObject<{
1008
+ modality: z.ZodLiteral<"tool-response">;
1009
+ index: z.ZodNumber;
1010
+ id: z.ZodString;
1011
+ name: z.ZodString;
1012
+ data: z.ZodString;
1013
+ metadata: z.ZodUndefined;
1014
+ }, "strip", z.ZodTypeAny, {
1015
+ data: string;
1016
+ name: string;
1017
+ modality: "tool-response";
1018
+ index: number;
1019
+ id: string;
1020
+ metadata?: undefined;
1021
+ }, {
1022
+ data: string;
1023
+ name: string;
1024
+ modality: "tool-response";
1025
+ index: number;
1026
+ id: string;
1027
+ metadata?: undefined;
1028
+ }>]>, "many">;
1029
+ metadata: z.ZodUndefined;
1030
+ }, "strip", z.ZodTypeAny, {
1031
+ role: "system" | "user" | "assistant" | "tool";
1032
+ content: ({
1033
+ value: string;
1034
+ modality: "text";
1035
+ metadata?: undefined;
1036
+ } | {
1037
+ value: {
1038
+ type: "base64";
1039
+ base64: string;
1040
+ } | {
1041
+ type: "url";
1042
+ url: string;
1043
+ };
1044
+ modality: "image";
1045
+ detail: "low" | "medium" | "high" | "auto";
1046
+ metadata?: undefined;
1047
+ } | {
1048
+ name: string;
1049
+ modality: "tool-call";
1050
+ index: number;
1051
+ id: string;
1052
+ arguments: string;
1053
+ metadata?: undefined;
1054
+ } | {
1055
+ data: string;
1056
+ name: string;
1057
+ modality: "tool-response";
1058
+ index: number;
1059
+ id: string;
1060
+ metadata?: undefined;
1061
+ })[];
1062
+ metadata?: undefined;
1063
+ }, {
1064
+ role: "system" | "user" | "assistant" | "tool";
1065
+ content: ({
1066
+ value: string;
1067
+ modality: "text";
1068
+ metadata?: undefined;
1069
+ } | {
1070
+ value: {
1071
+ type: "base64";
1072
+ base64: string;
1073
+ } | {
1074
+ type: "url";
1075
+ url: string;
1076
+ };
1077
+ modality: "image";
1078
+ detail: "low" | "medium" | "high" | "auto";
1079
+ metadata?: undefined;
1080
+ } | {
1081
+ name: string;
1082
+ modality: "tool-call";
1083
+ index: number;
1084
+ id: string;
1085
+ arguments: string;
1086
+ metadata?: undefined;
1087
+ } | {
1088
+ data: string;
1089
+ name: string;
1090
+ modality: "tool-response";
1091
+ index: number;
1092
+ id: string;
1093
+ metadata?: undefined;
1094
+ })[];
1095
+ metadata?: undefined;
1096
+ }>, "many">;
1097
+ latencyInMs: z.ZodNumber;
1098
+ metadataForCallbacks: z.ZodOptional<z.ZodAny>;
1099
+ provider: z.ZodObject<{
1100
+ request: z.ZodAny;
1101
+ response: z.ZodAny;
1102
+ }, "strip", z.ZodTypeAny, {
1103
+ request?: any;
1104
+ response?: any;
1105
+ }, {
1106
+ request?: any;
1107
+ response?: any;
1108
+ }>;
1109
+ }, "strip", z.ZodTypeAny, {
1110
+ request: {
1111
+ config: Record<string, any>;
1112
+ messages: {
1113
+ role: "system" | "user" | "assistant" | "tool";
1114
+ content: ({
1115
+ value: string;
1116
+ modality: "text";
1117
+ metadata?: undefined;
1118
+ } | {
1119
+ value: {
1120
+ type: "base64";
1121
+ base64: string;
1122
+ } | {
1123
+ type: "url";
1124
+ url: string;
1125
+ };
1126
+ modality: "image";
1127
+ detail: "low" | "medium" | "high" | "auto";
1128
+ metadata?: undefined;
1129
+ } | {
1130
+ name: string;
1131
+ modality: "tool-call";
1132
+ index: number;
1133
+ id: string;
1134
+ arguments: string;
1135
+ metadata?: undefined;
1136
+ } | {
1137
+ data: string;
1138
+ name: string;
1139
+ modality: "tool-response";
1140
+ index: number;
1141
+ id: string;
1142
+ metadata?: undefined;
1143
+ })[];
1144
+ metadata?: undefined;
1145
+ }[];
1146
+ tools?: {
1147
+ type: "function";
1148
+ definition: {
1149
+ schema: {
1150
+ name: string;
1151
+ description: string;
1152
+ strict?: boolean | undefined;
1153
+ parameters?: any;
1154
+ };
1155
+ };
1156
+ metadata?: any;
1157
+ }[] | undefined;
1158
+ };
1159
+ response: {
1160
+ role: "system" | "user" | "assistant" | "tool";
1161
+ content: ({
1162
+ value: string;
1163
+ modality: "text";
1164
+ metadata?: undefined;
1165
+ } | {
1166
+ value: {
1167
+ type: "base64";
1168
+ base64: string;
1169
+ } | {
1170
+ type: "url";
1171
+ url: string;
1172
+ };
1173
+ modality: "image";
1174
+ detail: "low" | "medium" | "high" | "auto";
1175
+ metadata?: undefined;
1176
+ } | {
1177
+ name: string;
1178
+ modality: "tool-call";
1179
+ index: number;
1180
+ id: string;
1181
+ arguments: string;
1182
+ metadata?: undefined;
1183
+ } | {
1184
+ data: string;
1185
+ name: string;
1186
+ modality: "tool-response";
1187
+ index: number;
1188
+ id: string;
1189
+ metadata?: undefined;
1190
+ })[];
1191
+ metadata?: undefined;
1192
+ }[];
1193
+ latencyInMs: number;
1194
+ provider: {
1195
+ request?: any;
1196
+ response?: any;
1197
+ };
1198
+ metadataForCallbacks?: any;
1199
+ }, {
1200
+ request: {
1201
+ config: Record<string, any>;
1202
+ messages: {
1203
+ role: "system" | "user" | "assistant" | "tool";
1204
+ content: ({
1205
+ value: string;
1206
+ modality: "text";
1207
+ metadata?: undefined;
1208
+ } | {
1209
+ value: {
1210
+ type: "base64";
1211
+ base64: string;
1212
+ } | {
1213
+ type: "url";
1214
+ url: string;
1215
+ };
1216
+ modality: "image";
1217
+ detail: "low" | "medium" | "high" | "auto";
1218
+ metadata?: undefined;
1219
+ } | {
1220
+ name: string;
1221
+ modality: "tool-call";
1222
+ index: number;
1223
+ id: string;
1224
+ arguments: string;
1225
+ metadata?: undefined;
1226
+ } | {
1227
+ data: string;
1228
+ name: string;
1229
+ modality: "tool-response";
1230
+ index: number;
1231
+ id: string;
1232
+ metadata?: undefined;
1233
+ })[];
1234
+ metadata?: undefined;
1235
+ }[];
1236
+ tools?: {
1237
+ type: "function";
1238
+ definition: {
1239
+ schema: {
1240
+ name: string;
1241
+ description: string;
1242
+ strict?: boolean | undefined;
1243
+ parameters?: any;
1244
+ };
1245
+ };
1246
+ metadata?: any;
1247
+ }[] | undefined;
1248
+ };
1249
+ response: {
1250
+ role: "system" | "user" | "assistant" | "tool";
1251
+ content: ({
1252
+ value: string;
1253
+ modality: "text";
1254
+ metadata?: undefined;
1255
+ } | {
1256
+ value: {
1257
+ type: "base64";
1258
+ base64: string;
1259
+ } | {
1260
+ type: "url";
1261
+ url: string;
1262
+ };
1263
+ modality: "image";
1264
+ detail: "low" | "medium" | "high" | "auto";
1265
+ metadata?: undefined;
1266
+ } | {
1267
+ name: string;
1268
+ modality: "tool-call";
1269
+ index: number;
1270
+ id: string;
1271
+ arguments: string;
1272
+ metadata?: undefined;
1273
+ } | {
1274
+ data: string;
1275
+ name: string;
1276
+ modality: "tool-response";
1277
+ index: number;
1278
+ id: string;
1279
+ metadata?: undefined;
1280
+ })[];
1281
+ metadata?: undefined;
1282
+ }[];
1283
+ latencyInMs: number;
1284
+ provider: {
1285
+ request?: any;
1286
+ response?: any;
1287
+ };
1288
+ metadataForCallbacks?: any;
1289
+ }>;
1290
+ type CompleteChatHandlerResponseType = z.infer<typeof CompleteChatHandlerResponse>;
1291
+ type CompleteChatCallbackType<M = any> = {
1292
+ onChatStart?: (metadata?: M) => Promise<void> | void;
1293
+ onChatCached?: (metadata?: M, response?: CompleteChatHandlerResponseType) => Promise<void> | void;
1294
+ onChatComplete?: (metadata?: M, response?: CompleteChatHandlerResponseType) => Promise<void> | void;
1295
+ onChatError?: (metadata?: M, error?: GatewayError) => Promise<void> | void;
1296
+ };
1297
+
1298
+ declare function handleCompleteChat(request: CompleteChatHandlerRequestType, client: HttpClient): Promise<CompleteChatHandlerResponseType>;
1299
+
1300
+ declare const GetEmbeddingsHandlerRequest: z.ZodObject<{
1301
+ model: z.ZodType<EmbeddingModelV1<{
1302
+ description: string;
1303
+ name: string;
1304
+ modalities: ["text" | "token", ...("text" | "token")[]];
1305
+ maxInputTokens: number;
1306
+ maxOutputTokens: number;
1307
+ config: {
1308
+ def: Record<string, {
1309
+ type: "multi-string";
1310
+ param: string;
1311
+ title: string;
1312
+ description: string;
1313
+ max: number;
1314
+ } | {
1315
+ type: "range";
1316
+ param: string;
1317
+ title: string;
1318
+ description: string;
1319
+ max: number;
1320
+ min: number;
1321
+ step: number;
1322
+ default: number;
1323
+ } | {
1324
+ type: "select-string";
1325
+ param: string;
1326
+ title: string;
1327
+ description: string;
1328
+ default: string;
1329
+ choices: string[];
1330
+ } | {
1331
+ type: "object-schema";
1332
+ param: string;
1333
+ title: string;
1334
+ description: string;
1335
+ objectSchema?: any;
1336
+ }>;
1337
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
1338
+ };
1339
+ }>, z.ZodTypeDef, EmbeddingModelV1<{
1340
+ description: string;
1341
+ name: string;
1342
+ modalities: ["text" | "token", ...("text" | "token")[]];
1343
+ maxInputTokens: number;
1344
+ maxOutputTokens: number;
1345
+ config: {
1346
+ def: Record<string, {
1347
+ type: "multi-string";
1348
+ param: string;
1349
+ title: string;
1350
+ description: string;
1351
+ max: number;
1352
+ } | {
1353
+ type: "range";
1354
+ param: string;
1355
+ title: string;
1356
+ description: string;
1357
+ max: number;
1358
+ min: number;
1359
+ step: number;
1360
+ default: number;
1361
+ } | {
1362
+ type: "select-string";
1363
+ param: string;
1364
+ title: string;
1365
+ description: string;
1366
+ default: string;
1367
+ choices: string[];
1368
+ } | {
1369
+ type: "object-schema";
1370
+ param: string;
1371
+ title: string;
1372
+ description: string;
1373
+ objectSchema?: any;
1374
+ }>;
1375
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
1376
+ };
1377
+ }>>;
1378
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
1379
+ embeddingRequests: z.ZodDiscriminatedUnion<"modality", [z.ZodObject<{
1380
+ modality: z.ZodLiteral<"text">;
1381
+ metadata: z.ZodUndefined;
1382
+ requests: z.ZodArray<z.ZodString, "many">;
1383
+ }, "strip", z.ZodTypeAny, {
1384
+ modality: "text";
1385
+ requests: string[];
1386
+ metadata?: undefined;
1387
+ }, {
1388
+ modality: "text";
1389
+ requests: string[];
1390
+ metadata?: undefined;
1391
+ }>, z.ZodObject<{
1392
+ modality: z.ZodLiteral<"token">;
1393
+ metadata: z.ZodUndefined;
1394
+ requests: z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">;
1395
+ }, "strip", z.ZodTypeAny, {
1396
+ modality: "token";
1397
+ requests: number[][];
1398
+ metadata?: undefined;
1399
+ }, {
1400
+ modality: "token";
1401
+ requests: number[][];
1402
+ metadata?: undefined;
1403
+ }>]>;
1404
+ callbacks: z.ZodOptional<z.ZodArray<z.ZodType<GetEmbeddingsCallbackType<any>, z.ZodTypeDef, GetEmbeddingsCallbackType<any>>, "atleastone">>;
1405
+ metadataForCallbacks: z.ZodOptional<z.ZodAny>;
1406
+ }, "strip", z.ZodTypeAny, {
1407
+ config: Record<string, any>;
1408
+ model: EmbeddingModelV1<{
1409
+ description: string;
1410
+ name: string;
1411
+ modalities: ["text" | "token", ...("text" | "token")[]];
1412
+ maxInputTokens: number;
1413
+ maxOutputTokens: number;
1414
+ config: {
1415
+ def: Record<string, {
1416
+ type: "multi-string";
1417
+ param: string;
1418
+ title: string;
1419
+ description: string;
1420
+ max: number;
1421
+ } | {
1422
+ type: "range";
1423
+ param: string;
1424
+ title: string;
1425
+ description: string;
1426
+ max: number;
1427
+ min: number;
1428
+ step: number;
1429
+ default: number;
1430
+ } | {
1431
+ type: "select-string";
1432
+ param: string;
1433
+ title: string;
1434
+ description: string;
1435
+ default: string;
1436
+ choices: string[];
1437
+ } | {
1438
+ type: "object-schema";
1439
+ param: string;
1440
+ title: string;
1441
+ description: string;
1442
+ objectSchema?: any;
1443
+ }>;
1444
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
1445
+ };
1446
+ }>;
1447
+ embeddingRequests: {
1448
+ modality: "text";
1449
+ requests: string[];
1450
+ metadata?: undefined;
1451
+ } | {
1452
+ modality: "token";
1453
+ requests: number[][];
1454
+ metadata?: undefined;
1455
+ };
1456
+ callbacks?: [GetEmbeddingsCallbackType<any>, ...GetEmbeddingsCallbackType<any>[]] | undefined;
1457
+ metadataForCallbacks?: any;
1458
+ }, {
1459
+ config: Record<string, any>;
1460
+ model: EmbeddingModelV1<{
1461
+ description: string;
1462
+ name: string;
1463
+ modalities: ["text" | "token", ...("text" | "token")[]];
1464
+ maxInputTokens: number;
1465
+ maxOutputTokens: number;
1466
+ config: {
1467
+ def: Record<string, {
1468
+ type: "multi-string";
1469
+ param: string;
1470
+ title: string;
1471
+ description: string;
1472
+ max: number;
1473
+ } | {
1474
+ type: "range";
1475
+ param: string;
1476
+ title: string;
1477
+ description: string;
1478
+ max: number;
1479
+ min: number;
1480
+ step: number;
1481
+ default: number;
1482
+ } | {
1483
+ type: "select-string";
1484
+ param: string;
1485
+ title: string;
1486
+ description: string;
1487
+ default: string;
1488
+ choices: string[];
1489
+ } | {
1490
+ type: "object-schema";
1491
+ param: string;
1492
+ title: string;
1493
+ description: string;
1494
+ objectSchema?: any;
1495
+ }>;
1496
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
1497
+ };
1498
+ }>;
1499
+ embeddingRequests: {
1500
+ modality: "text";
1501
+ requests: string[];
1502
+ metadata?: undefined;
1503
+ } | {
1504
+ modality: "token";
1505
+ requests: number[][];
1506
+ metadata?: undefined;
1507
+ };
1508
+ callbacks?: [GetEmbeddingsCallbackType<any>, ...GetEmbeddingsCallbackType<any>[]] | undefined;
1509
+ metadataForCallbacks?: any;
1510
+ }>;
1511
+ type GetEmbeddingsHandlerRequestType = z.infer<typeof GetEmbeddingsHandlerRequest>;
1512
+ declare const GetEmbeddingsHandlerResponse: z.ZodObject<{
1513
+ request: z.ZodObject<{
1514
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
1515
+ embeddingRequests: z.ZodDiscriminatedUnion<"modality", [z.ZodObject<{
1516
+ modality: z.ZodLiteral<"text">;
1517
+ metadata: z.ZodUndefined;
1518
+ requests: z.ZodArray<z.ZodString, "many">;
1519
+ }, "strip", z.ZodTypeAny, {
1520
+ modality: "text";
1521
+ requests: string[];
1522
+ metadata?: undefined;
1523
+ }, {
1524
+ modality: "text";
1525
+ requests: string[];
1526
+ metadata?: undefined;
1527
+ }>, z.ZodObject<{
1528
+ modality: z.ZodLiteral<"token">;
1529
+ metadata: z.ZodUndefined;
1530
+ requests: z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">;
1531
+ }, "strip", z.ZodTypeAny, {
1532
+ modality: "token";
1533
+ requests: number[][];
1534
+ metadata?: undefined;
1535
+ }, {
1536
+ modality: "token";
1537
+ requests: number[][];
1538
+ metadata?: undefined;
1539
+ }>]>;
1540
+ }, "strip", z.ZodTypeAny, {
1541
+ config: Record<string, any>;
1542
+ embeddingRequests: {
1543
+ modality: "text";
1544
+ requests: string[];
1545
+ metadata?: undefined;
1546
+ } | {
1547
+ modality: "token";
1548
+ requests: number[][];
1549
+ metadata?: undefined;
1550
+ };
1551
+ }, {
1552
+ config: Record<string, any>;
1553
+ embeddingRequests: {
1554
+ modality: "text";
1555
+ requests: string[];
1556
+ metadata?: undefined;
1557
+ } | {
1558
+ modality: "token";
1559
+ requests: number[][];
1560
+ metadata?: undefined;
1561
+ };
1562
+ }>;
1563
+ response: z.ZodDiscriminatedUnion<"encodingFormat", [z.ZodObject<{
1564
+ encodingFormat: z.ZodLiteral<"float">;
1565
+ embeddings: z.ZodArray<z.ZodObject<{
1566
+ index: z.ZodNumber;
1567
+ embedding: z.ZodArray<z.ZodNumber, "many">;
1568
+ }, "strip", z.ZodTypeAny, {
1569
+ index: number;
1570
+ embedding: number[];
1571
+ }, {
1572
+ index: number;
1573
+ embedding: number[];
1574
+ }>, "many">;
1575
+ }, "strip", z.ZodTypeAny, {
1576
+ encodingFormat: "float";
1577
+ embeddings: {
1578
+ index: number;
1579
+ embedding: number[];
1580
+ }[];
1581
+ }, {
1582
+ encodingFormat: "float";
1583
+ embeddings: {
1584
+ index: number;
1585
+ embedding: number[];
1586
+ }[];
1587
+ }>, z.ZodObject<{
1588
+ encodingFormat: z.ZodLiteral<"base64">;
1589
+ embeddings: z.ZodArray<z.ZodObject<{
1590
+ index: z.ZodNumber;
1591
+ embedding: z.ZodString;
1592
+ }, "strip", z.ZodTypeAny, {
1593
+ index: number;
1594
+ embedding: string;
1595
+ }, {
1596
+ index: number;
1597
+ embedding: string;
1598
+ }>, "many">;
1599
+ }, "strip", z.ZodTypeAny, {
1600
+ encodingFormat: "base64";
1601
+ embeddings: {
1602
+ index: number;
1603
+ embedding: string;
1604
+ }[];
1605
+ }, {
1606
+ encodingFormat: "base64";
1607
+ embeddings: {
1608
+ index: number;
1609
+ embedding: string;
1610
+ }[];
1611
+ }>]>;
1612
+ latencyInMs: z.ZodNumber;
1613
+ metadataForCallbacks: z.ZodOptional<z.ZodAny>;
1614
+ provider: z.ZodObject<{
1615
+ request: z.ZodAny;
1616
+ response: z.ZodAny;
1617
+ }, "strip", z.ZodTypeAny, {
1618
+ request?: any;
1619
+ response?: any;
1620
+ }, {
1621
+ request?: any;
1622
+ response?: any;
1623
+ }>;
1624
+ }, "strip", z.ZodTypeAny, {
1625
+ request: {
1626
+ config: Record<string, any>;
1627
+ embeddingRequests: {
1628
+ modality: "text";
1629
+ requests: string[];
1630
+ metadata?: undefined;
1631
+ } | {
1632
+ modality: "token";
1633
+ requests: number[][];
1634
+ metadata?: undefined;
1635
+ };
1636
+ };
1637
+ response: {
1638
+ encodingFormat: "float";
1639
+ embeddings: {
1640
+ index: number;
1641
+ embedding: number[];
1642
+ }[];
1643
+ } | {
1644
+ encodingFormat: "base64";
1645
+ embeddings: {
1646
+ index: number;
1647
+ embedding: string;
1648
+ }[];
1649
+ };
1650
+ latencyInMs: number;
1651
+ provider: {
1652
+ request?: any;
1653
+ response?: any;
1654
+ };
1655
+ metadataForCallbacks?: any;
1656
+ }, {
1657
+ request: {
1658
+ config: Record<string, any>;
1659
+ embeddingRequests: {
1660
+ modality: "text";
1661
+ requests: string[];
1662
+ metadata?: undefined;
1663
+ } | {
1664
+ modality: "token";
1665
+ requests: number[][];
1666
+ metadata?: undefined;
1667
+ };
1668
+ };
1669
+ response: {
1670
+ encodingFormat: "float";
1671
+ embeddings: {
1672
+ index: number;
1673
+ embedding: number[];
1674
+ }[];
1675
+ } | {
1676
+ encodingFormat: "base64";
1677
+ embeddings: {
1678
+ index: number;
1679
+ embedding: string;
1680
+ }[];
1681
+ };
1682
+ latencyInMs: number;
1683
+ provider: {
1684
+ request?: any;
1685
+ response?: any;
1686
+ };
1687
+ metadataForCallbacks?: any;
1688
+ }>;
1689
+ type GetEmbeddingsHandlerResponseType = z.infer<typeof GetEmbeddingsHandlerResponse>;
1690
+ type GetEmbeddingsCallbackType<M = any> = {
1691
+ onGetEmbeddingsStart?: (metadata?: M) => Promise<void> | void;
1692
+ onGetEmbeddingsCached?: (metadata?: M, response?: GetEmbeddingsHandlerResponseType) => Promise<void> | void;
1693
+ onGetEmbeddingsComplete?: (metadata?: M, response?: GetEmbeddingsHandlerResponseType) => Promise<void> | void;
1694
+ onGetEmbeddingsError?: (metadata?: M, error?: GatewayError) => Promise<void> | void;
1695
+ };
1696
+
1697
+ declare function handleGetEmbeddings(request: GetEmbeddingsHandlerRequestType, client: HttpClient): Promise<GetEmbeddingsHandlerResponseType>;
1698
+
1699
+ declare const StreamChatHandlerRequest: z.ZodObject<{
1700
+ model: z.ZodType<ChatModelV1<{
1701
+ name: string;
1702
+ description: string;
1703
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
1704
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
1705
+ maxInputTokens: number;
1706
+ maxOutputTokens: number;
1707
+ config: {
1708
+ def: Record<string, {
1709
+ type: "multi-string";
1710
+ param: string;
1711
+ title: string;
1712
+ description: string;
1713
+ max: number;
1714
+ } | {
1715
+ type: "range";
1716
+ param: string;
1717
+ title: string;
1718
+ description: string;
1719
+ max: number;
1720
+ min: number;
1721
+ step: number;
1722
+ default: number;
1723
+ } | {
1724
+ type: "select-string";
1725
+ param: string;
1726
+ title: string;
1727
+ description: string;
1728
+ default: string;
1729
+ choices: string[];
1730
+ } | {
1731
+ type: "object-schema";
1732
+ param: string;
1733
+ title: string;
1734
+ description: string;
1735
+ objectSchema?: any;
1736
+ }>;
1737
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
1738
+ };
1739
+ }>, z.ZodTypeDef, ChatModelV1<{
1740
+ name: string;
1741
+ description: string;
1742
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
1743
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
1744
+ maxInputTokens: number;
1745
+ maxOutputTokens: number;
1746
+ config: {
1747
+ def: Record<string, {
1748
+ type: "multi-string";
1749
+ param: string;
1750
+ title: string;
1751
+ description: string;
1752
+ max: number;
1753
+ } | {
1754
+ type: "range";
1755
+ param: string;
1756
+ title: string;
1757
+ description: string;
1758
+ max: number;
1759
+ min: number;
1760
+ step: number;
1761
+ default: number;
1762
+ } | {
1763
+ type: "select-string";
1764
+ param: string;
1765
+ title: string;
1766
+ description: string;
1767
+ default: string;
1768
+ choices: string[];
1769
+ } | {
1770
+ type: "object-schema";
1771
+ param: string;
1772
+ title: string;
1773
+ description: string;
1774
+ objectSchema?: any;
1775
+ }>;
1776
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
1777
+ };
1778
+ }>>;
1779
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
1780
+ messages: z.ZodArray<z.ZodObject<{
1781
+ role: z.ZodEnum<["system", "user", "assistant", "tool"]>;
1782
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"modality", [z.ZodObject<{
1783
+ modality: z.ZodLiteral<"text">;
1784
+ value: z.ZodString;
1785
+ metadata: z.ZodUndefined;
1786
+ }, "strip", z.ZodTypeAny, {
1787
+ value: string;
1788
+ modality: "text";
1789
+ metadata?: undefined;
1790
+ }, {
1791
+ value: string;
1792
+ modality: "text";
1793
+ metadata?: undefined;
1794
+ }>, z.ZodObject<{
1795
+ modality: z.ZodLiteral<"image">;
1796
+ detail: z.ZodEnum<["low", "medium", "high", "auto"]>;
1797
+ value: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1798
+ type: z.ZodLiteral<"base64">;
1799
+ base64: z.ZodString;
1800
+ }, "strip", z.ZodTypeAny, {
1801
+ type: "base64";
1802
+ base64: string;
1803
+ }, {
1804
+ type: "base64";
1805
+ base64: string;
1806
+ }>, z.ZodObject<{
1807
+ type: z.ZodLiteral<"url">;
1808
+ url: z.ZodString;
1809
+ }, "strip", z.ZodTypeAny, {
1810
+ type: "url";
1811
+ url: string;
1812
+ }, {
1813
+ type: "url";
1814
+ url: string;
1815
+ }>]>;
1816
+ metadata: z.ZodUndefined;
1817
+ }, "strip", z.ZodTypeAny, {
1818
+ value: {
1819
+ type: "base64";
1820
+ base64: string;
1821
+ } | {
1822
+ type: "url";
1823
+ url: string;
1824
+ };
1825
+ modality: "image";
1826
+ detail: "low" | "medium" | "high" | "auto";
1827
+ metadata?: undefined;
1828
+ }, {
1829
+ value: {
1830
+ type: "base64";
1831
+ base64: string;
1832
+ } | {
1833
+ type: "url";
1834
+ url: string;
1835
+ };
1836
+ modality: "image";
1837
+ detail: "low" | "medium" | "high" | "auto";
1838
+ metadata?: undefined;
1839
+ }>, z.ZodObject<{
1840
+ modality: z.ZodLiteral<"tool-call">;
1841
+ index: z.ZodNumber;
1842
+ id: z.ZodString;
1843
+ name: z.ZodString;
1844
+ arguments: z.ZodString;
1845
+ metadata: z.ZodUndefined;
1846
+ }, "strip", z.ZodTypeAny, {
1847
+ name: string;
1848
+ modality: "tool-call";
1849
+ index: number;
1850
+ id: string;
1851
+ arguments: string;
1852
+ metadata?: undefined;
1853
+ }, {
1854
+ name: string;
1855
+ modality: "tool-call";
1856
+ index: number;
1857
+ id: string;
1858
+ arguments: string;
1859
+ metadata?: undefined;
1860
+ }>, z.ZodObject<{
1861
+ modality: z.ZodLiteral<"tool-response">;
1862
+ index: z.ZodNumber;
1863
+ id: z.ZodString;
1864
+ name: z.ZodString;
1865
+ data: z.ZodString;
1866
+ metadata: z.ZodUndefined;
1867
+ }, "strip", z.ZodTypeAny, {
1868
+ data: string;
1869
+ name: string;
1870
+ modality: "tool-response";
1871
+ index: number;
1872
+ id: string;
1873
+ metadata?: undefined;
1874
+ }, {
1875
+ data: string;
1876
+ name: string;
1877
+ modality: "tool-response";
1878
+ index: number;
1879
+ id: string;
1880
+ metadata?: undefined;
1881
+ }>]>, "many">;
1882
+ metadata: z.ZodUndefined;
1883
+ }, "strip", z.ZodTypeAny, {
1884
+ role: "system" | "user" | "assistant" | "tool";
1885
+ content: ({
1886
+ value: string;
1887
+ modality: "text";
1888
+ metadata?: undefined;
1889
+ } | {
1890
+ value: {
1891
+ type: "base64";
1892
+ base64: string;
1893
+ } | {
1894
+ type: "url";
1895
+ url: string;
1896
+ };
1897
+ modality: "image";
1898
+ detail: "low" | "medium" | "high" | "auto";
1899
+ metadata?: undefined;
1900
+ } | {
1901
+ name: string;
1902
+ modality: "tool-call";
1903
+ index: number;
1904
+ id: string;
1905
+ arguments: string;
1906
+ metadata?: undefined;
1907
+ } | {
1908
+ data: string;
1909
+ name: string;
1910
+ modality: "tool-response";
1911
+ index: number;
1912
+ id: string;
1913
+ metadata?: undefined;
1914
+ })[];
1915
+ metadata?: undefined;
1916
+ }, {
1917
+ role: "system" | "user" | "assistant" | "tool";
1918
+ content: ({
1919
+ value: string;
1920
+ modality: "text";
1921
+ metadata?: undefined;
1922
+ } | {
1923
+ value: {
1924
+ type: "base64";
1925
+ base64: string;
1926
+ } | {
1927
+ type: "url";
1928
+ url: string;
1929
+ };
1930
+ modality: "image";
1931
+ detail: "low" | "medium" | "high" | "auto";
1932
+ metadata?: undefined;
1933
+ } | {
1934
+ name: string;
1935
+ modality: "tool-call";
1936
+ index: number;
1937
+ id: string;
1938
+ arguments: string;
1939
+ metadata?: undefined;
1940
+ } | {
1941
+ data: string;
1942
+ name: string;
1943
+ modality: "tool-response";
1944
+ index: number;
1945
+ id: string;
1946
+ metadata?: undefined;
1947
+ })[];
1948
+ metadata?: undefined;
1949
+ }>, "many">;
1950
+ tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<z.objectUtil.extendShape<{
1951
+ type: z.ZodEnum<["function"]>;
1952
+ definition: z.ZodObject<{
1953
+ schema: z.ZodObject<{
1954
+ name: z.ZodString;
1955
+ description: z.ZodString;
1956
+ parameters: z.ZodAny;
1957
+ strict: z.ZodOptional<z.ZodBoolean>;
1958
+ }, "strip", z.ZodTypeAny, {
1959
+ name: string;
1960
+ description: string;
1961
+ strict?: boolean | undefined;
1962
+ parameters?: any;
1963
+ }, {
1964
+ name: string;
1965
+ description: string;
1966
+ strict?: boolean | undefined;
1967
+ parameters?: any;
1968
+ }>;
1969
+ }, "strip", z.ZodTypeAny, {
1970
+ schema: {
1971
+ name: string;
1972
+ description: string;
1973
+ strict?: boolean | undefined;
1974
+ parameters?: any;
1975
+ };
1976
+ }, {
1977
+ schema: {
1978
+ name: string;
1979
+ description: string;
1980
+ strict?: boolean | undefined;
1981
+ parameters?: any;
1982
+ };
1983
+ }>;
1984
+ }, {
1985
+ metadata: z.ZodTypeAny;
1986
+ }>, "strip", z.ZodTypeAny, {
1987
+ type: "function";
1988
+ definition: {
1989
+ schema: {
1990
+ name: string;
1991
+ description: string;
1992
+ strict?: boolean | undefined;
1993
+ parameters?: any;
1994
+ };
1995
+ };
1996
+ metadata?: any;
1997
+ }, {
1998
+ type: "function";
1999
+ definition: {
2000
+ schema: {
2001
+ name: string;
2002
+ description: string;
2003
+ strict?: boolean | undefined;
2004
+ parameters?: any;
2005
+ };
2006
+ };
2007
+ metadata?: any;
2008
+ }>]>, "many">>;
2009
+ callbacks: z.ZodOptional<z.ZodArray<z.ZodType<StreamChatCallbackType<any>, z.ZodTypeDef, StreamChatCallbackType<any>>, "atleastone">>;
2010
+ metadataForCallbacks: z.ZodOptional<z.ZodAny>;
2011
+ }, "strip", z.ZodTypeAny, {
2012
+ config: Record<string, any>;
2013
+ model: ChatModelV1<{
2014
+ name: string;
2015
+ description: string;
2016
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
2017
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
2018
+ maxInputTokens: number;
2019
+ maxOutputTokens: number;
2020
+ config: {
2021
+ def: Record<string, {
2022
+ type: "multi-string";
2023
+ param: string;
2024
+ title: string;
2025
+ description: string;
2026
+ max: number;
2027
+ } | {
2028
+ type: "range";
2029
+ param: string;
2030
+ title: string;
2031
+ description: string;
2032
+ max: number;
2033
+ min: number;
2034
+ step: number;
2035
+ default: number;
2036
+ } | {
2037
+ type: "select-string";
2038
+ param: string;
2039
+ title: string;
2040
+ description: string;
2041
+ default: string;
2042
+ choices: string[];
2043
+ } | {
2044
+ type: "object-schema";
2045
+ param: string;
2046
+ title: string;
2047
+ description: string;
2048
+ objectSchema?: any;
2049
+ }>;
2050
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
2051
+ };
2052
+ }>;
2053
+ messages: {
2054
+ role: "system" | "user" | "assistant" | "tool";
2055
+ content: ({
2056
+ value: string;
2057
+ modality: "text";
2058
+ metadata?: undefined;
2059
+ } | {
2060
+ value: {
2061
+ type: "base64";
2062
+ base64: string;
2063
+ } | {
2064
+ type: "url";
2065
+ url: string;
2066
+ };
2067
+ modality: "image";
2068
+ detail: "low" | "medium" | "high" | "auto";
2069
+ metadata?: undefined;
2070
+ } | {
2071
+ name: string;
2072
+ modality: "tool-call";
2073
+ index: number;
2074
+ id: string;
2075
+ arguments: string;
2076
+ metadata?: undefined;
2077
+ } | {
2078
+ data: string;
2079
+ name: string;
2080
+ modality: "tool-response";
2081
+ index: number;
2082
+ id: string;
2083
+ metadata?: undefined;
2084
+ })[];
2085
+ metadata?: undefined;
2086
+ }[];
2087
+ tools?: {
2088
+ type: "function";
2089
+ definition: {
2090
+ schema: {
2091
+ name: string;
2092
+ description: string;
2093
+ strict?: boolean | undefined;
2094
+ parameters?: any;
2095
+ };
2096
+ };
2097
+ metadata?: any;
2098
+ }[] | undefined;
2099
+ callbacks?: [StreamChatCallbackType<any>, ...StreamChatCallbackType<any>[]] | undefined;
2100
+ metadataForCallbacks?: any;
2101
+ }, {
2102
+ config: Record<string, any>;
2103
+ model: ChatModelV1<{
2104
+ name: string;
2105
+ description: string;
2106
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
2107
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
2108
+ maxInputTokens: number;
2109
+ maxOutputTokens: number;
2110
+ config: {
2111
+ def: Record<string, {
2112
+ type: "multi-string";
2113
+ param: string;
2114
+ title: string;
2115
+ description: string;
2116
+ max: number;
2117
+ } | {
2118
+ type: "range";
2119
+ param: string;
2120
+ title: string;
2121
+ description: string;
2122
+ max: number;
2123
+ min: number;
2124
+ step: number;
2125
+ default: number;
2126
+ } | {
2127
+ type: "select-string";
2128
+ param: string;
2129
+ title: string;
2130
+ description: string;
2131
+ default: string;
2132
+ choices: string[];
2133
+ } | {
2134
+ type: "object-schema";
2135
+ param: string;
2136
+ title: string;
2137
+ description: string;
2138
+ objectSchema?: any;
2139
+ }>;
2140
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
2141
+ };
2142
+ }>;
2143
+ messages: {
2144
+ role: "system" | "user" | "assistant" | "tool";
2145
+ content: ({
2146
+ value: string;
2147
+ modality: "text";
2148
+ metadata?: undefined;
2149
+ } | {
2150
+ value: {
2151
+ type: "base64";
2152
+ base64: string;
2153
+ } | {
2154
+ type: "url";
2155
+ url: string;
2156
+ };
2157
+ modality: "image";
2158
+ detail: "low" | "medium" | "high" | "auto";
2159
+ metadata?: undefined;
2160
+ } | {
2161
+ name: string;
2162
+ modality: "tool-call";
2163
+ index: number;
2164
+ id: string;
2165
+ arguments: string;
2166
+ metadata?: undefined;
2167
+ } | {
2168
+ data: string;
2169
+ name: string;
2170
+ modality: "tool-response";
2171
+ index: number;
2172
+ id: string;
2173
+ metadata?: undefined;
2174
+ })[];
2175
+ metadata?: undefined;
2176
+ }[];
2177
+ tools?: {
2178
+ type: "function";
2179
+ definition: {
2180
+ schema: {
2181
+ name: string;
2182
+ description: string;
2183
+ strict?: boolean | undefined;
2184
+ parameters?: any;
2185
+ };
2186
+ };
2187
+ metadata?: any;
2188
+ }[] | undefined;
2189
+ callbacks?: [StreamChatCallbackType<any>, ...StreamChatCallbackType<any>[]] | undefined;
2190
+ metadataForCallbacks?: any;
2191
+ }>;
2192
+ type StreamChatHandlerRequestType = z.infer<typeof StreamChatHandlerRequest>;
2193
+ declare const StreamChatHandlerResponse: z.ZodObject<{
2194
+ request: z.ZodObject<{
2195
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
2196
+ messages: z.ZodArray<z.ZodObject<{
2197
+ role: z.ZodEnum<["system", "user", "assistant", "tool"]>;
2198
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"modality", [z.ZodObject<{
2199
+ modality: z.ZodLiteral<"text">;
2200
+ value: z.ZodString;
2201
+ metadata: z.ZodUndefined;
2202
+ }, "strip", z.ZodTypeAny, {
2203
+ value: string;
2204
+ modality: "text";
2205
+ metadata?: undefined;
2206
+ }, {
2207
+ value: string;
2208
+ modality: "text";
2209
+ metadata?: undefined;
2210
+ }>, z.ZodObject<{
2211
+ modality: z.ZodLiteral<"image">;
2212
+ detail: z.ZodEnum<["low", "medium", "high", "auto"]>;
2213
+ value: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
2214
+ type: z.ZodLiteral<"base64">;
2215
+ base64: z.ZodString;
2216
+ }, "strip", z.ZodTypeAny, {
2217
+ type: "base64";
2218
+ base64: string;
2219
+ }, {
2220
+ type: "base64";
2221
+ base64: string;
2222
+ }>, z.ZodObject<{
2223
+ type: z.ZodLiteral<"url">;
2224
+ url: z.ZodString;
2225
+ }, "strip", z.ZodTypeAny, {
2226
+ type: "url";
2227
+ url: string;
2228
+ }, {
2229
+ type: "url";
2230
+ url: string;
2231
+ }>]>;
2232
+ metadata: z.ZodUndefined;
2233
+ }, "strip", z.ZodTypeAny, {
2234
+ value: {
2235
+ type: "base64";
2236
+ base64: string;
2237
+ } | {
2238
+ type: "url";
2239
+ url: string;
2240
+ };
2241
+ modality: "image";
2242
+ detail: "low" | "medium" | "high" | "auto";
2243
+ metadata?: undefined;
2244
+ }, {
2245
+ value: {
2246
+ type: "base64";
2247
+ base64: string;
2248
+ } | {
2249
+ type: "url";
2250
+ url: string;
2251
+ };
2252
+ modality: "image";
2253
+ detail: "low" | "medium" | "high" | "auto";
2254
+ metadata?: undefined;
2255
+ }>, z.ZodObject<{
2256
+ modality: z.ZodLiteral<"tool-call">;
2257
+ index: z.ZodNumber;
2258
+ id: z.ZodString;
2259
+ name: z.ZodString;
2260
+ arguments: z.ZodString;
2261
+ metadata: z.ZodUndefined;
2262
+ }, "strip", z.ZodTypeAny, {
2263
+ name: string;
2264
+ modality: "tool-call";
2265
+ index: number;
2266
+ id: string;
2267
+ arguments: string;
2268
+ metadata?: undefined;
2269
+ }, {
2270
+ name: string;
2271
+ modality: "tool-call";
2272
+ index: number;
2273
+ id: string;
2274
+ arguments: string;
2275
+ metadata?: undefined;
2276
+ }>, z.ZodObject<{
2277
+ modality: z.ZodLiteral<"tool-response">;
2278
+ index: z.ZodNumber;
2279
+ id: z.ZodString;
2280
+ name: z.ZodString;
2281
+ data: z.ZodString;
2282
+ metadata: z.ZodUndefined;
2283
+ }, "strip", z.ZodTypeAny, {
2284
+ data: string;
2285
+ name: string;
2286
+ modality: "tool-response";
2287
+ index: number;
2288
+ id: string;
2289
+ metadata?: undefined;
2290
+ }, {
2291
+ data: string;
2292
+ name: string;
2293
+ modality: "tool-response";
2294
+ index: number;
2295
+ id: string;
2296
+ metadata?: undefined;
2297
+ }>]>, "many">;
2298
+ metadata: z.ZodUndefined;
2299
+ }, "strip", z.ZodTypeAny, {
2300
+ role: "system" | "user" | "assistant" | "tool";
2301
+ content: ({
2302
+ value: string;
2303
+ modality: "text";
2304
+ metadata?: undefined;
2305
+ } | {
2306
+ value: {
2307
+ type: "base64";
2308
+ base64: string;
2309
+ } | {
2310
+ type: "url";
2311
+ url: string;
2312
+ };
2313
+ modality: "image";
2314
+ detail: "low" | "medium" | "high" | "auto";
2315
+ metadata?: undefined;
2316
+ } | {
2317
+ name: string;
2318
+ modality: "tool-call";
2319
+ index: number;
2320
+ id: string;
2321
+ arguments: string;
2322
+ metadata?: undefined;
2323
+ } | {
2324
+ data: string;
2325
+ name: string;
2326
+ modality: "tool-response";
2327
+ index: number;
2328
+ id: string;
2329
+ metadata?: undefined;
2330
+ })[];
2331
+ metadata?: undefined;
2332
+ }, {
2333
+ role: "system" | "user" | "assistant" | "tool";
2334
+ content: ({
2335
+ value: string;
2336
+ modality: "text";
2337
+ metadata?: undefined;
2338
+ } | {
2339
+ value: {
2340
+ type: "base64";
2341
+ base64: string;
2342
+ } | {
2343
+ type: "url";
2344
+ url: string;
2345
+ };
2346
+ modality: "image";
2347
+ detail: "low" | "medium" | "high" | "auto";
2348
+ metadata?: undefined;
2349
+ } | {
2350
+ name: string;
2351
+ modality: "tool-call";
2352
+ index: number;
2353
+ id: string;
2354
+ arguments: string;
2355
+ metadata?: undefined;
2356
+ } | {
2357
+ data: string;
2358
+ name: string;
2359
+ modality: "tool-response";
2360
+ index: number;
2361
+ id: string;
2362
+ metadata?: undefined;
2363
+ })[];
2364
+ metadata?: undefined;
2365
+ }>, "many">;
2366
+ tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<z.objectUtil.extendShape<{
2367
+ type: z.ZodEnum<["function"]>;
2368
+ definition: z.ZodObject<{
2369
+ schema: z.ZodObject<{
2370
+ name: z.ZodString;
2371
+ description: z.ZodString;
2372
+ parameters: z.ZodAny;
2373
+ strict: z.ZodOptional<z.ZodBoolean>;
2374
+ }, "strip", z.ZodTypeAny, {
2375
+ name: string;
2376
+ description: string;
2377
+ strict?: boolean | undefined;
2378
+ parameters?: any;
2379
+ }, {
2380
+ name: string;
2381
+ description: string;
2382
+ strict?: boolean | undefined;
2383
+ parameters?: any;
2384
+ }>;
2385
+ }, "strip", z.ZodTypeAny, {
2386
+ schema: {
2387
+ name: string;
2388
+ description: string;
2389
+ strict?: boolean | undefined;
2390
+ parameters?: any;
2391
+ };
2392
+ }, {
2393
+ schema: {
2394
+ name: string;
2395
+ description: string;
2396
+ strict?: boolean | undefined;
2397
+ parameters?: any;
2398
+ };
2399
+ }>;
2400
+ }, {
2401
+ metadata: z.ZodTypeAny;
2402
+ }>, "strip", z.ZodTypeAny, {
2403
+ type: "function";
2404
+ definition: {
2405
+ schema: {
2406
+ name: string;
2407
+ description: string;
2408
+ strict?: boolean | undefined;
2409
+ parameters?: any;
2410
+ };
2411
+ };
2412
+ metadata?: any;
2413
+ }, {
2414
+ type: "function";
2415
+ definition: {
2416
+ schema: {
2417
+ name: string;
2418
+ description: string;
2419
+ strict?: boolean | undefined;
2420
+ parameters?: any;
2421
+ };
2422
+ };
2423
+ metadata?: any;
2424
+ }>]>, "many">>;
2425
+ }, "strip", z.ZodTypeAny, {
2426
+ config: Record<string, any>;
2427
+ messages: {
2428
+ role: "system" | "user" | "assistant" | "tool";
2429
+ content: ({
2430
+ value: string;
2431
+ modality: "text";
2432
+ metadata?: undefined;
2433
+ } | {
2434
+ value: {
2435
+ type: "base64";
2436
+ base64: string;
2437
+ } | {
2438
+ type: "url";
2439
+ url: string;
2440
+ };
2441
+ modality: "image";
2442
+ detail: "low" | "medium" | "high" | "auto";
2443
+ metadata?: undefined;
2444
+ } | {
2445
+ name: string;
2446
+ modality: "tool-call";
2447
+ index: number;
2448
+ id: string;
2449
+ arguments: string;
2450
+ metadata?: undefined;
2451
+ } | {
2452
+ data: string;
2453
+ name: string;
2454
+ modality: "tool-response";
2455
+ index: number;
2456
+ id: string;
2457
+ metadata?: undefined;
2458
+ })[];
2459
+ metadata?: undefined;
2460
+ }[];
2461
+ tools?: {
2462
+ type: "function";
2463
+ definition: {
2464
+ schema: {
2465
+ name: string;
2466
+ description: string;
2467
+ strict?: boolean | undefined;
2468
+ parameters?: any;
2469
+ };
2470
+ };
2471
+ metadata?: any;
2472
+ }[] | undefined;
2473
+ }, {
2474
+ config: Record<string, any>;
2475
+ messages: {
2476
+ role: "system" | "user" | "assistant" | "tool";
2477
+ content: ({
2478
+ value: string;
2479
+ modality: "text";
2480
+ metadata?: undefined;
2481
+ } | {
2482
+ value: {
2483
+ type: "base64";
2484
+ base64: string;
2485
+ } | {
2486
+ type: "url";
2487
+ url: string;
2488
+ };
2489
+ modality: "image";
2490
+ detail: "low" | "medium" | "high" | "auto";
2491
+ metadata?: undefined;
2492
+ } | {
2493
+ name: string;
2494
+ modality: "tool-call";
2495
+ index: number;
2496
+ id: string;
2497
+ arguments: string;
2498
+ metadata?: undefined;
2499
+ } | {
2500
+ data: string;
2501
+ name: string;
2502
+ modality: "tool-response";
2503
+ index: number;
2504
+ id: string;
2505
+ metadata?: undefined;
2506
+ })[];
2507
+ metadata?: undefined;
2508
+ }[];
2509
+ tools?: {
2510
+ type: "function";
2511
+ definition: {
2512
+ schema: {
2513
+ name: string;
2514
+ description: string;
2515
+ strict?: boolean | undefined;
2516
+ parameters?: any;
2517
+ };
2518
+ };
2519
+ metadata?: any;
2520
+ }[] | undefined;
2521
+ }>;
2522
+ response: z.ZodArray<z.ZodObject<{
2523
+ role: z.ZodEnum<["assistant"]>;
2524
+ partialContent: z.ZodDiscriminatedUnion<"modality", [z.ZodObject<{
2525
+ modality: z.ZodLiteral<"partial-text">;
2526
+ value: z.ZodString;
2527
+ metadata: z.ZodUndefined;
2528
+ }, "strip", z.ZodTypeAny, {
2529
+ value: string;
2530
+ modality: "partial-text";
2531
+ metadata?: undefined;
2532
+ }, {
2533
+ value: string;
2534
+ modality: "partial-text";
2535
+ metadata?: undefined;
2536
+ }>, z.ZodObject<{
2537
+ modality: z.ZodLiteral<"partial-tool-call">;
2538
+ index: z.ZodNumber;
2539
+ id: z.ZodOptional<z.ZodString>;
2540
+ name: z.ZodOptional<z.ZodString>;
2541
+ arguments: z.ZodOptional<z.ZodString>;
2542
+ metadata: z.ZodUndefined;
2543
+ }, "strip", z.ZodTypeAny, {
2544
+ modality: "partial-tool-call";
2545
+ index: number;
2546
+ name?: string | undefined;
2547
+ metadata?: undefined;
2548
+ id?: string | undefined;
2549
+ arguments?: string | undefined;
2550
+ }, {
2551
+ modality: "partial-tool-call";
2552
+ index: number;
2553
+ name?: string | undefined;
2554
+ metadata?: undefined;
2555
+ id?: string | undefined;
2556
+ arguments?: string | undefined;
2557
+ }>]>;
2558
+ metadata: z.ZodUndefined;
2559
+ }, "strip", z.ZodTypeAny, {
2560
+ role: "assistant";
2561
+ partialContent: {
2562
+ value: string;
2563
+ modality: "partial-text";
2564
+ metadata?: undefined;
2565
+ } | {
2566
+ modality: "partial-tool-call";
2567
+ index: number;
2568
+ name?: string | undefined;
2569
+ metadata?: undefined;
2570
+ id?: string | undefined;
2571
+ arguments?: string | undefined;
2572
+ };
2573
+ metadata?: undefined;
2574
+ }, {
2575
+ role: "assistant";
2576
+ partialContent: {
2577
+ value: string;
2578
+ modality: "partial-text";
2579
+ metadata?: undefined;
2580
+ } | {
2581
+ modality: "partial-tool-call";
2582
+ index: number;
2583
+ name?: string | undefined;
2584
+ metadata?: undefined;
2585
+ id?: string | undefined;
2586
+ arguments?: string | undefined;
2587
+ };
2588
+ metadata?: undefined;
2589
+ }>, "many">;
2590
+ metadataForCallbacks: z.ZodOptional<z.ZodAny>;
2591
+ provider: z.ZodObject<{
2592
+ request: z.ZodAny;
2593
+ response: z.ZodAny;
2594
+ }, "strip", z.ZodTypeAny, {
2595
+ request?: any;
2596
+ response?: any;
2597
+ }, {
2598
+ request?: any;
2599
+ response?: any;
2600
+ }>;
2601
+ }, "strip", z.ZodTypeAny, {
2602
+ request: {
2603
+ config: Record<string, any>;
2604
+ messages: {
2605
+ role: "system" | "user" | "assistant" | "tool";
2606
+ content: ({
2607
+ value: string;
2608
+ modality: "text";
2609
+ metadata?: undefined;
2610
+ } | {
2611
+ value: {
2612
+ type: "base64";
2613
+ base64: string;
2614
+ } | {
2615
+ type: "url";
2616
+ url: string;
2617
+ };
2618
+ modality: "image";
2619
+ detail: "low" | "medium" | "high" | "auto";
2620
+ metadata?: undefined;
2621
+ } | {
2622
+ name: string;
2623
+ modality: "tool-call";
2624
+ index: number;
2625
+ id: string;
2626
+ arguments: string;
2627
+ metadata?: undefined;
2628
+ } | {
2629
+ data: string;
2630
+ name: string;
2631
+ modality: "tool-response";
2632
+ index: number;
2633
+ id: string;
2634
+ metadata?: undefined;
2635
+ })[];
2636
+ metadata?: undefined;
2637
+ }[];
2638
+ tools?: {
2639
+ type: "function";
2640
+ definition: {
2641
+ schema: {
2642
+ name: string;
2643
+ description: string;
2644
+ strict?: boolean | undefined;
2645
+ parameters?: any;
2646
+ };
2647
+ };
2648
+ metadata?: any;
2649
+ }[] | undefined;
2650
+ };
2651
+ response: {
2652
+ role: "assistant";
2653
+ partialContent: {
2654
+ value: string;
2655
+ modality: "partial-text";
2656
+ metadata?: undefined;
2657
+ } | {
2658
+ modality: "partial-tool-call";
2659
+ index: number;
2660
+ name?: string | undefined;
2661
+ metadata?: undefined;
2662
+ id?: string | undefined;
2663
+ arguments?: string | undefined;
2664
+ };
2665
+ metadata?: undefined;
2666
+ }[];
2667
+ provider: {
2668
+ request?: any;
2669
+ response?: any;
2670
+ };
2671
+ metadataForCallbacks?: any;
2672
+ }, {
2673
+ request: {
2674
+ config: Record<string, any>;
2675
+ messages: {
2676
+ role: "system" | "user" | "assistant" | "tool";
2677
+ content: ({
2678
+ value: string;
2679
+ modality: "text";
2680
+ metadata?: undefined;
2681
+ } | {
2682
+ value: {
2683
+ type: "base64";
2684
+ base64: string;
2685
+ } | {
2686
+ type: "url";
2687
+ url: string;
2688
+ };
2689
+ modality: "image";
2690
+ detail: "low" | "medium" | "high" | "auto";
2691
+ metadata?: undefined;
2692
+ } | {
2693
+ name: string;
2694
+ modality: "tool-call";
2695
+ index: number;
2696
+ id: string;
2697
+ arguments: string;
2698
+ metadata?: undefined;
2699
+ } | {
2700
+ data: string;
2701
+ name: string;
2702
+ modality: "tool-response";
2703
+ index: number;
2704
+ id: string;
2705
+ metadata?: undefined;
2706
+ })[];
2707
+ metadata?: undefined;
2708
+ }[];
2709
+ tools?: {
2710
+ type: "function";
2711
+ definition: {
2712
+ schema: {
2713
+ name: string;
2714
+ description: string;
2715
+ strict?: boolean | undefined;
2716
+ parameters?: any;
2717
+ };
2718
+ };
2719
+ metadata?: any;
2720
+ }[] | undefined;
2721
+ };
2722
+ response: {
2723
+ role: "assistant";
2724
+ partialContent: {
2725
+ value: string;
2726
+ modality: "partial-text";
2727
+ metadata?: undefined;
2728
+ } | {
2729
+ modality: "partial-tool-call";
2730
+ index: number;
2731
+ name?: string | undefined;
2732
+ metadata?: undefined;
2733
+ id?: string | undefined;
2734
+ arguments?: string | undefined;
2735
+ };
2736
+ metadata?: undefined;
2737
+ }[];
2738
+ provider: {
2739
+ request?: any;
2740
+ response?: any;
2741
+ };
2742
+ metadataForCallbacks?: any;
2743
+ }>;
2744
+ type StreamChatHandlerResponseType = z.infer<typeof StreamChatHandlerResponse>;
2745
+ type StreamChatCallbackType<M = any> = {
2746
+ onStreamStart?: (metadata?: M) => Promise<void> | void;
2747
+ onStreamFirstResponse?: (metadata?: M, response?: StreamChatHandlerResponseType, chunk?: unknown) => Promise<void> | void;
2748
+ onStreamNewResponse?: (metadata?: M, response?: StreamChatHandlerResponseType, chunk?: unknown) => Promise<void> | void;
2749
+ onStreamEnd?: (metadata?: M, response?: StreamChatHandlerResponseType) => Promise<void> | void;
2750
+ onStreamError?: (metadata?: M, error?: GatewayError) => Promise<void> | void;
2751
+ };
2752
+
2753
+ declare function handleStreamChat<M>(request: StreamChatHandlerRequestType, client: HttpClient): AsyncGenerator<StreamChatHandlerResponseType, void, unknown>;
2754
+
2755
+ type GatewayCallbackType<M = any> = CompleteChatCallbackType<M> | StreamChatCallbackType<M>;
2756
+ declare const GatewayOptions: z.ZodObject<{
2757
+ dangerouslyAllowBrowser: z.ZodOptional<z.ZodBoolean>;
2758
+ httpClient: z.ZodOptional<z.ZodType<HttpClient, z.ZodTypeDef, HttpClient>>;
2759
+ callbacks: z.ZodOptional<z.ZodArray<z.ZodType<GatewayCallbackType<any>, z.ZodTypeDef, GatewayCallbackType<any>>, "atleastone">>;
2760
+ }, "strip", z.ZodTypeAny, {
2761
+ callbacks?: [GatewayCallbackType<any>, ...GatewayCallbackType<any>[]] | undefined;
2762
+ dangerouslyAllowBrowser?: boolean | undefined;
2763
+ httpClient?: HttpClient | undefined;
2764
+ }, {
2765
+ callbacks?: [GatewayCallbackType<any>, ...GatewayCallbackType<any>[]] | undefined;
2766
+ dangerouslyAllowBrowser?: boolean | undefined;
2767
+ httpClient?: HttpClient | undefined;
2768
+ }>;
2769
+ type GatewayOptionsType = z.infer<typeof GatewayOptions>;
2770
+ declare const GatewayCompleteChatRequest: z.ZodObject<{
2771
+ model: z.ZodType<ChatModelV1<{
2772
+ name: string;
2773
+ description: string;
2774
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
2775
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
2776
+ maxInputTokens: number;
2777
+ maxOutputTokens: number;
2778
+ config: {
2779
+ def: Record<string, {
2780
+ type: "multi-string";
2781
+ param: string;
2782
+ title: string;
2783
+ description: string;
2784
+ max: number;
2785
+ } | {
2786
+ type: "range";
2787
+ param: string;
2788
+ title: string;
2789
+ description: string;
2790
+ max: number;
2791
+ min: number;
2792
+ step: number;
2793
+ default: number;
2794
+ } | {
2795
+ type: "select-string";
2796
+ param: string;
2797
+ title: string;
2798
+ description: string;
2799
+ default: string;
2800
+ choices: string[];
2801
+ } | {
2802
+ type: "object-schema";
2803
+ param: string;
2804
+ title: string;
2805
+ description: string;
2806
+ objectSchema?: any;
2807
+ }>;
2808
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
2809
+ };
2810
+ }>, z.ZodTypeDef, ChatModelV1<{
2811
+ name: string;
2812
+ description: string;
2813
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
2814
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
2815
+ maxInputTokens: number;
2816
+ maxOutputTokens: number;
2817
+ config: {
2818
+ def: Record<string, {
2819
+ type: "multi-string";
2820
+ param: string;
2821
+ title: string;
2822
+ description: string;
2823
+ max: number;
2824
+ } | {
2825
+ type: "range";
2826
+ param: string;
2827
+ title: string;
2828
+ description: string;
2829
+ max: number;
2830
+ min: number;
2831
+ step: number;
2832
+ default: number;
2833
+ } | {
2834
+ type: "select-string";
2835
+ param: string;
2836
+ title: string;
2837
+ description: string;
2838
+ default: string;
2839
+ choices: string[];
2840
+ } | {
2841
+ type: "object-schema";
2842
+ param: string;
2843
+ title: string;
2844
+ description: string;
2845
+ objectSchema?: any;
2846
+ }>;
2847
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
2848
+ };
2849
+ }>>;
2850
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
2851
+ messages: z.ZodArray<z.ZodObject<{
2852
+ role: z.ZodEnum<["system", "user", "assistant", "tool"]>;
2853
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"modality", [z.ZodObject<{
2854
+ modality: z.ZodLiteral<"text">;
2855
+ value: z.ZodString;
2856
+ metadata: z.ZodUndefined;
2857
+ }, "strip", z.ZodTypeAny, {
2858
+ value: string;
2859
+ modality: "text";
2860
+ metadata?: undefined;
2861
+ }, {
2862
+ value: string;
2863
+ modality: "text";
2864
+ metadata?: undefined;
2865
+ }>, z.ZodObject<{
2866
+ modality: z.ZodLiteral<"image">;
2867
+ detail: z.ZodEnum<["low", "medium", "high", "auto"]>;
2868
+ value: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
2869
+ type: z.ZodLiteral<"base64">;
2870
+ base64: z.ZodString;
2871
+ }, "strip", z.ZodTypeAny, {
2872
+ type: "base64";
2873
+ base64: string;
2874
+ }, {
2875
+ type: "base64";
2876
+ base64: string;
2877
+ }>, z.ZodObject<{
2878
+ type: z.ZodLiteral<"url">;
2879
+ url: z.ZodString;
2880
+ }, "strip", z.ZodTypeAny, {
2881
+ type: "url";
2882
+ url: string;
2883
+ }, {
2884
+ type: "url";
2885
+ url: string;
2886
+ }>]>;
2887
+ metadata: z.ZodUndefined;
2888
+ }, "strip", z.ZodTypeAny, {
2889
+ value: {
2890
+ type: "base64";
2891
+ base64: string;
2892
+ } | {
2893
+ type: "url";
2894
+ url: string;
2895
+ };
2896
+ modality: "image";
2897
+ detail: "low" | "medium" | "high" | "auto";
2898
+ metadata?: undefined;
2899
+ }, {
2900
+ value: {
2901
+ type: "base64";
2902
+ base64: string;
2903
+ } | {
2904
+ type: "url";
2905
+ url: string;
2906
+ };
2907
+ modality: "image";
2908
+ detail: "low" | "medium" | "high" | "auto";
2909
+ metadata?: undefined;
2910
+ }>, z.ZodObject<{
2911
+ modality: z.ZodLiteral<"tool-call">;
2912
+ index: z.ZodNumber;
2913
+ id: z.ZodString;
2914
+ name: z.ZodString;
2915
+ arguments: z.ZodString;
2916
+ metadata: z.ZodUndefined;
2917
+ }, "strip", z.ZodTypeAny, {
2918
+ name: string;
2919
+ modality: "tool-call";
2920
+ index: number;
2921
+ id: string;
2922
+ arguments: string;
2923
+ metadata?: undefined;
2924
+ }, {
2925
+ name: string;
2926
+ modality: "tool-call";
2927
+ index: number;
2928
+ id: string;
2929
+ arguments: string;
2930
+ metadata?: undefined;
2931
+ }>, z.ZodObject<{
2932
+ modality: z.ZodLiteral<"tool-response">;
2933
+ index: z.ZodNumber;
2934
+ id: z.ZodString;
2935
+ name: z.ZodString;
2936
+ data: z.ZodString;
2937
+ metadata: z.ZodUndefined;
2938
+ }, "strip", z.ZodTypeAny, {
2939
+ data: string;
2940
+ name: string;
2941
+ modality: "tool-response";
2942
+ index: number;
2943
+ id: string;
2944
+ metadata?: undefined;
2945
+ }, {
2946
+ data: string;
2947
+ name: string;
2948
+ modality: "tool-response";
2949
+ index: number;
2950
+ id: string;
2951
+ metadata?: undefined;
2952
+ }>]>, "many">;
2953
+ metadata: z.ZodUndefined;
2954
+ }, "strip", z.ZodTypeAny, {
2955
+ role: "system" | "user" | "assistant" | "tool";
2956
+ content: ({
2957
+ value: string;
2958
+ modality: "text";
2959
+ metadata?: undefined;
2960
+ } | {
2961
+ value: {
2962
+ type: "base64";
2963
+ base64: string;
2964
+ } | {
2965
+ type: "url";
2966
+ url: string;
2967
+ };
2968
+ modality: "image";
2969
+ detail: "low" | "medium" | "high" | "auto";
2970
+ metadata?: undefined;
2971
+ } | {
2972
+ name: string;
2973
+ modality: "tool-call";
2974
+ index: number;
2975
+ id: string;
2976
+ arguments: string;
2977
+ metadata?: undefined;
2978
+ } | {
2979
+ data: string;
2980
+ name: string;
2981
+ modality: "tool-response";
2982
+ index: number;
2983
+ id: string;
2984
+ metadata?: undefined;
2985
+ })[];
2986
+ metadata?: undefined;
2987
+ }, {
2988
+ role: "system" | "user" | "assistant" | "tool";
2989
+ content: ({
2990
+ value: string;
2991
+ modality: "text";
2992
+ metadata?: undefined;
2993
+ } | {
2994
+ value: {
2995
+ type: "base64";
2996
+ base64: string;
2997
+ } | {
2998
+ type: "url";
2999
+ url: string;
3000
+ };
3001
+ modality: "image";
3002
+ detail: "low" | "medium" | "high" | "auto";
3003
+ metadata?: undefined;
3004
+ } | {
3005
+ name: string;
3006
+ modality: "tool-call";
3007
+ index: number;
3008
+ id: string;
3009
+ arguments: string;
3010
+ metadata?: undefined;
3011
+ } | {
3012
+ data: string;
3013
+ name: string;
3014
+ modality: "tool-response";
3015
+ index: number;
3016
+ id: string;
3017
+ metadata?: undefined;
3018
+ })[];
3019
+ metadata?: undefined;
3020
+ }>, "many">;
3021
+ tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<z.objectUtil.extendShape<{
3022
+ type: z.ZodEnum<["function"]>;
3023
+ definition: z.ZodObject<{
3024
+ schema: z.ZodObject<{
3025
+ name: z.ZodString;
3026
+ description: z.ZodString;
3027
+ parameters: z.ZodAny;
3028
+ strict: z.ZodOptional<z.ZodBoolean>;
3029
+ }, "strip", z.ZodTypeAny, {
3030
+ name: string;
3031
+ description: string;
3032
+ strict?: boolean | undefined;
3033
+ parameters?: any;
3034
+ }, {
3035
+ name: string;
3036
+ description: string;
3037
+ strict?: boolean | undefined;
3038
+ parameters?: any;
3039
+ }>;
3040
+ }, "strip", z.ZodTypeAny, {
3041
+ schema: {
3042
+ name: string;
3043
+ description: string;
3044
+ strict?: boolean | undefined;
3045
+ parameters?: any;
3046
+ };
3047
+ }, {
3048
+ schema: {
3049
+ name: string;
3050
+ description: string;
3051
+ strict?: boolean | undefined;
3052
+ parameters?: any;
3053
+ };
3054
+ }>;
3055
+ }, {
3056
+ metadata: z.ZodTypeAny;
3057
+ }>, "strip", z.ZodTypeAny, {
3058
+ type: "function";
3059
+ definition: {
3060
+ schema: {
3061
+ name: string;
3062
+ description: string;
3063
+ strict?: boolean | undefined;
3064
+ parameters?: any;
3065
+ };
3066
+ };
3067
+ metadata?: any;
3068
+ }, {
3069
+ type: "function";
3070
+ definition: {
3071
+ schema: {
3072
+ name: string;
3073
+ description: string;
3074
+ strict?: boolean | undefined;
3075
+ parameters?: any;
3076
+ };
3077
+ };
3078
+ metadata?: any;
3079
+ }>]>, "many">>;
3080
+ options: z.ZodOptional<z.ZodObject<{
3081
+ queuePriority: z.ZodOptional<z.ZodNumber>;
3082
+ metadataForCallbacks: z.ZodOptional<z.ZodAny>;
3083
+ }, "strip", z.ZodTypeAny, {
3084
+ metadataForCallbacks?: any;
3085
+ queuePriority?: number | undefined;
3086
+ }, {
3087
+ metadataForCallbacks?: any;
3088
+ queuePriority?: number | undefined;
3089
+ }>>;
3090
+ }, "strip", z.ZodTypeAny, {
3091
+ config: Record<string, any>;
3092
+ model: ChatModelV1<{
3093
+ name: string;
3094
+ description: string;
3095
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
3096
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
3097
+ maxInputTokens: number;
3098
+ maxOutputTokens: number;
3099
+ config: {
3100
+ def: Record<string, {
3101
+ type: "multi-string";
3102
+ param: string;
3103
+ title: string;
3104
+ description: string;
3105
+ max: number;
3106
+ } | {
3107
+ type: "range";
3108
+ param: string;
3109
+ title: string;
3110
+ description: string;
3111
+ max: number;
3112
+ min: number;
3113
+ step: number;
3114
+ default: number;
3115
+ } | {
3116
+ type: "select-string";
3117
+ param: string;
3118
+ title: string;
3119
+ description: string;
3120
+ default: string;
3121
+ choices: string[];
3122
+ } | {
3123
+ type: "object-schema";
3124
+ param: string;
3125
+ title: string;
3126
+ description: string;
3127
+ objectSchema?: any;
3128
+ }>;
3129
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
3130
+ };
3131
+ }>;
3132
+ messages: {
3133
+ role: "system" | "user" | "assistant" | "tool";
3134
+ content: ({
3135
+ value: string;
3136
+ modality: "text";
3137
+ metadata?: undefined;
3138
+ } | {
3139
+ value: {
3140
+ type: "base64";
3141
+ base64: string;
3142
+ } | {
3143
+ type: "url";
3144
+ url: string;
3145
+ };
3146
+ modality: "image";
3147
+ detail: "low" | "medium" | "high" | "auto";
3148
+ metadata?: undefined;
3149
+ } | {
3150
+ name: string;
3151
+ modality: "tool-call";
3152
+ index: number;
3153
+ id: string;
3154
+ arguments: string;
3155
+ metadata?: undefined;
3156
+ } | {
3157
+ data: string;
3158
+ name: string;
3159
+ modality: "tool-response";
3160
+ index: number;
3161
+ id: string;
3162
+ metadata?: undefined;
3163
+ })[];
3164
+ metadata?: undefined;
3165
+ }[];
3166
+ options?: {
3167
+ metadataForCallbacks?: any;
3168
+ queuePriority?: number | undefined;
3169
+ } | undefined;
3170
+ tools?: {
3171
+ type: "function";
3172
+ definition: {
3173
+ schema: {
3174
+ name: string;
3175
+ description: string;
3176
+ strict?: boolean | undefined;
3177
+ parameters?: any;
3178
+ };
3179
+ };
3180
+ metadata?: any;
3181
+ }[] | undefined;
3182
+ }, {
3183
+ config: Record<string, any>;
3184
+ model: ChatModelV1<{
3185
+ name: string;
3186
+ description: string;
3187
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
3188
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
3189
+ maxInputTokens: number;
3190
+ maxOutputTokens: number;
3191
+ config: {
3192
+ def: Record<string, {
3193
+ type: "multi-string";
3194
+ param: string;
3195
+ title: string;
3196
+ description: string;
3197
+ max: number;
3198
+ } | {
3199
+ type: "range";
3200
+ param: string;
3201
+ title: string;
3202
+ description: string;
3203
+ max: number;
3204
+ min: number;
3205
+ step: number;
3206
+ default: number;
3207
+ } | {
3208
+ type: "select-string";
3209
+ param: string;
3210
+ title: string;
3211
+ description: string;
3212
+ default: string;
3213
+ choices: string[];
3214
+ } | {
3215
+ type: "object-schema";
3216
+ param: string;
3217
+ title: string;
3218
+ description: string;
3219
+ objectSchema?: any;
3220
+ }>;
3221
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
3222
+ };
3223
+ }>;
3224
+ messages: {
3225
+ role: "system" | "user" | "assistant" | "tool";
3226
+ content: ({
3227
+ value: string;
3228
+ modality: "text";
3229
+ metadata?: undefined;
3230
+ } | {
3231
+ value: {
3232
+ type: "base64";
3233
+ base64: string;
3234
+ } | {
3235
+ type: "url";
3236
+ url: string;
3237
+ };
3238
+ modality: "image";
3239
+ detail: "low" | "medium" | "high" | "auto";
3240
+ metadata?: undefined;
3241
+ } | {
3242
+ name: string;
3243
+ modality: "tool-call";
3244
+ index: number;
3245
+ id: string;
3246
+ arguments: string;
3247
+ metadata?: undefined;
3248
+ } | {
3249
+ data: string;
3250
+ name: string;
3251
+ modality: "tool-response";
3252
+ index: number;
3253
+ id: string;
3254
+ metadata?: undefined;
3255
+ })[];
3256
+ metadata?: undefined;
3257
+ }[];
3258
+ options?: {
3259
+ metadataForCallbacks?: any;
3260
+ queuePriority?: number | undefined;
3261
+ } | undefined;
3262
+ tools?: {
3263
+ type: "function";
3264
+ definition: {
3265
+ schema: {
3266
+ name: string;
3267
+ description: string;
3268
+ strict?: boolean | undefined;
3269
+ parameters?: any;
3270
+ };
3271
+ };
3272
+ metadata?: any;
3273
+ }[] | undefined;
3274
+ }>;
3275
+ type GatewayCompleteChatRequestType = z.infer<typeof GatewayCompleteChatRequest>;
3276
+ declare const GatewayStreamChatRequest: z.ZodObject<{
3277
+ model: z.ZodType<ChatModelV1<{
3278
+ name: string;
3279
+ description: string;
3280
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
3281
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
3282
+ maxInputTokens: number;
3283
+ maxOutputTokens: number;
3284
+ config: {
3285
+ def: Record<string, {
3286
+ type: "multi-string";
3287
+ param: string;
3288
+ title: string;
3289
+ description: string;
3290
+ max: number;
3291
+ } | {
3292
+ type: "range";
3293
+ param: string;
3294
+ title: string;
3295
+ description: string;
3296
+ max: number;
3297
+ min: number;
3298
+ step: number;
3299
+ default: number;
3300
+ } | {
3301
+ type: "select-string";
3302
+ param: string;
3303
+ title: string;
3304
+ description: string;
3305
+ default: string;
3306
+ choices: string[];
3307
+ } | {
3308
+ type: "object-schema";
3309
+ param: string;
3310
+ title: string;
3311
+ description: string;
3312
+ objectSchema?: any;
3313
+ }>;
3314
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
3315
+ };
3316
+ }>, z.ZodTypeDef, ChatModelV1<{
3317
+ name: string;
3318
+ description: string;
3319
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
3320
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
3321
+ maxInputTokens: number;
3322
+ maxOutputTokens: number;
3323
+ config: {
3324
+ def: Record<string, {
3325
+ type: "multi-string";
3326
+ param: string;
3327
+ title: string;
3328
+ description: string;
3329
+ max: number;
3330
+ } | {
3331
+ type: "range";
3332
+ param: string;
3333
+ title: string;
3334
+ description: string;
3335
+ max: number;
3336
+ min: number;
3337
+ step: number;
3338
+ default: number;
3339
+ } | {
3340
+ type: "select-string";
3341
+ param: string;
3342
+ title: string;
3343
+ description: string;
3344
+ default: string;
3345
+ choices: string[];
3346
+ } | {
3347
+ type: "object-schema";
3348
+ param: string;
3349
+ title: string;
3350
+ description: string;
3351
+ objectSchema?: any;
3352
+ }>;
3353
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
3354
+ };
3355
+ }>>;
3356
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
3357
+ messages: z.ZodArray<z.ZodObject<{
3358
+ role: z.ZodEnum<["system", "user", "assistant", "tool"]>;
3359
+ content: z.ZodArray<z.ZodDiscriminatedUnion<"modality", [z.ZodObject<{
3360
+ modality: z.ZodLiteral<"text">;
3361
+ value: z.ZodString;
3362
+ metadata: z.ZodUndefined;
3363
+ }, "strip", z.ZodTypeAny, {
3364
+ value: string;
3365
+ modality: "text";
3366
+ metadata?: undefined;
3367
+ }, {
3368
+ value: string;
3369
+ modality: "text";
3370
+ metadata?: undefined;
3371
+ }>, z.ZodObject<{
3372
+ modality: z.ZodLiteral<"image">;
3373
+ detail: z.ZodEnum<["low", "medium", "high", "auto"]>;
3374
+ value: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
3375
+ type: z.ZodLiteral<"base64">;
3376
+ base64: z.ZodString;
3377
+ }, "strip", z.ZodTypeAny, {
3378
+ type: "base64";
3379
+ base64: string;
3380
+ }, {
3381
+ type: "base64";
3382
+ base64: string;
3383
+ }>, z.ZodObject<{
3384
+ type: z.ZodLiteral<"url">;
3385
+ url: z.ZodString;
3386
+ }, "strip", z.ZodTypeAny, {
3387
+ type: "url";
3388
+ url: string;
3389
+ }, {
3390
+ type: "url";
3391
+ url: string;
3392
+ }>]>;
3393
+ metadata: z.ZodUndefined;
3394
+ }, "strip", z.ZodTypeAny, {
3395
+ value: {
3396
+ type: "base64";
3397
+ base64: string;
3398
+ } | {
3399
+ type: "url";
3400
+ url: string;
3401
+ };
3402
+ modality: "image";
3403
+ detail: "low" | "medium" | "high" | "auto";
3404
+ metadata?: undefined;
3405
+ }, {
3406
+ value: {
3407
+ type: "base64";
3408
+ base64: string;
3409
+ } | {
3410
+ type: "url";
3411
+ url: string;
3412
+ };
3413
+ modality: "image";
3414
+ detail: "low" | "medium" | "high" | "auto";
3415
+ metadata?: undefined;
3416
+ }>, z.ZodObject<{
3417
+ modality: z.ZodLiteral<"tool-call">;
3418
+ index: z.ZodNumber;
3419
+ id: z.ZodString;
3420
+ name: z.ZodString;
3421
+ arguments: z.ZodString;
3422
+ metadata: z.ZodUndefined;
3423
+ }, "strip", z.ZodTypeAny, {
3424
+ name: string;
3425
+ modality: "tool-call";
3426
+ index: number;
3427
+ id: string;
3428
+ arguments: string;
3429
+ metadata?: undefined;
3430
+ }, {
3431
+ name: string;
3432
+ modality: "tool-call";
3433
+ index: number;
3434
+ id: string;
3435
+ arguments: string;
3436
+ metadata?: undefined;
3437
+ }>, z.ZodObject<{
3438
+ modality: z.ZodLiteral<"tool-response">;
3439
+ index: z.ZodNumber;
3440
+ id: z.ZodString;
3441
+ name: z.ZodString;
3442
+ data: z.ZodString;
3443
+ metadata: z.ZodUndefined;
3444
+ }, "strip", z.ZodTypeAny, {
3445
+ data: string;
3446
+ name: string;
3447
+ modality: "tool-response";
3448
+ index: number;
3449
+ id: string;
3450
+ metadata?: undefined;
3451
+ }, {
3452
+ data: string;
3453
+ name: string;
3454
+ modality: "tool-response";
3455
+ index: number;
3456
+ id: string;
3457
+ metadata?: undefined;
3458
+ }>]>, "many">;
3459
+ metadata: z.ZodUndefined;
3460
+ }, "strip", z.ZodTypeAny, {
3461
+ role: "system" | "user" | "assistant" | "tool";
3462
+ content: ({
3463
+ value: string;
3464
+ modality: "text";
3465
+ metadata?: undefined;
3466
+ } | {
3467
+ value: {
3468
+ type: "base64";
3469
+ base64: string;
3470
+ } | {
3471
+ type: "url";
3472
+ url: string;
3473
+ };
3474
+ modality: "image";
3475
+ detail: "low" | "medium" | "high" | "auto";
3476
+ metadata?: undefined;
3477
+ } | {
3478
+ name: string;
3479
+ modality: "tool-call";
3480
+ index: number;
3481
+ id: string;
3482
+ arguments: string;
3483
+ metadata?: undefined;
3484
+ } | {
3485
+ data: string;
3486
+ name: string;
3487
+ modality: "tool-response";
3488
+ index: number;
3489
+ id: string;
3490
+ metadata?: undefined;
3491
+ })[];
3492
+ metadata?: undefined;
3493
+ }, {
3494
+ role: "system" | "user" | "assistant" | "tool";
3495
+ content: ({
3496
+ value: string;
3497
+ modality: "text";
3498
+ metadata?: undefined;
3499
+ } | {
3500
+ value: {
3501
+ type: "base64";
3502
+ base64: string;
3503
+ } | {
3504
+ type: "url";
3505
+ url: string;
3506
+ };
3507
+ modality: "image";
3508
+ detail: "low" | "medium" | "high" | "auto";
3509
+ metadata?: undefined;
3510
+ } | {
3511
+ name: string;
3512
+ modality: "tool-call";
3513
+ index: number;
3514
+ id: string;
3515
+ arguments: string;
3516
+ metadata?: undefined;
3517
+ } | {
3518
+ data: string;
3519
+ name: string;
3520
+ modality: "tool-response";
3521
+ index: number;
3522
+ id: string;
3523
+ metadata?: undefined;
3524
+ })[];
3525
+ metadata?: undefined;
3526
+ }>, "many">;
3527
+ tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<z.objectUtil.extendShape<{
3528
+ type: z.ZodEnum<["function"]>;
3529
+ definition: z.ZodObject<{
3530
+ schema: z.ZodObject<{
3531
+ name: z.ZodString;
3532
+ description: z.ZodString;
3533
+ parameters: z.ZodAny;
3534
+ strict: z.ZodOptional<z.ZodBoolean>;
3535
+ }, "strip", z.ZodTypeAny, {
3536
+ name: string;
3537
+ description: string;
3538
+ strict?: boolean | undefined;
3539
+ parameters?: any;
3540
+ }, {
3541
+ name: string;
3542
+ description: string;
3543
+ strict?: boolean | undefined;
3544
+ parameters?: any;
3545
+ }>;
3546
+ }, "strip", z.ZodTypeAny, {
3547
+ schema: {
3548
+ name: string;
3549
+ description: string;
3550
+ strict?: boolean | undefined;
3551
+ parameters?: any;
3552
+ };
3553
+ }, {
3554
+ schema: {
3555
+ name: string;
3556
+ description: string;
3557
+ strict?: boolean | undefined;
3558
+ parameters?: any;
3559
+ };
3560
+ }>;
3561
+ }, {
3562
+ metadata: z.ZodTypeAny;
3563
+ }>, "strip", z.ZodTypeAny, {
3564
+ type: "function";
3565
+ definition: {
3566
+ schema: {
3567
+ name: string;
3568
+ description: string;
3569
+ strict?: boolean | undefined;
3570
+ parameters?: any;
3571
+ };
3572
+ };
3573
+ metadata?: any;
3574
+ }, {
3575
+ type: "function";
3576
+ definition: {
3577
+ schema: {
3578
+ name: string;
3579
+ description: string;
3580
+ strict?: boolean | undefined;
3581
+ parameters?: any;
3582
+ };
3583
+ };
3584
+ metadata?: any;
3585
+ }>]>, "many">>;
3586
+ options: z.ZodOptional<z.ZodObject<{
3587
+ queuePriority: z.ZodOptional<z.ZodNumber>;
3588
+ metadataForCallbacks: z.ZodOptional<z.ZodAny>;
3589
+ }, "strip", z.ZodTypeAny, {
3590
+ metadataForCallbacks?: any;
3591
+ queuePriority?: number | undefined;
3592
+ }, {
3593
+ metadataForCallbacks?: any;
3594
+ queuePriority?: number | undefined;
3595
+ }>>;
3596
+ }, "strip", z.ZodTypeAny, {
3597
+ config: Record<string, any>;
3598
+ model: ChatModelV1<{
3599
+ name: string;
3600
+ description: string;
3601
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
3602
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
3603
+ maxInputTokens: number;
3604
+ maxOutputTokens: number;
3605
+ config: {
3606
+ def: Record<string, {
3607
+ type: "multi-string";
3608
+ param: string;
3609
+ title: string;
3610
+ description: string;
3611
+ max: number;
3612
+ } | {
3613
+ type: "range";
3614
+ param: string;
3615
+ title: string;
3616
+ description: string;
3617
+ max: number;
3618
+ min: number;
3619
+ step: number;
3620
+ default: number;
3621
+ } | {
3622
+ type: "select-string";
3623
+ param: string;
3624
+ title: string;
3625
+ description: string;
3626
+ default: string;
3627
+ choices: string[];
3628
+ } | {
3629
+ type: "object-schema";
3630
+ param: string;
3631
+ title: string;
3632
+ description: string;
3633
+ objectSchema?: any;
3634
+ }>;
3635
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
3636
+ };
3637
+ }>;
3638
+ messages: {
3639
+ role: "system" | "user" | "assistant" | "tool";
3640
+ content: ({
3641
+ value: string;
3642
+ modality: "text";
3643
+ metadata?: undefined;
3644
+ } | {
3645
+ value: {
3646
+ type: "base64";
3647
+ base64: string;
3648
+ } | {
3649
+ type: "url";
3650
+ url: string;
3651
+ };
3652
+ modality: "image";
3653
+ detail: "low" | "medium" | "high" | "auto";
3654
+ metadata?: undefined;
3655
+ } | {
3656
+ name: string;
3657
+ modality: "tool-call";
3658
+ index: number;
3659
+ id: string;
3660
+ arguments: string;
3661
+ metadata?: undefined;
3662
+ } | {
3663
+ data: string;
3664
+ name: string;
3665
+ modality: "tool-response";
3666
+ index: number;
3667
+ id: string;
3668
+ metadata?: undefined;
3669
+ })[];
3670
+ metadata?: undefined;
3671
+ }[];
3672
+ options?: {
3673
+ metadataForCallbacks?: any;
3674
+ queuePriority?: number | undefined;
3675
+ } | undefined;
3676
+ tools?: {
3677
+ type: "function";
3678
+ definition: {
3679
+ schema: {
3680
+ name: string;
3681
+ description: string;
3682
+ strict?: boolean | undefined;
3683
+ parameters?: any;
3684
+ };
3685
+ };
3686
+ metadata?: any;
3687
+ }[] | undefined;
3688
+ }, {
3689
+ config: Record<string, any>;
3690
+ model: ChatModelV1<{
3691
+ name: string;
3692
+ description: string;
3693
+ roles: Partial<Record<"system" | "user" | "assistant" | "tool", string | undefined>>;
3694
+ modalities: ["text" | "image" | "tool-call" | "tool-response", ...("text" | "image" | "tool-call" | "tool-response")[]];
3695
+ maxInputTokens: number;
3696
+ maxOutputTokens: number;
3697
+ config: {
3698
+ def: Record<string, {
3699
+ type: "multi-string";
3700
+ param: string;
3701
+ title: string;
3702
+ description: string;
3703
+ max: number;
3704
+ } | {
3705
+ type: "range";
3706
+ param: string;
3707
+ title: string;
3708
+ description: string;
3709
+ max: number;
3710
+ min: number;
3711
+ step: number;
3712
+ default: number;
3713
+ } | {
3714
+ type: "select-string";
3715
+ param: string;
3716
+ title: string;
3717
+ description: string;
3718
+ default: string;
3719
+ choices: string[];
3720
+ } | {
3721
+ type: "object-schema";
3722
+ param: string;
3723
+ title: string;
3724
+ description: string;
3725
+ objectSchema?: any;
3726
+ }>;
3727
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
3728
+ };
3729
+ }>;
3730
+ messages: {
3731
+ role: "system" | "user" | "assistant" | "tool";
3732
+ content: ({
3733
+ value: string;
3734
+ modality: "text";
3735
+ metadata?: undefined;
3736
+ } | {
3737
+ value: {
3738
+ type: "base64";
3739
+ base64: string;
3740
+ } | {
3741
+ type: "url";
3742
+ url: string;
3743
+ };
3744
+ modality: "image";
3745
+ detail: "low" | "medium" | "high" | "auto";
3746
+ metadata?: undefined;
3747
+ } | {
3748
+ name: string;
3749
+ modality: "tool-call";
3750
+ index: number;
3751
+ id: string;
3752
+ arguments: string;
3753
+ metadata?: undefined;
3754
+ } | {
3755
+ data: string;
3756
+ name: string;
3757
+ modality: "tool-response";
3758
+ index: number;
3759
+ id: string;
3760
+ metadata?: undefined;
3761
+ })[];
3762
+ metadata?: undefined;
3763
+ }[];
3764
+ options?: {
3765
+ metadataForCallbacks?: any;
3766
+ queuePriority?: number | undefined;
3767
+ } | undefined;
3768
+ tools?: {
3769
+ type: "function";
3770
+ definition: {
3771
+ schema: {
3772
+ name: string;
3773
+ description: string;
3774
+ strict?: boolean | undefined;
3775
+ parameters?: any;
3776
+ };
3777
+ };
3778
+ metadata?: any;
3779
+ }[] | undefined;
3780
+ }>;
3781
+ type GatewayStreamChatRequestType = z.infer<typeof GatewayStreamChatRequest>;
3782
+ declare const GatewayGetEmbeddingsRequest: z.ZodObject<{
3783
+ model: z.ZodType<EmbeddingModelV1<{
3784
+ description: string;
3785
+ name: string;
3786
+ modalities: ["text" | "token", ...("text" | "token")[]];
3787
+ maxInputTokens: number;
3788
+ maxOutputTokens: number;
3789
+ config: {
3790
+ def: Record<string, {
3791
+ type: "multi-string";
3792
+ param: string;
3793
+ title: string;
3794
+ description: string;
3795
+ max: number;
3796
+ } | {
3797
+ type: "range";
3798
+ param: string;
3799
+ title: string;
3800
+ description: string;
3801
+ max: number;
3802
+ min: number;
3803
+ step: number;
3804
+ default: number;
3805
+ } | {
3806
+ type: "select-string";
3807
+ param: string;
3808
+ title: string;
3809
+ description: string;
3810
+ default: string;
3811
+ choices: string[];
3812
+ } | {
3813
+ type: "object-schema";
3814
+ param: string;
3815
+ title: string;
3816
+ description: string;
3817
+ objectSchema?: any;
3818
+ }>;
3819
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
3820
+ };
3821
+ }>, z.ZodTypeDef, EmbeddingModelV1<{
3822
+ description: string;
3823
+ name: string;
3824
+ modalities: ["text" | "token", ...("text" | "token")[]];
3825
+ maxInputTokens: number;
3826
+ maxOutputTokens: number;
3827
+ config: {
3828
+ def: Record<string, {
3829
+ type: "multi-string";
3830
+ param: string;
3831
+ title: string;
3832
+ description: string;
3833
+ max: number;
3834
+ } | {
3835
+ type: "range";
3836
+ param: string;
3837
+ title: string;
3838
+ description: string;
3839
+ max: number;
3840
+ min: number;
3841
+ step: number;
3842
+ default: number;
3843
+ } | {
3844
+ type: "select-string";
3845
+ param: string;
3846
+ title: string;
3847
+ description: string;
3848
+ default: string;
3849
+ choices: string[];
3850
+ } | {
3851
+ type: "object-schema";
3852
+ param: string;
3853
+ title: string;
3854
+ description: string;
3855
+ objectSchema?: any;
3856
+ }>;
3857
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
3858
+ };
3859
+ }>>;
3860
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
3861
+ embeddingRequests: z.ZodDiscriminatedUnion<"modality", [z.ZodObject<{
3862
+ modality: z.ZodLiteral<"text">;
3863
+ metadata: z.ZodUndefined;
3864
+ requests: z.ZodArray<z.ZodString, "many">;
3865
+ }, "strip", z.ZodTypeAny, {
3866
+ modality: "text";
3867
+ requests: string[];
3868
+ metadata?: undefined;
3869
+ }, {
3870
+ modality: "text";
3871
+ requests: string[];
3872
+ metadata?: undefined;
3873
+ }>, z.ZodObject<{
3874
+ modality: z.ZodLiteral<"token">;
3875
+ metadata: z.ZodUndefined;
3876
+ requests: z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">;
3877
+ }, "strip", z.ZodTypeAny, {
3878
+ modality: "token";
3879
+ requests: number[][];
3880
+ metadata?: undefined;
3881
+ }, {
3882
+ modality: "token";
3883
+ requests: number[][];
3884
+ metadata?: undefined;
3885
+ }>]>;
3886
+ options: z.ZodOptional<z.ZodObject<{
3887
+ queuePriority: z.ZodOptional<z.ZodNumber>;
3888
+ metadataForCallbacks: z.ZodOptional<z.ZodAny>;
3889
+ }, "strip", z.ZodTypeAny, {
3890
+ metadataForCallbacks?: any;
3891
+ queuePriority?: number | undefined;
3892
+ }, {
3893
+ metadataForCallbacks?: any;
3894
+ queuePriority?: number | undefined;
3895
+ }>>;
3896
+ }, "strip", z.ZodTypeAny, {
3897
+ config: Record<string, any>;
3898
+ model: EmbeddingModelV1<{
3899
+ description: string;
3900
+ name: string;
3901
+ modalities: ["text" | "token", ...("text" | "token")[]];
3902
+ maxInputTokens: number;
3903
+ maxOutputTokens: number;
3904
+ config: {
3905
+ def: Record<string, {
3906
+ type: "multi-string";
3907
+ param: string;
3908
+ title: string;
3909
+ description: string;
3910
+ max: number;
3911
+ } | {
3912
+ type: "range";
3913
+ param: string;
3914
+ title: string;
3915
+ description: string;
3916
+ max: number;
3917
+ min: number;
3918
+ step: number;
3919
+ default: number;
3920
+ } | {
3921
+ type: "select-string";
3922
+ param: string;
3923
+ title: string;
3924
+ description: string;
3925
+ default: string;
3926
+ choices: string[];
3927
+ } | {
3928
+ type: "object-schema";
3929
+ param: string;
3930
+ title: string;
3931
+ description: string;
3932
+ objectSchema?: any;
3933
+ }>;
3934
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
3935
+ };
3936
+ }>;
3937
+ embeddingRequests: {
3938
+ modality: "text";
3939
+ requests: string[];
3940
+ metadata?: undefined;
3941
+ } | {
3942
+ modality: "token";
3943
+ requests: number[][];
3944
+ metadata?: undefined;
3945
+ };
3946
+ options?: {
3947
+ metadataForCallbacks?: any;
3948
+ queuePriority?: number | undefined;
3949
+ } | undefined;
3950
+ }, {
3951
+ config: Record<string, any>;
3952
+ model: EmbeddingModelV1<{
3953
+ description: string;
3954
+ name: string;
3955
+ modalities: ["text" | "token", ...("text" | "token")[]];
3956
+ maxInputTokens: number;
3957
+ maxOutputTokens: number;
3958
+ config: {
3959
+ def: Record<string, {
3960
+ type: "multi-string";
3961
+ param: string;
3962
+ title: string;
3963
+ description: string;
3964
+ max: number;
3965
+ } | {
3966
+ type: "range";
3967
+ param: string;
3968
+ title: string;
3969
+ description: string;
3970
+ max: number;
3971
+ min: number;
3972
+ step: number;
3973
+ default: number;
3974
+ } | {
3975
+ type: "select-string";
3976
+ param: string;
3977
+ title: string;
3978
+ description: string;
3979
+ default: string;
3980
+ choices: string[];
3981
+ } | {
3982
+ type: "object-schema";
3983
+ param: string;
3984
+ title: string;
3985
+ description: string;
3986
+ objectSchema?: any;
3987
+ }>;
3988
+ schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
3989
+ };
3990
+ }>;
3991
+ embeddingRequests: {
3992
+ modality: "text";
3993
+ requests: string[];
3994
+ metadata?: undefined;
3995
+ } | {
3996
+ modality: "token";
3997
+ requests: number[][];
3998
+ metadata?: undefined;
3999
+ };
4000
+ options?: {
4001
+ metadataForCallbacks?: any;
4002
+ queuePriority?: number | undefined;
4003
+ } | undefined;
4004
+ }>;
4005
+ type GatewayGetEmbeddingsRequestType = z.infer<typeof GatewayGetEmbeddingsRequest>;
4006
+
4007
+ declare class Gateway {
4008
+ private options;
4009
+ private httpClient;
4010
+ private completeQueue;
4011
+ private embeddingQueue;
4012
+ constructor(options: GatewayOptionsType);
4013
+ completeChat(request: GatewayCompleteChatRequestType): Promise<CompleteChatHandlerResponseType>;
4014
+ private executeCompleteChatTask;
4015
+ streamChat(request: GatewayStreamChatRequestType): AsyncGenerator<StreamChatHandlerResponseType, void, unknown>;
4016
+ getEmbeddings(request: GatewayGetEmbeddingsRequestType): Promise<GetEmbeddingsHandlerResponseType>;
4017
+ private executeGetEmbeddingsTask;
4018
+ static GatewayError: typeof GatewayError;
4019
+ }
4020
+
4021
+ export { type CompleteChatCallbackType, CompleteChatHandlerRequest, type CompleteChatHandlerRequestType, CompleteChatHandlerResponse, type CompleteChatHandlerResponseType, Gateway, type GatewayCallbackType, GatewayError, type GatewayOptionsType, type GetEmbeddingsCallbackType, GetEmbeddingsHandlerRequest, type GetEmbeddingsHandlerRequestType, GetEmbeddingsHandlerResponse, type GetEmbeddingsHandlerResponseType, type HttpClient, type HttpClientResponse, IsomorphicHttpClient, IsomorphicHttpClientError, type Queue, SimpleQueue, type StreamChatCallbackType, StreamChatHandlerRequest, type StreamChatHandlerRequestType, StreamChatHandlerResponse, type StreamChatHandlerResponseType, type Task, handleCompleteChat, handleGetEmbeddings, handleStreamChat };