Repository navigation
Expand file tree
/
Copy pathtypescript-sdk-types.d.ts
More file actions
2546 lines (2435 loc) · 88.4 KB
/
Copy pathtypescript-sdk-types.d.ts
File metadata and controls
2546 lines (2435 loc) · 88.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { ReadableStream as ReadableStream_2 } from 'stream/web';
import { RequestInit as RequestInit_10 } from '../../../../../../../../../node_modules/undici-types/index.d.ts';
import { RequestInit as RequestInit_11 } from '../../../../../../../../../../node_modules/undici-types/index.d.ts';
import { RequestInit as RequestInit_12 } from '../node_modules/undici/index.d.ts';
import { RequestInit as RequestInit_13 } from '../../node_modules/undici/index.d.ts';
import { RequestInit as RequestInit_14 } from '../../../node_modules/undici/index.d.ts';
import { RequestInit as RequestInit_15 } from '../../../../node_modules/undici/index.d.ts';
import { RequestInit as RequestInit_16 } from '../../../../../node_modules/undici/index.d.ts';
import { RequestInit as RequestInit_17 } from '../../../../../../node_modules/undici/index.d.ts';
import { RequestInit as RequestInit_18 } from '../../../../../../../node_modules/undici/index.d.ts';
import { RequestInit as RequestInit_19 } from '../../../../../../../../node_modules/undici/index.d.ts';
import { RequestInit as RequestInit_2 } from '../node_modules/undici-types/index.d.ts';
import { RequestInit as RequestInit_20 } from '../../../../../../../../../node_modules/undici/index.d.ts';
import { RequestInit as RequestInit_21 } from '../../../../../../../../../../node_modules/undici/index.d.ts';
import { RequestInit as RequestInit_22 } from '../node_modules/@types/node-fetch/index.d.ts';
import { RequestInit as RequestInit_23 } from '../../node_modules/@types/node-fetch/index.d.ts';
import { RequestInit as RequestInit_24 } from '../../../node_modules/@types/node-fetch/index.d.ts';
import { RequestInit as RequestInit_25 } from '../../../../node_modules/@types/node-fetch/index.d.ts';
import { RequestInit as RequestInit_26 } from '../../../../../node_modules/@types/node-fetch/index.d.ts';
import { RequestInit as RequestInit_27 } from '../../../../../../node_modules/@types/node-fetch/index.d.ts';
import { RequestInit as RequestInit_28 } from '../../../../../../../node_modules/@types/node-fetch/index.d.ts';
import { RequestInit as RequestInit_29 } from '../../../../../../../../node_modules/@types/node-fetch/index.d.ts';
import { RequestInit as RequestInit_3 } from '../../node_modules/undici-types/index.d.ts';
import { RequestInit as RequestInit_30 } from '../../../../../../../../../node_modules/@types/node-fetch/index.d.ts';
import { RequestInit as RequestInit_31 } from '../../../../../../../../../../node_modules/@types/node-fetch/index.d.ts';
import { RequestInit as RequestInit_32 } from '../node_modules/node-fetch';
import { RequestInit as RequestInit_33 } from '../../node_modules/node-fetch';
import { RequestInit as RequestInit_34 } from '../../../node_modules/node-fetch';
import { RequestInit as RequestInit_35 } from '../../../../node_modules/node-fetch';
import { RequestInit as RequestInit_36 } from '../../../../../node_modules/node-fetch';
import { RequestInit as RequestInit_37 } from '../../../../../../node_modules/node-fetch';
import { RequestInit as RequestInit_38 } from '../../../../../../../node_modules/node-fetch';
import { RequestInit as RequestInit_39 } from '../../../../../../../../node_modules/node-fetch';
import { RequestInit as RequestInit_4 } from '../../../node_modules/undici-types/index.d.ts';
import { RequestInit as RequestInit_40 } from '../../../../../../../../../node_modules/node-fetch';
import { RequestInit as RequestInit_41 } from '../../../../../../../../../../node_modules/node-fetch';
import { RequestInit as RequestInit_5 } from '../../../../node_modules/undici-types/index.d.ts';
import { RequestInit as RequestInit_6 } from '../../../../../node_modules/undici-types/index.d.ts';
import { RequestInit as RequestInit_7 } from '../../../../../../node_modules/undici-types/index.d.ts';
import { RequestInit as RequestInit_8 } from '../../../../../../../node_modules/undici-types/index.d.ts';
import { RequestInit as RequestInit_9 } from '../../../../../../../../node_modules/undici-types/index.d.ts';
declare namespace API {
export {
Beta,
SearchResult,
BetaSearchParams,
TaskRun,
Input,
JsonSchema,
TaskRunResult,
TaskSpec,
TextSchema,
TaskRunCreateParams,
TaskRunResultParams
}
}
export declare class APIConnectionError extends APIError<undefined, undefined, undefined> {
constructor({ message, cause }: {
message?: string | undefined;
cause?: Error | undefined;
});
}
export declare class APIConnectionTimeoutError extends APIConnectionError {
constructor({ message }?: {
message?: string;
});
}
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends ParallelError {
/** HTTP status for the response that caused the error */
readonly status: TStatus;
/** HTTP headers for the response that caused the error */
readonly headers: THeaders;
/** JSON body of the response that caused the error */
readonly error: TError;
constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders);
private static makeMessage;
static generate(status: number | undefined, errorResponse: Object | undefined, message: string | undefined, headers: Headers | undefined): APIError;
}
/**
* A subclass of `Promise` providing additional helper methods
* for interacting with the SDK.
*/
export declare class APIPromise<T> extends Promise<T> {
#private;
private responsePromise;
private parseResponse;
private parsedPromise;
constructor(client: Parallel, responsePromise: Promise<APIResponseProps>, parseResponse?: (client: Parallel, props: APIResponseProps) => PromiseOrValue<T>);
_thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
/**
* Gets the raw `Response` instance instead of parsing the response
* data.
*
* If you want to parse the response body but still get the `Response`
* instance, you can use {@link withResponse()}.
*
* 👋 Getting the wrong TypeScript type for `Response`?
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
* to your `tsconfig.json`.
*/
asResponse(): Promise<Response>;
/**
* Gets the parsed response data and the raw `Response` instance.
*
* If you just want to get the raw `Response` instance without parsing it,
* you can use {@link asResponse()}.
*
* 👋 Getting the wrong TypeScript type for `Response`?
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
* to your `tsconfig.json`.
*/
withResponse(): Promise<{
data: T;
response: Response;
}>;
private parse;
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
}
declare abstract class APIResource {
protected _client: Parallel;
constructor(client: Parallel);
}
declare type APIResponseProps = {
response: Response;
options: FinalRequestOptions;
controller: AbortController;
requestLogID: string;
retryOfRequestLogID: string | undefined;
startTime: number;
};
export declare class APIUserAbortError extends APIError<undefined, undefined, undefined> {
constructor({ message }?: {
message?: string;
});
}
export declare class AuthenticationError extends APIError<401, Headers> {
}
export declare class BadRequestError extends APIError<400, Headers> {
}
declare class Beta extends APIResource {
taskGroup: TaskGroupAPI.TaskGroup;
/**
* Searches the web.
*/
search(body: BetaSearchParams, options?: RequestOptions): APIPromise<SearchResult>;
}
declare namespace Beta {
{ declare type SearchResult as SearchResult, declare type BetaSearchParams as BetaSearchParams };
{ declare type TaskGroup as TaskGroup, declare type TaskGroupRun as TaskGroupRun, declare type TaskGroupEventsResponse as TaskGroupEventsResponse, declare type TaskGroupRetrieveRunsResponse as TaskGroupRetrieveRunsResponse, declare type TaskGroupCreateParams as TaskGroupCreateParams, declare type TaskGroupAddRunsParams as TaskGroupAddRunsParams, declare type TaskGroupEventsParams as TaskGroupEventsParams, declare type TaskGroupRetrieveRunsParams as TaskGroupRetrieveRunsParams, };
}
declare interface BetaSearchParams {
/**
* Upper bound on the number of characters to include in excerpts for each search
* result.
*/
max_chars_per_result?: number | null;
/**
* Upper bound on the number of results to return. May be limited by the processor.
* Defaults to 10 if not provided.
*/
max_results?: number | null;
/**
* Natural-language description of what the web search is trying to find. May
* include guidance about preferred sources or freshness. At least one of objective
* or search_queries must be provided.
*/
objective?: string | null;
/**
* Search processor.
*/
processor?: 'base' | 'pro';
/**
* Optional list of traditional keyword search queries to guide the search. May
* contain search operators. At least one of objective or search_queries must be
* provided.
*/
search_queries?: Array<string> | null;
/**
* Source policy for web search results.
*
* This policy governs which sources are allowed/disallowed in results.
*/
source_policy?: BetaSearchParams.SourcePolicy | null;
}
declare namespace BetaSearchParams {
/**
* Source policy for web search results.
*
* This policy governs which sources are allowed/disallowed in results.
*/
interface SourcePolicy {
/**
* List of domains to exclude from results. If specified, sources from these
* domains will be excluded.
*/
exclude_domains?: Array<string>;
/**
* List of domains to restrict the results to. If specified, only sources from
* these domains will be included.
*/
include_domains?: Array<string>;
}
}
/**
* Intended to match DOM Blob, node-fetch Blob, node:buffer Blob, etc.
* Don't add arrayBuffer here, node-fetch doesn't have it
*/
declare interface BlobLike {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
readonly size: number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
readonly type: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
text(): Promise<string>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
slice(start?: number, end?: number): BlobLike;
}
declare type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | DataView;
/**
* A copy of the builtin `BlobPropertyBag` type as it isn't fully supported in certain
* environments and attempting to reference the global version will error.
*
* https://github.com/microsoft/TypeScript/blob/49ad1a3917a0ea57f5ff248159256e12bb1cb705/src/lib/dom.generated.d.ts#L154
* https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob#options
*/
declare interface BlobPropertyBag {
endings?: EndingType;
type?: string;
}
/**
* The type for constructing `RequestInit` body.
*
* https://developer.mozilla.org/docs/Web/API/RequestInit#body
*/
declare type _BodyInit = RequestInit['body'];
declare const brand_privateNullableHeaders: unique symbol;
declare interface BunFile extends Blob {
readonly name?: string | undefined;
}
/** @ts-ignore For users with \@types/bun */
declare type BunRequestInit = globalThis.FetchRequestInit;
export declare interface ClientOptions {
/**
* Defaults to process.env['PARALLEL_API_KEY'].
*/
apiKey?: string | undefined;
/**
* Specifies the environment to use for the API.
*
* Each environment maps to a different base URL:
* - `production` corresponds to `https://api.parallel.ai`
* - `staging` corresponds to `https://api.scl124ai.com/staging`
* - `canary` corresponds to `https://api.scl124ai.com/canary`
*/
environment?: Environment | undefined;
/**
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
*
* Defaults to process.env['PARALLEL_BASE_URL'].
*/
baseURL?: string | null | undefined;
/**
* The maximum amount of time (in milliseconds) that the client should wait for a response
* from the server before timing out a single request.
*
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
* much longer than this timeout before the promise succeeds or fails.
*
* @unit milliseconds
*/
timeout?: number | undefined;
/**
* Additional `RequestInit` options to be passed to `fetch` calls.
* Properties will be overridden by per-request `fetchOptions`.
*/
fetchOptions?: MergedRequestInit | undefined;
/**
* Specify a custom `fetch` function implementation.
*
* If not provided, we expect that `fetch` is defined globally.
*/
fetch?: Fetch | undefined;
/**
* The maximum number of times that the client will retry a request in case of a
* temporary failure, like a network error or a 5XX error from the server.
*
* @default 2
*/
maxRetries?: number | undefined;
/**
* Default headers to include with every request to the API.
*
* These can be removed in individual requests by explicitly setting the
* header to `null` in request options.
*/
defaultHeaders?: HeadersLike | undefined;
/**
* Default query parameters to include with every request to the API.
*
* These can be removed in individual requests by explicitly setting the
* param to `undefined` in request options.
*/
defaultQuery?: Record<string, string | undefined> | undefined;
/**
* Set the log level.
*
* Defaults to process.env['PARALLEL_LOG'] or 'warn' if it isn't set.
*/
logLevel?: LogLevel | undefined;
/**
* Set the logger.
*
* Defaults to globalThis.console.
*/
logger?: Logger | undefined;
}
declare type _ConditionalNodeReadableStream<R = any> = typeof globalThis extends {
ReadableStream: any;
} ? never : _NodeReadableStream<R>;
export declare class ConflictError extends APIError<409, Headers> {
}
/** @ts-ignore */
declare type _DOMReadableStream<R = any> = globalThis.ReadableStream<R>;
declare type EncodedContent = {
bodyHeaders: HeadersLike;
body: _BodyInit;
};
/**
* A copy of the builtin `EndingType` type as it isn't fully supported in certain
* environments and attempting to reference the global version will error.
*
* https://github.com/microsoft/TypeScript/blob/49ad1a3917a0ea57f5ff248159256e12bb1cb705/src/lib/dom.generated.d.ts#L27941
*/
declare type EndingType = 'native' | 'transparent';
declare type Environment = keyof typeof environments;
declare const environments: {
production: string;
staging: string;
canary: string;
};
declare namespace Errors {
export {
ParallelError,
APIError,
APIUserAbortError,
APIConnectionError,
APIConnectionTimeoutError,
BadRequestError,
AuthenticationError,
PermissionDeniedError,
NotFoundError,
ConflictError,
UnprocessableEntityError,
RateLimitError,
InternalServerError
}
}
declare const FallbackEncoder: RequestEncoder;
declare type Fetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
/** @ts-ignore For users who use Deno */
declare type FetchRequestInit = NonNullable<OverloadedParameters<typeof fetch>[1]>;
/**
* Intended to match DOM File, node:buffer File, undici File, etc.
*/
declare interface FileLike extends BlobLike {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
readonly lastModified: number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
readonly name?: string | undefined;
}
/**
* A copy of the builtin `FilePropertyBag` type as it isn't fully supported in certain
* environments and attempting to reference the global version will error.
*
* https://github.com/microsoft/TypeScript/blob/49ad1a3917a0ea57f5ff248159256e12bb1cb705/src/lib/dom.generated.d.ts#L503
* https://developer.mozilla.org/en-US/docs/Web/API/File/File#options
*/
declare interface FilePropertyBag extends BlobPropertyBag {
lastModified?: number;
}
declare type FinalizedRequestInit = RequestInit & {
headers: Headers;
};
declare type FinalRequestOptions = RequestOptions & {
method: HTTPMethod;
path: string;
};
declare type FsReadStream = AsyncIterable<Uint8Array> & {
path: string | {
toString(): string;
};
};
declare type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null | NullableHeaders;
declare type HeaderValue = string | undefined | null;
declare type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
/**
* Request to run a task.
*/
declare interface Input {
/**
* Input to the task, either text or a JSON object.
*/
input: string | unknown;
/**
* Processor to use for the task.
*/
processor: string;
/**
* User-provided metadata stored with the run. Keys and values must be strings with
* a maximum length of 16 and 512 characters respectively.
*/
metadata?: {
[key: string]: string | number | boolean;
} | null;
/**
* Source policy for web search results.
*
* This policy governs which sources are allowed/disallowed in results.
*/
source_policy?: Input.SourcePolicy | null;
/**
* Specification for a task.
*
* Auto output schemas can be specified by setting `output_schema={"type":"auto"}`.
* Not specifying a TaskSpec is the same as setting an auto output schema.
*
* For convenience bare strings are also accepted as input or output schemas.
*/
task_spec?: TaskSpec | null;
}
declare namespace Input {
/**
* Source policy for web search results.
*
* This policy governs which sources are allowed/disallowed in results.
*/
interface SourcePolicy {
/**
* List of domains to exclude from results. If specified, sources from these
* domains will be excluded.
*/
exclude_domains?: Array<string>;
/**
* List of domains to restrict the results to. If specified, only sources from
* these domains will be included.
*/
include_domains?: Array<string>;
}
}
export declare class InternalServerError extends APIError<number, Headers> {
}
/**
* JSON schema for a task input or output.
*/
declare interface JsonSchema {
/**
* A JSON Schema object. Only a subset of JSON Schema is supported.
*/
json_schema: unknown;
/**
* The type of schema being defined. Always `json`.
*/
type?: 'json';
}
declare type LogFn = (message: string, ...rest: unknown[]) => void;
declare type Logger = {
error: LogFn;
warn: LogFn;
info: LogFn;
debug: LogFn;
};
declare type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug';
/**
* This type contains `RequestInit` options that may be available on the current runtime,
* including per-platform extensions like `dispatcher`, `agent`, `client`, etc.
*/
declare type MergedRequestInit = RequestInits &
/** We don't include these in the types as they'll be overridden for every request. */
Partial<Record<'body' | 'headers' | 'method' | 'signal', never>>;
/**
* Shims for types that we can't always rely on being available globally.
*
* Note: these only exist at the type-level, there is no corresponding runtime
* version for any of these symbols.
*/
declare type NeverToAny<T> = T extends never ? any : T;
/** @ts-ignore For users with node-fetch@2 */
declare type NodeFetch2RequestInit = NotAny<RequestInit_22> | NotAny<RequestInit_23> | NotAny<RequestInit_24> | NotAny<RequestInit_25> | NotAny<RequestInit_26> | NotAny<RequestInit_27> | NotAny<RequestInit_28> | NotAny<RequestInit_29> | NotAny<RequestInit_30> | NotAny<RequestInit_31>;
/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */
declare type NodeFetch3RequestInit = NotAny<RequestInit_32> | NotAny<RequestInit_33> | NotAny<RequestInit_34> | NotAny<RequestInit_35> | NotAny<RequestInit_36> | NotAny<RequestInit_37> | NotAny<RequestInit_38> | NotAny<RequestInit_39> | NotAny<RequestInit_40> | NotAny<RequestInit_41>;
/** @ts-ignore */
declare type _NodeReadableStream<R = any> = ReadableStream_2<R>;
declare type NotAny<T> = [0] extends [1 & T] ? never : T;
export declare class NotFoundError extends APIError<404, Headers> {
}
/* Excluded from this release type: NullableHeaders */
declare namespace Opts {
export {
FinalRequestOptions,
RequestOptions,
EncodedContent,
RequestEncoder,
FallbackEncoder
}
}
/**
* Some environments overload the global fetch function, and Parameters<T> only gets the last signature.
*/
declare type OverloadedParameters<T> = T extends ({
(...args: infer A): unknown;
(...args: infer B): unknown;
(...args: infer C): unknown;
(...args: infer D): unknown;
}) ? A | B | C | D : T extends ({
(...args: infer A): unknown;
(...args: infer B): unknown;
(...args: infer C): unknown;
}) ? A | B | C : T extends ({
(...args: infer A): unknown;
(...args: infer B): unknown;
}) ? A | B : T extends (...args: infer A) => unknown ? A : never;
/**
* API Client for interfacing with the Parallel API.
*/
declare class Parallel {
#private;
apiKey: string;
baseURL: string;
maxRetries: number;
timeout: number;
logger: Logger | undefined;
logLevel: LogLevel | undefined;
fetchOptions: MergedRequestInit | undefined;
private fetch;
protected idempotencyHeader?: string;
private _options;
/**
* API Client for interfacing with the Parallel API.
*
* @param {string | undefined} [opts.apiKey=process.env['PARALLEL_API_KEY'] ?? undefined]
* @param {Environment} [opts.environment=production] - Specifies the environment URL to use for the API.
* @param {string} [opts.baseURL=process.env['PARALLEL_BASE_URL'] ?? https://api.parallel.ai] - Override the default base URL for the API.
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
*/
constructor({ baseURL, apiKey, ...opts }?: ClientOptions);
/**
* Create a new client instance re-using the same options given to the current client with optional overriding.
*/
withOptions(options: Partial<ClientOptions>): this;
protected defaultQuery(): Record<string, string | undefined> | undefined;
protected validateHeaders({ values, nulls }: NullableHeaders): void;
protected authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined>;
/**
* Basic re-implementation of `qs.stringify` for primitive types.
*/
protected stringifyQuery(query: Record<string, unknown>): string;
private getUserAgent;
protected defaultIdempotencyKey(): string;
protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError;
buildURL(path: string, query: Record<string, unknown> | null | undefined, defaultBaseURL?: string | undefined): string;
/**
* Used as a callback for mutating the given `FinalRequestOptions` object.
*/
protected prepareOptions(options: FinalRequestOptions): Promise<void>;
/**
* Used as a callback for mutating the given `RequestInit` object.
*
* This is useful for cases where you want to add certain headers based off of
* the request properties, e.g. `method` or `url`.
*/
protected prepareRequest(request: _RequestInit, { url, options }: {
url: string;
options: FinalRequestOptions;
}): Promise<void>;
get<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
post<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
patch<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
put<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
delete<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
private methodRequest;
request<Rsp>(options: PromiseOrValue<FinalRequestOptions>, remainingRetries?: number | null): APIPromise<Rsp>;
private makeRequest;
fetchWithTimeout(url: _RequestInfo, init: _RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
private shouldRetry;
private retryRequest;
private calculateDefaultRetryTimeoutMillis;
buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: {
retryCount?: number;
}): Promise<{
req: FinalizedRequestInit;
url: string;
timeout: number;
}>;
private buildHeaders;
private buildBody;
static Parallel: typeof Parallel;
static DEFAULT_TIMEOUT: number;
static ParallelError: typeof Errors.ParallelError;
static APIError: typeof Errors.APIError;
static APIConnectionError: typeof Errors.APIConnectionError;
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
static APIUserAbortError: typeof Errors.APIUserAbortError;
static NotFoundError: typeof Errors.NotFoundError;
static ConflictError: typeof Errors.ConflictError;
static RateLimitError: typeof Errors.RateLimitError;
static BadRequestError: typeof Errors.BadRequestError;
static AuthenticationError: typeof Errors.AuthenticationError;
static InternalServerError: typeof Errors.InternalServerError;
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
static toFile: typeof Uploads.toFile;
taskRun: API.TaskRun;
beta: API.Beta;
}
declare namespace Parallel {
type RequestOptions = Opts.RequestOptions;
{ declare type TaskRun as TaskRun, declare type Input as Input, declare type JsonSchema as JsonSchema, declare type TaskRunResult as TaskRunResult, declare type TaskSpec as TaskSpec, declare type TextSchema as TextSchema, declare type TaskRunCreateParams as TaskRunCreateParams, declare type TaskRunResultParams as TaskRunResultParams, };
{ Beta as Beta, declare type SearchResult as SearchResult, declare type BetaSearchParams as BetaSearchParams };
}
export { Parallel }
export default Parallel;
export declare class ParallelError extends Error {
}
export declare class PermissionDeniedError extends APIError<403, Headers> {
}
declare type PromiseOrValue<T> = T | Promise<T>;
export declare class RateLimitError extends APIError<429, Headers> {
}
declare type _ReadableStream_2<R = any> = NeverToAny<([0] extends [1 & _DOMReadableStream<R>] ? never : _DOMReadableStream<R>) | ([0] extends [1 & _ConditionalNodeReadableStream<R>] ? never : _ConditionalNodeReadableStream<R>)>;
declare type RequestEncoder = (request: {
headers: NullableHeaders;
body: unknown;
}) => EncodedContent;
/**
* The type for the first argument to `fetch`.
*
* https://developer.mozilla.org/docs/Web/API/Window/fetch#resource
*/
declare type _RequestInfo = Request | URL | string;
/**
* An alias to the builtin `RequestInit` type so we can
* easily alias it in import statements if there are name clashes.
*
* https://developer.mozilla.org/docs/Web/API/RequestInit
*/
declare type _RequestInit = RequestInit;
declare type RequestInits = NotAny<UndiciTypesRequestInit> | NotAny<UndiciRequestInit> | NotAny<BunRequestInit> | NotAny<NodeFetch2RequestInit> | NotAny<NodeFetch3RequestInit> | NotAny<RequestInit> | NotAny<FetchRequestInit>;
declare type RequestOptions = {
/**
* The HTTP method for the request (e.g., 'get', 'post', 'put', 'delete').
*/
method?: HTTPMethod;
/**
* The URL path for the request.
*
* @example "/v1/foo"
*/
path?: string;
/**
* Query parameters to include in the request URL.
*/
query?: object | undefined | null;
/**
* The request body. Can be a string, JSON object, FormData, or other supported types.
*/
body?: unknown;
/**
* HTTP headers to include with the request. Can be a Headers object, plain object, or array of tuples.
*/
headers?: HeadersLike;
/**
* The maximum number of times that the client will retry a request in case of a
* temporary failure, like a network error or a 5XX error from the server.
*
* @default 2
*/
maxRetries?: number;
stream?: boolean | undefined;
/**
* The maximum amount of time (in milliseconds) that the client should wait for a response
* from the server before timing out a single request.
*
* @unit milliseconds
*/
timeout?: number;
/**
* Additional `RequestInit` options to be passed to the underlying `fetch` call.
* These options will be merged with the client's default fetch options.
*/
fetchOptions?: MergedRequestInit;
/**
* An AbortSignal that can be used to cancel the request.
*/
signal?: AbortSignal | undefined | null;
/**
* A unique key for this request to enable idempotency.
*/
idempotencyKey?: string;
/**
* Override the default base URL for this specific request.
*/
defaultBaseURL?: string | undefined;
__binaryResponse?: boolean | undefined;
__streamClass?: typeof Stream;
};
/**
* Intended to match DOM Response, node-fetch Response, undici Response, etc.
*/
declare interface ResponseLike {
url: string;
blob(): Promise<BlobLike>;
}
/**
* Output for the Search API.
*/
declare interface SearchResult {
/**
* A list of WebSearchResult objects, ordered by decreasing relevance.
*/
results: Array<SearchResult.Result>;
/**
* Search ID. Example: `search_cad0a6d2-dec0-46bd-95ae-900527d880e7`
*/
search_id: string;
}
declare namespace SearchResult {
/**
* A single search result from the web search API.
*/
interface Result {
/**
* Text excerpts from the search result which are relevant to the request.
*/
excerpts: Array<string>;
/**
* Title of the search result.
*/
title: string;
/**
* URL associated with the search result.
*/
url: string;
}
}
declare class Stream<Item> implements AsyncIterable<Item> {
#private;
private iterator;
controller: AbortController;
constructor(iterator: () => AsyncIterator<Item>, controller: AbortController, client?: Parallel);
static fromSSEResponse<Item>(response: Response, controller: AbortController, client?: Parallel): Stream<Item>;
/**
* Generates a Stream from a newline-separated ReadableStream
* where each item is a JSON value.
*/
static fromReadableStream<Item>(readableStream: _ReadableStream_2, controller: AbortController, client?: Parallel): Stream<Item>;
[Symbol.asyncIterator](): AsyncIterator<Item>;
/**
* Splits the stream into two streams which can be
* independently read from at different speeds.
*/
tee(): [Stream<Item>, Stream<Item>];
/**
* Converts this stream to a newline-separated ReadableStream of
* JSON stringified values in the stream
* which can be turned back into a Stream with `Stream.fromReadableStream()`.
*/
toReadableStream(): _ReadableStream_2;
}
declare class TaskGroup extends APIResource {
/**
* Initiates a TaskGroup to group and track multiple runs.
*/
create(body: TaskGroupCreateParams, options?: RequestOptions): APIPromise<TaskGroup>;
/**
* Retrieves aggregated status across runs in a TaskGroup.
*/
retrieve(taskGroupID: string, options?: RequestOptions): APIPromise<TaskGroup>;
/**
* Initiates multiple task runs within a TaskGroup.
*/
addRuns(taskGroupID: string, params: TaskGroupAddRunsParams, options?: RequestOptions): APIPromise<TaskGroupRun>;
/**
* Streams events from a TaskGroup: status updates and run completions.
*
* The connection will remain open for up to 10 minutes as long as at least one run
* in the TaskGroup is active.
*/
events(taskGroupID: string, query?: TaskGroupEventsParams | undefined, options?: RequestOptions): APIPromise<Stream<TaskGroupEventsResponse>>;
/**
* Retrieves task runs in a TaskGroup and optionally their inputs and outputs.
*/
retrieveRuns(taskGroupID: string, query?: TaskGroupRetrieveRunsParams | undefined, options?: RequestOptions): APIPromise<Stream<TaskGroupRetrieveRunsResponse>>;
}
/**
* Response object for a task group, including its status and metadata.
*/
declare interface TaskGroup {
/**
* Timestamp of the creation of the group, as an RFC 3339 string.
*/
created_at: string | null;
/**
* Status of a task group.
*/
status: TaskGroup.Status;
/**
* ID of the group.
*/
taskgroup_id: string;
/**
* User-provided metadata stored with the group.
*/
metadata?: {
[key: string]: string | number | boolean;
} | null;
}
declare namespace TaskGroup {
/**
* Status of a task group.
*/
interface Status {
/**
* True if at least one run in the group is currently active, i.e. status is one of
* {'cancelling', 'queued', 'running'}.
*/
is_active: boolean;
/**
* Timestamp of the last status update to the group, as an RFC 3339 string.
*/
modified_at: string | null;
/**
* Number of task runs in the group.
*/
num_task_runs: number;
/**
* Human-readable status message for the group.
*/
status_message: string | null;
/**
* Number of task runs with each status.
*/
task_run_status_counts: {
[key: string]: number;
};
}
}
declare namespace TaskGroup {
{ declare type TaskGroup as TaskGroup, declare type TaskGroupRun as TaskGroupRun, declare type TaskGroupEventsResponse as TaskGroupEventsResponse, declare type TaskGroupRetrieveRunsResponse as TaskGroupRetrieveRunsResponse, declare type TaskGroupCreateParams as TaskGroupCreateParams, declare type TaskGroupAddRunsParams as TaskGroupAddRunsParams, declare type TaskGroupEventsParams as TaskGroupEventsParams, declare type TaskGroupRetrieveRunsParams as TaskGroupRetrieveRunsParams, };
}
declare interface TaskGroupAddRunsParams {
/**
* Body param: List of task runs to execute.
*/
inputs: Array<TaskGroupAddRunsParams.Input>;
/**
* Query param:
*/
parallel_beta?: string | null;
/**
* Body param: Specification for a task.
*
* Auto output schemas can be specified by setting `output_schema={"type":"auto"}`.
* Not specifying a TaskSpec is the same as setting an auto output schema.
*
* For convenience bare strings are also accepted as input or output schemas.
*/
default_task_spec?: TaskRunAPI.TaskSpec | null;
}
declare namespace TaskGroupAddRunsParams {
/**
* Task run input with additional beta fields.
*/
interface Input {
/**
* Input to the task, either text or a JSON object.
*/
input: string | unknown;
/**
* Processor to use for the task.
*/
processor: string;
/**
* Controls tracking of task run execution progress. When set to true, progress
* events are recorded and can be accessed via the
* [Task Run events](https://platform.parallel.ai/api-reference) endpoint. When
* false, no progress events are tracked. Note that progress tracking cannot be
* enabled after a run has been created. The flag is set to true by default for
* premium processors (pro and above). This feature is not available via the Python
* SDK. To enable this feature in your API requests, specify the `parallel-beta`
* header with `events-sse-2025-07-24` value.
*/
enable_events?: boolean | null;
/**
* Optional list of MCP servers to use for the run. This feature is not available
* via the Python SDK. To enable this feature in your API requests, specify the
* `parallel-beta` header with `mcp-server-2025-07-17` value.
*/
mcp_servers?: Array<Input.McpServer> | null;
/**
* User-provided metadata stored with the run. Keys and values must be strings with
* a maximum length of 16 and 512 characters respectively.
*/
metadata?: {
[key: string]: string | number | boolean;
} | null;
/**
* Source policy for web search results.
*
* This policy governs which sources are allowed/disallowed in results.
*/
source_policy?: Input.SourcePolicy | null;
/**
* Specification for a task.