exa-js 1.5.13 → 1.7.0

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,1871 @@
1
+ /**
2
+ * Base client for Websets API
3
+ */
4
+
5
+ /**
6
+ * Type for API query parameters
7
+ */
8
+ type QueryParams = Record<string, string | number | boolean | string[] | undefined>;
9
+ /**
10
+ * Type for API request body
11
+ */
12
+ interface RequestBody {
13
+ [key: string]: unknown;
14
+ }
15
+ /**
16
+ * Common pagination parameters
17
+ */
18
+ interface PaginationParams {
19
+ /**
20
+ * Cursor for pagination
21
+ */
22
+ cursor?: string;
23
+ /**
24
+ * Maximum number of items per page
25
+ */
26
+ limit?: number;
27
+ }
28
+ /**
29
+ * Base client class for all Websets-related API clients
30
+ */
31
+ declare class WebsetsBaseClient {
32
+ protected client: Exa;
33
+ /**
34
+ * Initialize a new Websets base client
35
+ * @param client The Exa client instance
36
+ */
37
+ constructor(client: Exa);
38
+ /**
39
+ * Make a request to the Websets API
40
+ * @param endpoint The endpoint path
41
+ * @param method The HTTP method
42
+ * @param data Optional request body data
43
+ * @param params Optional query parameters
44
+ * @returns The response JSON
45
+ * @throws ExaError with API error details if the request fails
46
+ */
47
+ protected request<T = unknown>(endpoint: string, method?: string, data?: RequestBody, params?: QueryParams): Promise<T>;
48
+ /**
49
+ * Helper to build pagination parameters
50
+ * @param pagination The pagination parameters
51
+ * @returns QueryParams object with pagination parameters
52
+ */
53
+ protected buildPaginationParams(pagination?: PaginationParams): QueryParams;
54
+ }
55
+
56
+ interface components {
57
+ schemas: {
58
+ CreateCriterionParameters: {
59
+ /** @description The description of the criterion */
60
+ description: string;
61
+ };
62
+ CreateEnrichmentParameters: {
63
+ /** @description Provide a description of the enrichment task you want to perform to each Webset Item. */
64
+ description: string;
65
+ /**
66
+ * @description Format of the enrichment response.
67
+ *
68
+ * We automatically select the best format based on the description. If you want to explicitly specify the format, you can do so here.
69
+ * @enum {string}
70
+ */
71
+ format?: CreateEnrichmentParametersFormat;
72
+ /** @description Set of key-value pairs you want to associate with this object. */
73
+ metadata?: {
74
+ [key: string]: string;
75
+ };
76
+ /** @description When the format is options, the different options for the enrichment agent to choose from. */
77
+ options?: {
78
+ /** @description The label of the option */
79
+ label: string;
80
+ }[];
81
+ };
82
+ CreateWebhookParameters: {
83
+ /** @description The events to trigger the webhook */
84
+ events: components["schemas"]["EventType"][];
85
+ /** @description Set of key-value pairs you want to associate with this object. */
86
+ metadata?: {
87
+ [key: string]: string;
88
+ };
89
+ /**
90
+ * Format: uri
91
+ * @description The URL to send the webhook to
92
+ */
93
+ url: string;
94
+ };
95
+ CreateWebsetParameters: {
96
+ /** @description Add Enrichments for the Webset. */
97
+ enrichments?: components["schemas"]["CreateEnrichmentParameters"][];
98
+ /** @description The external identifier for the webset.
99
+ *
100
+ * You can use this to reference the Webset by your own internal identifiers. */
101
+ externalId?: string;
102
+ /** @description Set of key-value pairs you want to associate with this object. */
103
+ metadata?: {
104
+ [key: string]: string;
105
+ };
106
+ /** @description Create initial search for the Webset. */
107
+ search: {
108
+ /**
109
+ * @description Number of Items the Webset will attempt to find.
110
+ *
111
+ * The actual number of Items found may be less than this number depending on the search complexity.
112
+ * @default 10
113
+ */
114
+ count: number;
115
+ /** @description Criteria every item is evaluated against.
116
+ *
117
+ * It's not required to provide your own criteria, we automatically detect the criteria from all the information provided in the query. Only use this when you need more fine control. */
118
+ criteria?: components["schemas"]["CreateCriterionParameters"][];
119
+ /** @description Entity the Webset will return results for.
120
+ *
121
+ * It is not required to provide it, we automatically detect the entity from all the information provided in the query. Only use this when you need more fine control. */
122
+ entity?: components["schemas"]["WebsetEntity"];
123
+ /** @description Your search query.
124
+ *
125
+ * Use this to describe what you are looking for.
126
+ *
127
+ * Any URL provided will be crawled and used as context for the search. */
128
+ query: string;
129
+ };
130
+ };
131
+ CreateWebsetSearchParameters: {
132
+ /**
133
+ * WebsetSearchBehaviour
134
+ * @description The behaviour of the Search when it is added to a Webset.
135
+ *
136
+ * - `override`: the search will reuse the existing Items found in the Webset and evaluate them against the new criteria. Any Items that don't match the new criteria will be discarded.
137
+ * @default override
138
+ * @enum {string}
139
+ */
140
+ behaviour: CreateWebsetSearchParametersBehaviour;
141
+ /** @description Number of Items the Search will attempt to find.
142
+ *
143
+ * The actual number of Items found may be less than this number depending on the query complexity. */
144
+ count: number;
145
+ /** @description Criteria every item is evaluated against.
146
+ *
147
+ * It's not required to provide your own criteria, we automatically detect the criteria from all the information provided in the query. */
148
+ criteria?: components["schemas"]["CreateCriterionParameters"][];
149
+ /** @description Entity the Webset will return results for.
150
+ *
151
+ * It is not required to provide it, we automatically detect the entity from all the information provided in the query. */
152
+ entity?: components["schemas"]["WebsetEntity"];
153
+ /** @description Set of key-value pairs you want to associate with this object. */
154
+ metadata?: {
155
+ [key: string]: string;
156
+ };
157
+ /** @description Query describing what you are looking for.
158
+ *
159
+ * Any URL provided will be crawled and used as context for the search. */
160
+ query: string;
161
+ };
162
+ EnrichmentResult: {
163
+ /** @description The id of the Enrichment that generated the result */
164
+ enrichmentId: string;
165
+ format: components["schemas"]["WebsetEnrichmentFormat"];
166
+ /**
167
+ * @default enrichment_result
168
+ * @constant
169
+ */
170
+ object: "enrichment_result";
171
+ /** @description The reasoning for the result when an Agent is used. */
172
+ reasoning: string | null;
173
+ /** @description The references used to generate the result. */
174
+ references: {
175
+ /** @description The relevant snippet of the reference content */
176
+ snippet: string | null;
177
+ /** @description The title of the reference */
178
+ title: string | null;
179
+ /** @description The URL of the reference */
180
+ url: string;
181
+ }[];
182
+ /** @description The result of the enrichment. */
183
+ result: string[] | null;
184
+ };
185
+ /** Event */
186
+ Event: {
187
+ /**
188
+ * Format: date-time
189
+ * @description The date and time the event was created
190
+ */
191
+ createdAt: string;
192
+ data: components["schemas"]["Webset"];
193
+ /** @description The unique identifier for the event */
194
+ id: string;
195
+ /**
196
+ * @default event
197
+ * @constant
198
+ */
199
+ object: "event";
200
+ /**
201
+ * @default webset.created
202
+ * @constant
203
+ */
204
+ type: "webset.created";
205
+ } | {
206
+ /**
207
+ * Format: date-time
208
+ * @description The date and time the event was created
209
+ */
210
+ createdAt: string;
211
+ data: components["schemas"]["Webset"];
212
+ /** @description The unique identifier for the event */
213
+ id: string;
214
+ /**
215
+ * @default event
216
+ * @constant
217
+ */
218
+ object: "event";
219
+ /**
220
+ * @default webset.deleted
221
+ * @constant
222
+ */
223
+ type: "webset.deleted";
224
+ } | {
225
+ /**
226
+ * Format: date-time
227
+ * @description The date and time the event was created
228
+ */
229
+ createdAt: string;
230
+ data: components["schemas"]["Webset"];
231
+ /** @description The unique identifier for the event */
232
+ id: string;
233
+ /**
234
+ * @default event
235
+ * @constant
236
+ */
237
+ object: "event";
238
+ /**
239
+ * @default webset.idle
240
+ * @constant
241
+ */
242
+ type: "webset.idle";
243
+ } | {
244
+ /**
245
+ * Format: date-time
246
+ * @description The date and time the event was created
247
+ */
248
+ createdAt: string;
249
+ data: components["schemas"]["Webset"];
250
+ /** @description The unique identifier for the event */
251
+ id: string;
252
+ /**
253
+ * @default event
254
+ * @constant
255
+ */
256
+ object: "event";
257
+ /**
258
+ * @default webset.paused
259
+ * @constant
260
+ */
261
+ type: "webset.paused";
262
+ } | {
263
+ /**
264
+ * Format: date-time
265
+ * @description The date and time the event was created
266
+ */
267
+ createdAt: string;
268
+ data: components["schemas"]["WebsetItem"];
269
+ /** @description The unique identifier for the event */
270
+ id: string;
271
+ /**
272
+ * @default event
273
+ * @constant
274
+ */
275
+ object: "event";
276
+ /**
277
+ * @default webset.item.created
278
+ * @constant
279
+ */
280
+ type: "webset.item.created";
281
+ } | {
282
+ /**
283
+ * Format: date-time
284
+ * @description The date and time the event was created
285
+ */
286
+ createdAt: string;
287
+ data: components["schemas"]["WebsetItem"];
288
+ /** @description The unique identifier for the event */
289
+ id: string;
290
+ /**
291
+ * @default event
292
+ * @constant
293
+ */
294
+ object: "event";
295
+ /**
296
+ * @default webset.item.enriched
297
+ * @constant
298
+ */
299
+ type: "webset.item.enriched";
300
+ } | {
301
+ /**
302
+ * Format: date-time
303
+ * @description The date and time the event was created
304
+ */
305
+ createdAt: string;
306
+ data: components["schemas"]["WebsetSearch"];
307
+ /** @description The unique identifier for the event */
308
+ id: string;
309
+ /**
310
+ * @default event
311
+ * @constant
312
+ */
313
+ object: "event";
314
+ /**
315
+ * @default webset.search.created
316
+ * @constant
317
+ */
318
+ type: "webset.search.created";
319
+ } | {
320
+ /**
321
+ * Format: date-time
322
+ * @description The date and time the event was created
323
+ */
324
+ createdAt: string;
325
+ data: components["schemas"]["WebsetSearch"];
326
+ /** @description The unique identifier for the event */
327
+ id: string;
328
+ /**
329
+ * @default event
330
+ * @constant
331
+ */
332
+ object: "event";
333
+ /**
334
+ * @default webset.search.updated
335
+ * @constant
336
+ */
337
+ type: "webset.search.updated";
338
+ } | {
339
+ /**
340
+ * Format: date-time
341
+ * @description The date and time the event was created
342
+ */
343
+ createdAt: string;
344
+ data: components["schemas"]["WebsetSearch"];
345
+ /** @description The unique identifier for the event */
346
+ id: string;
347
+ /**
348
+ * @default event
349
+ * @constant
350
+ */
351
+ object: "event";
352
+ /**
353
+ * @default webset.search.canceled
354
+ * @constant
355
+ */
356
+ type: "webset.search.canceled";
357
+ } | {
358
+ /**
359
+ * Format: date-time
360
+ * @description The date and time the event was created
361
+ */
362
+ createdAt: string;
363
+ data: components["schemas"]["WebsetSearch"];
364
+ /** @description The unique identifier for the event */
365
+ id: string;
366
+ /**
367
+ * @default event
368
+ * @constant
369
+ */
370
+ object: "event";
371
+ /**
372
+ * @default webset.search.completed
373
+ * @constant
374
+ */
375
+ type: "webset.search.completed";
376
+ };
377
+ /** @enum {string} */
378
+ EventType: EventType;
379
+ GetWebsetResponse: components["schemas"]["Webset"] & {
380
+ /** @description When expand query parameter contains `items`, this will contain the items in the webset */
381
+ items?: components["schemas"]["WebsetItem"][];
382
+ };
383
+ ListEventsResponse: {
384
+ /** @description The list of events */
385
+ data: components["schemas"]["Event"][];
386
+ /** @description Whether there are more results to paginate through */
387
+ hasMore: boolean;
388
+ /** @description The cursor to paginate through the next set of results */
389
+ nextCursor: string | null;
390
+ };
391
+ ListWebhookAttemptsResponse: {
392
+ /** @description The list of webhook attempts */
393
+ data: components["schemas"]["WebhookAttempt"][];
394
+ /** @description Whether there are more results to paginate through */
395
+ hasMore: boolean;
396
+ /** @description The cursor to paginate through the next set of results */
397
+ nextCursor: string | null;
398
+ };
399
+ ListWebhooksResponse: {
400
+ /** @description The list of webhooks */
401
+ data: components["schemas"]["Webhook"][];
402
+ /** @description Whether there are more results to paginate through */
403
+ hasMore: boolean;
404
+ /** @description The cursor to paginate through the next set of results */
405
+ nextCursor: string | null;
406
+ };
407
+ ListWebsetItemResponse: {
408
+ /** @description The list of webset items */
409
+ data: components["schemas"]["WebsetItem"][];
410
+ /** @description Whether there are more Items to paginate through */
411
+ hasMore: boolean;
412
+ /** @description The cursor to paginate through the next set of Items */
413
+ nextCursor: string | null;
414
+ };
415
+ ListWebsetsResponse: {
416
+ /** @description The list of websets */
417
+ data: components["schemas"]["Webset"][];
418
+ /** @description Whether there are more results to paginate through */
419
+ hasMore: boolean;
420
+ /** @description The cursor to paginate through the next set of results */
421
+ nextCursor: string | null;
422
+ };
423
+ UpdateWebhookParameters: {
424
+ /** @description The events to trigger the webhook */
425
+ events?: components["schemas"]["EventType"][];
426
+ /** @description Set of key-value pairs you want to associate with this object. */
427
+ metadata?: {
428
+ [key: string]: string;
429
+ };
430
+ /**
431
+ * Format: uri
432
+ * @description The URL to send the webhook to
433
+ */
434
+ url?: string;
435
+ };
436
+ UpdateWebsetRequest: {
437
+ /** @description Set of key-value pairs you want to associate with this object. */
438
+ metadata?: {
439
+ [key: string]: string;
440
+ } | null;
441
+ };
442
+ Webhook: {
443
+ /**
444
+ * Format: date-time
445
+ * @description The date and time the webhook was created
446
+ */
447
+ createdAt: string;
448
+ /** @description The events to trigger the webhook */
449
+ events: components["schemas"]["EventType"][];
450
+ /** @description The unique identifier for the webhook */
451
+ id: string;
452
+ /**
453
+ * @description The metadata of the webhook
454
+ * @default {}
455
+ */
456
+ metadata: {
457
+ [key: string]: string;
458
+ };
459
+ /**
460
+ * @default webhook
461
+ * @constant
462
+ */
463
+ object: "webhook";
464
+ /** @description The secret to verify the webhook signature. Only returned on Webhook creation. */
465
+ secret: string | null;
466
+ /**
467
+ * WebhookStatus
468
+ * @description The status of the webhook
469
+ * @enum {string}
470
+ */
471
+ status: WebhookStatus;
472
+ /**
473
+ * Format: date-time
474
+ * @description The date and time the webhook was last updated
475
+ */
476
+ updatedAt: string;
477
+ /**
478
+ * Format: uri
479
+ * @description The URL to send the webhook to
480
+ */
481
+ url: string;
482
+ };
483
+ WebhookAttempt: {
484
+ /** @description The attempt number of the webhook */
485
+ attempt: number;
486
+ /**
487
+ * Format: date-time
488
+ * @description The date and time the webhook attempt was made
489
+ */
490
+ attemptedAt: string;
491
+ /** @description The unique identifier for the event */
492
+ eventId: string;
493
+ /**
494
+ * @description The type of event
495
+ * @enum {string}
496
+ */
497
+ eventType: EventType;
498
+ /** @description The unique identifier for the webhook attempt */
499
+ id: string;
500
+ /**
501
+ * @default webhook_attempt
502
+ * @constant
503
+ */
504
+ object: "webhook_attempt";
505
+ /** @description The body of the response */
506
+ responseBody: string | null;
507
+ /** @description The headers of the response */
508
+ responseHeaders: {
509
+ [key: string]: string;
510
+ };
511
+ /** @description The status code of the response */
512
+ responseStatusCode: number;
513
+ /** @description Whether the attempt was successful */
514
+ successful: boolean;
515
+ /** @description The URL that was used during the attempt */
516
+ url: string;
517
+ /** @description The unique identifier for the webhook */
518
+ webhookId: string;
519
+ };
520
+ Webset: {
521
+ /**
522
+ * Format: date-time
523
+ * @description The date and time the webset was created
524
+ */
525
+ createdAt: string;
526
+ /** @description The Enrichments to apply to the Webset Items. */
527
+ enrichments: components["schemas"]["WebsetEnrichment"][];
528
+ /** @description The external identifier for the webset */
529
+ externalId: string | null;
530
+ /** @description The unique identifier for the webset */
531
+ id: string;
532
+ /**
533
+ * @description Set of key-value pairs you want to associate with this object.
534
+ * @default {}
535
+ */
536
+ metadata: {
537
+ [key: string]: string;
538
+ };
539
+ /**
540
+ * @default webset
541
+ * @constant
542
+ */
543
+ object: "webset";
544
+ /** @description The searches that have been performed on the webset. */
545
+ searches: components["schemas"]["WebsetSearch"][];
546
+ /**
547
+ * WebsetStatus
548
+ * @description The status of the webset
549
+ * @enum {string}
550
+ */
551
+ status: WebsetStatus;
552
+ /**
553
+ * Format: date-time
554
+ * @description The date and time the webset was updated
555
+ */
556
+ updatedAt: string;
557
+ };
558
+ WebsetArticleEntity: {
559
+ /**
560
+ * @default article
561
+ * @constant
562
+ */
563
+ type: "article";
564
+ };
565
+ WebsetCompanyEntity: {
566
+ /**
567
+ * @default company
568
+ * @constant
569
+ */
570
+ type: "company";
571
+ };
572
+ WebsetCustomEntity: {
573
+ /** @description When you decide to use a custom entity, this is the description of the entity.
574
+ *
575
+ * The entity represents what type of results the Webset will return. For example, if you want results to be Job Postings, you might use "Job Postings" as the entity description. */
576
+ description: string;
577
+ /**
578
+ * @default custom
579
+ * @constant
580
+ */
581
+ type: "custom";
582
+ };
583
+ WebsetEnrichment: {
584
+ /**
585
+ * Format: date-time
586
+ * @description The date and time the enrichment was created
587
+ */
588
+ createdAt: string;
589
+ /** @description The description of the enrichment task provided during the creation of the enrichment. */
590
+ description: string;
591
+ /** @description The format of the enrichment response. */
592
+ format: components["schemas"]["WebsetEnrichmentFormat"];
593
+ /** @description The unique identifier for the enrichment */
594
+ id: string;
595
+ /** @description The instructions for the enrichment Agent.
596
+ *
597
+ * This will be automatically generated based on the description and format. */
598
+ instructions: string | null;
599
+ /**
600
+ * @description The metadata of the enrichment
601
+ * @default {}
602
+ */
603
+ metadata: {
604
+ [key: string]: string;
605
+ };
606
+ /**
607
+ * @default webset_enrichment
608
+ * @constant
609
+ */
610
+ object: "webset_enrichment";
611
+ /**
612
+ * WebsetEnrichmentOptions
613
+ * @description When the format is options, the different options for the enrichment agent to choose from.
614
+ */
615
+ options: {
616
+ /** @description The label of the option */
617
+ label: string;
618
+ }[] | null;
619
+ /**
620
+ * WebsetEnrichmentStatus
621
+ * @description The status of the enrichment
622
+ * @enum {string}
623
+ */
624
+ status: WebsetEnrichmentStatus;
625
+ /** @description The title of the enrichment.
626
+ *
627
+ * This will be automatically generated based on the description and format. */
628
+ title: string | null;
629
+ /**
630
+ * Format: date-time
631
+ * @description The date and time the enrichment was updated
632
+ */
633
+ updatedAt: string;
634
+ /** @description The unique identifier for the Webset this enrichment belongs to. */
635
+ websetId: string;
636
+ };
637
+ /** @enum {string} */
638
+ WebsetEnrichmentFormat: WebsetEnrichmentFormat;
639
+ WebsetEntity: components["schemas"]["WebsetCompanyEntity"] | components["schemas"]["WebsetPersonEntity"] | components["schemas"]["WebsetArticleEntity"] | components["schemas"]["WebsetResearchPaperEntity"] | components["schemas"]["WebsetCustomEntity"];
640
+ WebsetItem: {
641
+ /**
642
+ * Format: date-time
643
+ * @description The date and time the item was created
644
+ */
645
+ createdAt: string;
646
+ /** @description The enrichments results of the Webset item */
647
+ enrichments: components["schemas"]["EnrichmentResult"][] | null;
648
+ /** @description The criteria evaluations of the item */
649
+ evaluations: components["schemas"]["WebsetItemEvaluation"][];
650
+ /** @description The unique identifier for the Webset Item */
651
+ id: string;
652
+ /**
653
+ * @default webset_item
654
+ * @constant
655
+ */
656
+ object: "webset_item";
657
+ /** @description The properties of the Item */
658
+ properties: components["schemas"]["WebsetItemPersonProperties"] | components["schemas"]["WebsetItemCompanyProperties"] | components["schemas"]["WebsetItemArticleProperties"] | components["schemas"]["WebsetItemResearchPaperProperties"] | components["schemas"]["WebsetItemCustomProperties"];
659
+ /**
660
+ * @description The source of the Item
661
+ * @enum {string}
662
+ */
663
+ source: WebsetItemSource;
664
+ /** @description The unique identifier for the source */
665
+ sourceId: string;
666
+ /**
667
+ * Format: date-time
668
+ * @description The date and time the item was last updated
669
+ */
670
+ updatedAt: string;
671
+ /** @description The unique identifier for the Webset this Item belongs to. */
672
+ websetId: string;
673
+ };
674
+ WebsetItemArticleProperties: {
675
+ /** WebsetItemArticlePropertiesFields */
676
+ article: {
677
+ /** @description The author(s) of the article */
678
+ author: string | null;
679
+ /** @description The date and time the article was published */
680
+ publishedAt: string | null;
681
+ };
682
+ /** @description The text content for the article */
683
+ content: string | null;
684
+ /** @description Short description of the relevance of the article */
685
+ description: string;
686
+ /**
687
+ * @default article
688
+ * @constant
689
+ */
690
+ type: "article";
691
+ /**
692
+ * Format: uri
693
+ * @description The URL of the article
694
+ */
695
+ url: string;
696
+ };
697
+ WebsetItemCompanyProperties: {
698
+ /** WebsetItemCompanyPropertiesFields */
699
+ company: {
700
+ /** @description A short description of the company */
701
+ about: string | null;
702
+ /** @description The number of employees of the company */
703
+ employees: number | null;
704
+ /** @description The industry of the company */
705
+ industry: string | null;
706
+ /** @description The main location of the company */
707
+ location: string | null;
708
+ /**
709
+ * Format: uri
710
+ * @description The logo URL of the company
711
+ */
712
+ logoUrl: string | null;
713
+ /** @description The name of the company */
714
+ name: string;
715
+ };
716
+ /** @description The text content of the company website */
717
+ content: string | null;
718
+ /** @description Short description of the relevance of the company */
719
+ description: string;
720
+ /**
721
+ * @default company
722
+ * @constant
723
+ */
724
+ type: "company";
725
+ /**
726
+ * Format: uri
727
+ * @description The URL of the company website
728
+ */
729
+ url: string;
730
+ };
731
+ WebsetItemCustomProperties: {
732
+ /** @description The text content of the Item */
733
+ content: string | null;
734
+ /** WebsetItemCustomPropertiesFields */
735
+ custom: {
736
+ /** @description The author(s) of the website */
737
+ author: string | null;
738
+ /** @description The date and time the website was published */
739
+ publishedAt: string | null;
740
+ };
741
+ /** @description Short description of the Item */
742
+ description: string;
743
+ /**
744
+ * @default custom
745
+ * @constant
746
+ */
747
+ type: "custom";
748
+ /**
749
+ * Format: uri
750
+ * @description The URL of the Item
751
+ */
752
+ url: string;
753
+ };
754
+ WebsetItemEvaluation: {
755
+ /** @description The description of the criterion */
756
+ criterion: string;
757
+ /** @description The reasoning for the result of the evaluation */
758
+ reasoning: string;
759
+ /**
760
+ * @description The references used to generate the result.
761
+ * @default []
762
+ */
763
+ references: {
764
+ /** @description The relevant snippet of the reference content */
765
+ snippet: string | null;
766
+ /** @description The title of the reference */
767
+ title: string | null;
768
+ /** @description The URL of the reference */
769
+ url: string;
770
+ }[];
771
+ /**
772
+ * @description The satisfaction of the criterion
773
+ * @enum {string}
774
+ */
775
+ satisfied: WebsetItemEvaluationSatisfied;
776
+ };
777
+ WebsetItemPersonProperties: {
778
+ /** @description Short description of the relevance of the person */
779
+ description: string;
780
+ /** WebsetItemPersonPropertiesFields */
781
+ person: {
782
+ /** @description The location of the person */
783
+ location: string | null;
784
+ /** @description The name of the person */
785
+ name: string;
786
+ /**
787
+ * Format: uri
788
+ * @description The image URL of the person
789
+ */
790
+ pictureUrl: string | null;
791
+ /** @description The current work position of the person */
792
+ position: string | null;
793
+ };
794
+ /**
795
+ * @default person
796
+ * @constant
797
+ */
798
+ type: "person";
799
+ /**
800
+ * Format: uri
801
+ * @description The URL of the person profile
802
+ */
803
+ url: string;
804
+ };
805
+ WebsetItemResearchPaperProperties: {
806
+ /** @description The text content of the research paper */
807
+ content: string | null;
808
+ /** @description Short description of the relevance of the research paper */
809
+ description: string;
810
+ /** WebsetItemResearchPaperPropertiesFields */
811
+ researchPaper: {
812
+ /** @description The author(s) of the research paper */
813
+ author: string | null;
814
+ /** @description The date and time the research paper was published */
815
+ publishedAt: string | null;
816
+ };
817
+ /**
818
+ * @default research_paper
819
+ * @constant
820
+ */
821
+ type: "research_paper";
822
+ /**
823
+ * Format: uri
824
+ * @description The URL of the research paper
825
+ */
826
+ url: string;
827
+ };
828
+ WebsetPersonEntity: {
829
+ /**
830
+ * @default person
831
+ * @constant
832
+ */
833
+ type: "person";
834
+ };
835
+ WebsetResearchPaperEntity: {
836
+ /**
837
+ * @default research_paper
838
+ * @constant
839
+ */
840
+ type: "research_paper";
841
+ };
842
+ WebsetSearch: {
843
+ /**
844
+ * Format: date-time
845
+ * @description The date and time the search was canceled
846
+ */
847
+ canceledAt: string | null;
848
+ /**
849
+ * @description The reason the search was canceled
850
+ * @enum {string|null}
851
+ */
852
+ canceledReason: WebsetSearchCanceledReason;
853
+ /** @description The number of results the search will attempt to find. The actual number of results may be less than this number depending on the search complexity. */
854
+ count: number;
855
+ /**
856
+ * Format: date-time
857
+ * @description The date and time the search was created
858
+ */
859
+ createdAt: string;
860
+ /** @description The criteria the search will use to evaluate the results. If not provided, we will automatically generate them for you. */
861
+ criteria: {
862
+ /** @description The description of the criterion */
863
+ description: string;
864
+ /** @description Value between 0 and 100 representing the percentage of results that meet the criterion. */
865
+ successRate: number;
866
+ }[];
867
+ /** @description The entity the search will return results for.
868
+ *
869
+ * When no entity is provided during creation, we will automatically select the best entity based on the query. */
870
+ entity: components["schemas"]["WebsetEntity"];
871
+ /** @description The unique identifier for the search */
872
+ id: string;
873
+ /**
874
+ * @description Set of key-value pairs you want to associate with this object.
875
+ * @default {}
876
+ */
877
+ metadata: {
878
+ [key: string]: string;
879
+ };
880
+ /**
881
+ * @default webset_search
882
+ * @constant
883
+ */
884
+ object: "webset_search";
885
+ /** @description The progress of the search */
886
+ progress: {
887
+ /** @description The completion percentage of the search */
888
+ completion: number;
889
+ /** @description The number of results found so far */
890
+ found: number;
891
+ };
892
+ /** @description The query used to create the search. */
893
+ query: string;
894
+ /**
895
+ * WebsetSearchStatus
896
+ * @description The status of the search
897
+ * @enum {string}
898
+ */
899
+ status: WebsetSearchStatus;
900
+ /**
901
+ * Format: date-time
902
+ * @description The date and time the search was updated
903
+ */
904
+ updatedAt: string;
905
+ };
906
+ };
907
+ responses: never;
908
+ parameters: never;
909
+ requestBodies: never;
910
+ headers: never;
911
+ pathItems: never;
912
+ }
913
+ type CreateEnrichmentParameters = components["schemas"]["CreateEnrichmentParameters"];
914
+ type CreateWebhookParameters = components["schemas"]["CreateWebhookParameters"];
915
+ type CreateWebsetParameters = components["schemas"]["CreateWebsetParameters"];
916
+ type CreateWebsetSearchParameters = components["schemas"]["CreateWebsetSearchParameters"];
917
+ type EnrichmentResult = components["schemas"]["EnrichmentResult"];
918
+ type Event = components["schemas"]["Event"];
919
+ type GetWebsetResponse = components["schemas"]["GetWebsetResponse"];
920
+ type ListEventsResponse = components["schemas"]["ListEventsResponse"];
921
+ type ListWebhookAttemptsResponse = components["schemas"]["ListWebhookAttemptsResponse"];
922
+ type ListWebhooksResponse = components["schemas"]["ListWebhooksResponse"];
923
+ type ListWebsetItemResponse = components["schemas"]["ListWebsetItemResponse"];
924
+ type ListWebsetsResponse = components["schemas"]["ListWebsetsResponse"];
925
+ type UpdateWebhookParameters = components["schemas"]["UpdateWebhookParameters"];
926
+ type UpdateWebsetRequest = components["schemas"]["UpdateWebsetRequest"];
927
+ type Webhook = components["schemas"]["Webhook"];
928
+ type WebhookAttempt = components["schemas"]["WebhookAttempt"];
929
+ type Webset = components["schemas"]["Webset"];
930
+ type WebsetEnrichment = components["schemas"]["WebsetEnrichment"];
931
+ type WebsetItem = components["schemas"]["WebsetItem"];
932
+ type WebsetSearch = components["schemas"]["WebsetSearch"];
933
+ declare enum CreateEnrichmentParametersFormat {
934
+ text = "text",
935
+ date = "date",
936
+ number = "number",
937
+ options = "options",
938
+ email = "email",
939
+ phone = "phone"
940
+ }
941
+ declare enum CreateWebsetSearchParametersBehaviour {
942
+ override = "override"
943
+ }
944
+ declare enum EventType {
945
+ webset_created = "webset.created",
946
+ webset_deleted = "webset.deleted",
947
+ webset_paused = "webset.paused",
948
+ webset_idle = "webset.idle",
949
+ webset_search_created = "webset.search.created",
950
+ webset_search_canceled = "webset.search.canceled",
951
+ webset_search_completed = "webset.search.completed",
952
+ webset_search_updated = "webset.search.updated",
953
+ webset_export_created = "webset.export.created",
954
+ webset_export_completed = "webset.export.completed",
955
+ webset_item_created = "webset.item.created",
956
+ webset_item_enriched = "webset.item.enriched"
957
+ }
958
+ declare enum WebhookStatus {
959
+ active = "active",
960
+ inactive = "inactive"
961
+ }
962
+ declare enum WebsetStatus {
963
+ idle = "idle",
964
+ running = "running",
965
+ paused = "paused"
966
+ }
967
+ declare enum WebsetEnrichmentStatus {
968
+ pending = "pending",
969
+ canceled = "canceled",
970
+ completed = "completed"
971
+ }
972
+ declare enum WebsetEnrichmentFormat {
973
+ text = "text",
974
+ date = "date",
975
+ number = "number",
976
+ options = "options",
977
+ email = "email",
978
+ phone = "phone"
979
+ }
980
+ declare enum WebsetItemSource {
981
+ search = "search"
982
+ }
983
+ declare enum WebsetItemEvaluationSatisfied {
984
+ yes = "yes",
985
+ no = "no",
986
+ unclear = "unclear"
987
+ }
988
+ declare enum WebsetSearchCanceledReason {
989
+ webset_deleted = "webset_deleted",
990
+ webset_canceled = "webset_canceled"
991
+ }
992
+ declare enum WebsetSearchStatus {
993
+ created = "created",
994
+ running = "running",
995
+ completed = "completed",
996
+ canceled = "canceled"
997
+ }
998
+
999
+ /**
1000
+ * Client for managing Webset Enrichments
1001
+ */
1002
+
1003
+ /**
1004
+ * Client for managing Webset Enrichments
1005
+ */
1006
+ declare class WebsetEnrichmentsClient extends WebsetsBaseClient {
1007
+ /**
1008
+ * Create an Enrichment for a Webset
1009
+ * @param websetId The ID of the Webset
1010
+ * @param params The enrichment parameters
1011
+ * @returns The created Webset Enrichment
1012
+ */
1013
+ create(websetId: string, params: CreateEnrichmentParameters): Promise<WebsetEnrichment>;
1014
+ /**
1015
+ * Get an Enrichment by ID
1016
+ * @param websetId The ID of the Webset
1017
+ * @param id The ID of the Enrichment
1018
+ * @returns The Webset Enrichment
1019
+ */
1020
+ get(websetId: string, id: string): Promise<WebsetEnrichment>;
1021
+ /**
1022
+ * Delete an Enrichment
1023
+ * @param websetId The ID of the Webset
1024
+ * @param id The ID of the Enrichment
1025
+ * @returns The deleted Webset Enrichment
1026
+ */
1027
+ delete(websetId: string, id: string): Promise<WebsetEnrichment>;
1028
+ /**
1029
+ * Cancel a running Enrichment
1030
+ * @param websetId The ID of the Webset
1031
+ * @param id The ID of the Enrichment
1032
+ * @returns The canceled Webset Enrichment
1033
+ */
1034
+ cancel(websetId: string, id: string): Promise<WebsetEnrichment>;
1035
+ }
1036
+
1037
+ /**
1038
+ * Options for listing Events
1039
+ */
1040
+ interface ListEventsOptions {
1041
+ /**
1042
+ * The cursor to paginate through the results
1043
+ */
1044
+ cursor?: string;
1045
+ /**
1046
+ * The number of results to return
1047
+ */
1048
+ limit?: number;
1049
+ /**
1050
+ * The types of events to filter by
1051
+ */
1052
+ types?: EventType[];
1053
+ }
1054
+ /**
1055
+ * Client for managing Events
1056
+ */
1057
+ declare class EventsClient extends WebsetsBaseClient {
1058
+ /**
1059
+ * Initialize a new Events client
1060
+ * @param client The Exa client instance
1061
+ */
1062
+ constructor(client: Exa);
1063
+ /**
1064
+ * List all Events
1065
+ * @param options Optional filtering and pagination options
1066
+ * @returns The list of Events
1067
+ */
1068
+ list(options?: ListEventsOptions): Promise<ListEventsResponse>;
1069
+ /**
1070
+ * Get an Event by ID
1071
+ * @param id The ID of the Event
1072
+ * @returns The Event
1073
+ */
1074
+ get(id: string): Promise<Event>;
1075
+ }
1076
+
1077
+ /**
1078
+ * Client for managing Webset Items
1079
+ */
1080
+
1081
+ /**
1082
+ * Client for managing Webset Items
1083
+ */
1084
+ declare class WebsetItemsClient extends WebsetsBaseClient {
1085
+ /**
1086
+ * List all Items for a Webset
1087
+ * @param websetId The ID of the Webset
1088
+ * @param params - Optional pagination parameters
1089
+ * @returns A promise that resolves with the list of Items
1090
+ */
1091
+ list(websetId: string, params?: PaginationParams): Promise<ListWebsetItemResponse>;
1092
+ /**
1093
+ * Iterate through all Items in a Webset, handling pagination automatically
1094
+ * @param websetId The ID of the Webset
1095
+ * @param options Pagination options
1096
+ * @returns Async generator of Webset Items
1097
+ */
1098
+ listAll(websetId: string, options?: PaginationParams): AsyncGenerator<WebsetItem>;
1099
+ /**
1100
+ * Collect all items from a Webset into an array
1101
+ * @param websetId The ID of the Webset
1102
+ * @param options Pagination options
1103
+ * @returns Promise resolving to an array of all Webset Items
1104
+ */
1105
+ getAll(websetId: string, options?: PaginationParams): Promise<WebsetItem[]>;
1106
+ /**
1107
+ * Get an Item by ID
1108
+ * @param websetId The ID of the Webset
1109
+ * @param id The ID of the Item
1110
+ * @returns The Webset Item
1111
+ */
1112
+ get(websetId: string, id: string): Promise<WebsetItem>;
1113
+ /**
1114
+ * Delete an Item
1115
+ * @param websetId The ID of the Webset
1116
+ * @param id The ID of the Item
1117
+ * @returns The deleted Webset Item
1118
+ */
1119
+ delete(websetId: string, id: string): Promise<WebsetItem>;
1120
+ }
1121
+
1122
+ /**
1123
+ * Client for managing Webset Searches
1124
+ */
1125
+
1126
+ /**
1127
+ * Client for managing Webset Searches
1128
+ */
1129
+ declare class WebsetSearchesClient extends WebsetsBaseClient {
1130
+ /**
1131
+ * Create a new Search for the Webset
1132
+ * @param websetId The ID of the Webset
1133
+ * @param params The search parameters
1134
+ * @returns The created Webset Search
1135
+ */
1136
+ create(websetId: string, params: CreateWebsetSearchParameters): Promise<WebsetSearch>;
1137
+ /**
1138
+ * Get a Search by ID
1139
+ * @param websetId The ID of the Webset
1140
+ * @param id The ID of the Search
1141
+ * @returns The Webset Search
1142
+ */
1143
+ get(websetId: string, id: string): Promise<WebsetSearch>;
1144
+ /**
1145
+ * Cancel a running Search
1146
+ * @param websetId The ID of the Webset
1147
+ * @param id The ID of the Search
1148
+ * @returns The canceled Webset Search
1149
+ */
1150
+ cancel(websetId: string, id: string): Promise<WebsetSearch>;
1151
+ }
1152
+
1153
+ /**
1154
+ * Client for managing Webset Webhooks
1155
+ */
1156
+
1157
+ /**
1158
+ * Options for listing webhooks (only pagination is supported by API)
1159
+ */
1160
+ interface ListWebhooksOptions extends PaginationParams {
1161
+ }
1162
+ /**
1163
+ * Options for listing webhook attempts
1164
+ */
1165
+ interface ListWebhookAttemptsOptions extends PaginationParams {
1166
+ /**
1167
+ * The type of event to filter by
1168
+ */
1169
+ eventType?: EventType;
1170
+ }
1171
+ /**
1172
+ * Client for managing Webset Webhooks
1173
+ */
1174
+ declare class WebsetWebhooksClient extends WebsetsBaseClient {
1175
+ /**
1176
+ * Create a Webhook
1177
+ * @param params The webhook parameters
1178
+ * @returns The created Webhook
1179
+ */
1180
+ create(params: CreateWebhookParameters): Promise<Webhook>;
1181
+ /**
1182
+ * Get a Webhook by ID
1183
+ * @param id The ID of the Webhook
1184
+ * @returns The Webhook
1185
+ */
1186
+ get(id: string): Promise<Webhook>;
1187
+ /**
1188
+ * List all Webhooks
1189
+ * @param options Pagination options
1190
+ * @returns The list of Webhooks
1191
+ */
1192
+ list(options?: ListWebhooksOptions): Promise<ListWebhooksResponse>;
1193
+ /**
1194
+ * Iterate through all Webhooks, handling pagination automatically
1195
+ * @param options Pagination options
1196
+ * @returns Async generator of Webhooks
1197
+ */
1198
+ listAll(options?: ListWebhooksOptions): AsyncGenerator<Webhook>;
1199
+ /**
1200
+ * Collect all Webhooks into an array
1201
+ * @param options Pagination options
1202
+ * @returns Promise resolving to an array of all Webhooks
1203
+ */
1204
+ getAll(options?: ListWebhooksOptions): Promise<Webhook[]>;
1205
+ /**
1206
+ * Update a Webhook
1207
+ * @param id The ID of the Webhook
1208
+ * @param params The webhook update parameters (events, metadata, url)
1209
+ * @returns The updated Webhook
1210
+ */
1211
+ update(id: string, params: UpdateWebhookParameters): Promise<Webhook>;
1212
+ /**
1213
+ * Delete a Webhook
1214
+ * @param id The ID of the Webhook
1215
+ * @returns The deleted Webhook
1216
+ */
1217
+ delete(id: string): Promise<Webhook>;
1218
+ /**
1219
+ * List all attempts for a Webhook
1220
+ * @param id The ID of the Webhook
1221
+ * @param options Pagination and filtering options
1222
+ * @returns The list of Webhook attempts
1223
+ */
1224
+ listAttempts(id: string, options?: ListWebhookAttemptsOptions): Promise<ListWebhookAttemptsResponse>;
1225
+ /**
1226
+ * Iterate through all attempts for a Webhook, handling pagination automatically
1227
+ * @param id The ID of the Webhook
1228
+ * @param options Pagination and filtering options
1229
+ * @returns Async generator of Webhook attempts
1230
+ */
1231
+ listAllAttempts(id: string, options?: ListWebhookAttemptsOptions): AsyncGenerator<WebhookAttempt>;
1232
+ /**
1233
+ * Collect all attempts for a Webhook into an array
1234
+ * @param id The ID of the Webhook
1235
+ * @param options Pagination and filtering options
1236
+ * @returns Promise resolving to an array of all Webhook attempts
1237
+ */
1238
+ getAllAttempts(id: string, options?: ListWebhookAttemptsOptions): Promise<WebhookAttempt[]>;
1239
+ }
1240
+
1241
+ /**
1242
+ * Main client for Websets API
1243
+ */
1244
+
1245
+ /**
1246
+ * Options for listing Websets (API only supports pagination)
1247
+ */
1248
+ interface ListWebsetsOptions extends PaginationParams {
1249
+ }
1250
+ /**
1251
+ * Client for managing Websets
1252
+ */
1253
+ declare class WebsetsClient extends WebsetsBaseClient {
1254
+ /**
1255
+ * Client for managing Events
1256
+ */
1257
+ events: EventsClient;
1258
+ /**
1259
+ * Client for managing Webset Items
1260
+ */
1261
+ items: WebsetItemsClient;
1262
+ /**
1263
+ * Client for managing Webset Searches
1264
+ */
1265
+ searches: WebsetSearchesClient;
1266
+ /**
1267
+ * Client for managing Webset Enrichments
1268
+ */
1269
+ enrichments: WebsetEnrichmentsClient;
1270
+ /**
1271
+ * Client for managing Webset Webhooks
1272
+ */
1273
+ webhooks: WebsetWebhooksClient;
1274
+ /**
1275
+ * Initialize a new Websets client
1276
+ * @param client The Exa client instance
1277
+ */
1278
+ constructor(client: Exa);
1279
+ /**
1280
+ * Create a new Webset
1281
+ * @param params The Webset creation parameters
1282
+ * @returns The created Webset
1283
+ */
1284
+ create(params: CreateWebsetParameters): Promise<Webset>;
1285
+ /**
1286
+ * Get a Webset by ID
1287
+ * @param id The ID of the Webset
1288
+ * @param expand Optional array of relations to expand
1289
+ * @returns The Webset
1290
+ */
1291
+ get(id: string, expand?: Array<"items">): Promise<GetWebsetResponse>;
1292
+ /**
1293
+ * List all Websets
1294
+ * @param options Pagination options (filtering by status is not supported by API)
1295
+ * @returns The list of Websets
1296
+ */
1297
+ list(options?: ListWebsetsOptions): Promise<ListWebsetsResponse>;
1298
+ /**
1299
+ * Iterate through all Websets, handling pagination automatically
1300
+ * @param options Pagination options
1301
+ * @returns Async generator of Websets
1302
+ */
1303
+ listAll(options?: ListWebsetsOptions): AsyncGenerator<Webset>;
1304
+ /**
1305
+ * Collect all Websets into an array
1306
+ * @param options Pagination options
1307
+ * @returns Promise resolving to an array of all Websets
1308
+ */
1309
+ getAll(options?: ListWebsetsOptions): Promise<Webset[]>;
1310
+ /**
1311
+ * Update a Webset
1312
+ * @param id The ID of the Webset
1313
+ * @param params The Webset update parameters
1314
+ * @returns The updated Webset
1315
+ */
1316
+ update(id: string, params: UpdateWebsetRequest): Promise<Webset>;
1317
+ /**
1318
+ * Delete a Webset
1319
+ * @param id The ID of the Webset
1320
+ * @returns The deleted Webset
1321
+ */
1322
+ delete(id: string): Promise<Webset>;
1323
+ /**
1324
+ * Cancel a running Webset
1325
+ * @param id The ID or external ID of the Webset
1326
+ * @returns The canceled Webset (as returned by the API)
1327
+ */
1328
+ cancel(id: string): Promise<Webset>;
1329
+ /**
1330
+ * Wait until a Webset is idle
1331
+ * @param id The ID of the Webset
1332
+ * @param options Configuration options for timeout and polling
1333
+ * @returns The Webset once it becomes idle
1334
+ * @throws Error if the Webset does not become idle within the timeout
1335
+ */
1336
+ waitUntilIdle(id: string, options?: {
1337
+ timeout?: number;
1338
+ pollInterval?: number;
1339
+ onPoll?: (status: WebsetStatus) => void;
1340
+ } | number): Promise<Webset>;
1341
+ }
1342
+
1343
+ /**
1344
+ * HTTP status codes
1345
+ */
1346
+ declare enum HttpStatusCode {
1347
+ BadRequest = 400,
1348
+ NotFound = 404,
1349
+ Unauthorized = 401,
1350
+ Forbidden = 403,
1351
+ TooManyRequests = 429,
1352
+ RequestTimeout = 408,
1353
+ InternalServerError = 500,
1354
+ ServiceUnavailable = 503
1355
+ }
1356
+ /**
1357
+ * Base error class for all Exa API errors
1358
+ */
1359
+ declare class ExaError extends Error {
1360
+ /**
1361
+ * HTTP status code
1362
+ */
1363
+ statusCode: number;
1364
+ /**
1365
+ * ISO timestamp from API
1366
+ */
1367
+ timestamp?: string;
1368
+ /**
1369
+ * Path that caused the error (may be undefined for client-side errors)
1370
+ */
1371
+ path?: string;
1372
+ /**
1373
+ * Create a new ExaError
1374
+ * @param message Error message
1375
+ * @param statusCode HTTP status code
1376
+ * @param timestamp ISO timestamp from API
1377
+ * @param path Path that caused the error
1378
+ */
1379
+ constructor(message: string, statusCode: number, timestamp?: string, path?: string);
1380
+ }
1381
+
1382
+ declare const isBeta = false;
1383
+ /**
1384
+ * Search options for performing a search query.
1385
+ * @typedef {Object} SearchOptions
1386
+ * @property {number} [numResults] - Number of search results to return. Default 10. Max 10 for basic plans.
1387
+ * @property {string[]} [includeDomains] - List of domains to include in the search.
1388
+ * @property {string[]} [excludeDomains] - List of domains to exclude in the search.
1389
+ * @property {string} [startCrawlDate] - Start date for results based on crawl date.
1390
+ * @property {string} [endCrawlDate] - End date for results based on crawl date.
1391
+ * @property {string} [startPublishedDate] - Start date for results based on published date.
1392
+ * @property {string} [endPublishedDate] - End date for results based on published date.
1393
+ * @property {string} [category] - A data category to focus on, with higher comprehensivity and data cleanliness. Currently, the only category is company.
1394
+ * @property {string[]} [includeText] - List of strings that must be present in webpage text of results. Currently only supports 1 string of up to 5 words.
1395
+ * @property {string[]} [excludeText] - List of strings that must not be present in webpage text of results. Currently only supports 1 string of up to 5 words.
1396
+ * @property {string[]} [flags] - Experimental flags
1397
+ */
1398
+ type BaseSearchOptions = {
1399
+ numResults?: number;
1400
+ includeDomains?: string[];
1401
+ excludeDomains?: string[];
1402
+ startCrawlDate?: string;
1403
+ endCrawlDate?: string;
1404
+ startPublishedDate?: string;
1405
+ endPublishedDate?: string;
1406
+ category?: "company" | "research paper" | "news" | "pdf" | "github" | "tweet" | "personal site" | "linkedin profile" | "financial report";
1407
+ includeText?: string[];
1408
+ excludeText?: string[];
1409
+ flags?: string[];
1410
+ };
1411
+ /**
1412
+ * Search options for performing a search query.
1413
+ * @typedef {Object} RegularSearchOptions
1414
+ */
1415
+ type RegularSearchOptions = BaseSearchOptions & {
1416
+ /**
1417
+ * If true, the search results are moderated for safety.
1418
+ */
1419
+ moderation?: boolean;
1420
+ useAutoprompt?: boolean;
1421
+ type?: "keyword" | "neural" | "auto";
1422
+ };
1423
+ /**
1424
+ * Options for finding similar links.
1425
+ * @typedef {Object} FindSimilarOptions
1426
+ * @property {boolean} [excludeSourceDomain] - If true, excludes links from the base domain of the input.
1427
+ */
1428
+ type FindSimilarOptions = BaseSearchOptions & {
1429
+ excludeSourceDomain?: boolean;
1430
+ };
1431
+ type ExtrasOptions = {
1432
+ links?: number;
1433
+ imageLinks?: number;
1434
+ };
1435
+ /**
1436
+ * Search options for performing a search query.
1437
+ * @typedef {Object} ContentsOptions
1438
+ * @property {TextContentsOptions | boolean} [text] - Options for retrieving text contents.
1439
+ * @property {HighlightsContentsOptions | boolean} [highlights] - Options for retrieving highlights.
1440
+ * @property {SummaryContentsOptions | boolean} [summary] - Options for retrieving summary.
1441
+ * @property {LivecrawlOptions} [livecrawl] - Options for livecrawling contents. Default is "never" for neural/auto search, "fallback" for keyword search.
1442
+ * @property {number} [livecrawlTimeout] - The timeout for livecrawling. Max and default is 10000ms.
1443
+ * @property {boolean} [filterEmptyResults] - If true, filters out results with no contents. Default is true.
1444
+ * @property {number} [subpages] - The number of subpages to return for each result, where each subpage is derived from an internal link for the result.
1445
+ * @property {string | string[]} [subpageTarget] - Text used to match/rank subpages in the returned subpage list. You could use "about" to get *about* page for websites. Note that this is a fuzzy matcher.
1446
+ * @property {ExtrasOptions} [extras] - Miscelleneous data derived from results
1447
+ */
1448
+ type ContentsOptions = {
1449
+ text?: TextContentsOptions | true;
1450
+ highlights?: HighlightsContentsOptions | true;
1451
+ summary?: SummaryContentsOptions | true;
1452
+ livecrawl?: LivecrawlOptions;
1453
+ livecrawlTimeout?: number;
1454
+ filterEmptyResults?: boolean;
1455
+ subpages?: number;
1456
+ subpageTarget?: string | string[];
1457
+ extras?: ExtrasOptions;
1458
+ } & (typeof isBeta extends true ? {} : {});
1459
+ /**
1460
+ * Options for livecrawling contents
1461
+ * @typedef {string} LivecrawlOptions
1462
+ */
1463
+ type LivecrawlOptions = "never" | "fallback" | "always" | "auto";
1464
+ /**
1465
+ * Options for retrieving text from page.
1466
+ * @typedef {Object} TextContentsOptions
1467
+ * @property {number} [maxCharacters] - The maximum number of characters to return.
1468
+ * @property {boolean} [includeHtmlTags] - If true, includes HTML tags in the returned text. Default: false
1469
+ */
1470
+ type TextContentsOptions = {
1471
+ maxCharacters?: number;
1472
+ includeHtmlTags?: boolean;
1473
+ };
1474
+ /**
1475
+ * Options for retrieving highlights from page.
1476
+ * @typedef {Object} HighlightsContentsOptions
1477
+ * @property {string} [query] - The query string to use for highlights search.
1478
+ * @property {number} [numSentences] - The number of sentences to return for each highlight.
1479
+ * @property {number} [highlightsPerUrl] - The number of highlights to return for each URL.
1480
+ */
1481
+ type HighlightsContentsOptions = {
1482
+ query?: string;
1483
+ numSentences?: number;
1484
+ highlightsPerUrl?: number;
1485
+ };
1486
+ /**
1487
+ * Represents a JSON Schema definition used for structured summary output.
1488
+ * To learn more visit https://json-schema.org/overview/what-is-jsonschema.
1489
+ */
1490
+ type JSONSchema = {
1491
+ $schema?: string;
1492
+ title?: string;
1493
+ description?: string;
1494
+ type: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
1495
+ properties?: Record<string, JSONSchema>;
1496
+ items?: JSONSchema | JSONSchema[];
1497
+ required?: string[];
1498
+ enum?: any[];
1499
+ additionalProperties?: boolean | JSONSchema;
1500
+ definitions?: Record<string, JSONSchema>;
1501
+ patternProperties?: Record<string, JSONSchema>;
1502
+ allOf?: JSONSchema[];
1503
+ anyOf?: JSONSchema[];
1504
+ oneOf?: JSONSchema[];
1505
+ not?: JSONSchema;
1506
+ };
1507
+ /**
1508
+ * Options for retrieving summary from page.
1509
+ * @typedef {Object} SummaryContentsOptions
1510
+ * @property {string} [query] - The query string to use for summary generation.
1511
+ * @property {JSONSchema} [schema] - JSON schema for structured output from summary.
1512
+ */
1513
+ type SummaryContentsOptions = {
1514
+ query?: string;
1515
+ schema?: JSONSchema;
1516
+ };
1517
+ /**
1518
+ * @typedef {Object} TextResponse
1519
+ * @property {string} text - Text from page
1520
+ */
1521
+ type TextResponse = {
1522
+ text: string;
1523
+ };
1524
+ /**
1525
+ * @typedef {Object} HighlightsResponse
1526
+ * @property {string[]} highlights - The highlights as an array of strings.
1527
+ * @property {number[]} highlightScores - The corresponding scores as an array of floats, 0 to 1
1528
+ */
1529
+ type HighlightsResponse = {
1530
+ highlights: string[];
1531
+ highlightScores: number[];
1532
+ };
1533
+ /**
1534
+ * @typedef {Object} SummaryResponse
1535
+ * @property {string} summary - The generated summary of the page content.
1536
+ */
1537
+ type SummaryResponse = {
1538
+ summary: string;
1539
+ };
1540
+ /**
1541
+ * @typedef {Object} ExtrasResponse
1542
+ * @property {string[]} links - The links on the page of a result
1543
+ * @property {string[]} imageLinks - The image links on the page of a result
1544
+ */
1545
+ type ExtrasResponse = {
1546
+ extras: {
1547
+ links?: string[];
1548
+ imageLinks?: string[];
1549
+ };
1550
+ };
1551
+ /**
1552
+ * @typedef {Object} SubpagesResponse
1553
+ * @property {ContentsResultComponent<T extends ContentsOptions>} subpages - The subpages for a result
1554
+ */
1555
+ type SubpagesResponse<T extends ContentsOptions> = {
1556
+ subpages: ContentsResultComponent<T>[];
1557
+ };
1558
+ type Default<T extends {}, U> = [keyof T] extends [never] ? U : T;
1559
+ /**
1560
+ * @typedef {Object} ContentsResultComponent
1561
+ * Depending on 'ContentsOptions', this yields a combination of 'TextResponse', 'HighlightsResponse', 'SummaryResponse', or an empty object.
1562
+ *
1563
+ * @template T - A type extending from 'ContentsOptions'.
1564
+ */
1565
+ type ContentsResultComponent<T extends ContentsOptions> = Default<(T["text"] extends object | true ? TextResponse : {}) & (T["highlights"] extends object | true ? HighlightsResponse : {}) & (T["summary"] extends object | true ? SummaryResponse : {}) & (T["subpages"] extends number ? SubpagesResponse<T> : {}) & (T["extras"] extends object ? ExtrasResponse : {}), TextResponse>;
1566
+ /**
1567
+ * Represents the cost breakdown related to contents retrieval. Fields are optional because
1568
+ * only non-zero costs are included.
1569
+ * @typedef {Object} CostDollarsContents
1570
+ * @property {number} [text] - The cost in dollars for retrieving text.
1571
+ * @property {number} [highlights] - The cost in dollars for retrieving highlights.
1572
+ * @property {number} [summary] - The cost in dollars for retrieving summary.
1573
+ */
1574
+ type CostDollarsContents = {
1575
+ text?: number;
1576
+ highlights?: number;
1577
+ summary?: number;
1578
+ };
1579
+ /**
1580
+ * Represents the cost breakdown related to search. Fields are optional because
1581
+ * only non-zero costs are included.
1582
+ * @typedef {Object} CostDollarsSeearch
1583
+ * @property {number} [neural] - The cost in dollars for neural search.
1584
+ * @property {number} [keyword] - The cost in dollars for keyword search.
1585
+ */
1586
+ type CostDollarsSeearch = {
1587
+ neural?: number;
1588
+ keyword?: number;
1589
+ };
1590
+ /**
1591
+ * Represents the total cost breakdown. Only non-zero costs are included.
1592
+ * @typedef {Object} CostDollars
1593
+ * @property {number} total - The total cost in dollars.
1594
+ * @property {CostDollarsSeearch} [search] - The cost breakdown for search.
1595
+ * @property {CostDollarsContents} [contents] - The cost breakdown for contents.
1596
+ */
1597
+ type CostDollars = {
1598
+ total: number;
1599
+ search?: CostDollarsSeearch;
1600
+ contents?: CostDollarsContents;
1601
+ };
1602
+ /**
1603
+ * Represents a search result object.
1604
+ * @typedef {Object} SearchResult
1605
+ * @property {string} title - The title of the search result.
1606
+ * @property {string} url - The URL of the search result.
1607
+ * @property {string} [publishedDate] - The estimated creation date of the content.
1608
+ * @property {string} [author] - The author of the content, if available.
1609
+ * @property {number} [score] - Similarity score between the query/url and the result.
1610
+ * @property {string} id - The temporary ID for the document.
1611
+ * @property {string} [image] - A representative image for the content, if any.
1612
+ * @property {string} [favicon] - A favicon for the site, if any.
1613
+ */
1614
+ type SearchResult<T extends ContentsOptions> = {
1615
+ title: string | null;
1616
+ url: string;
1617
+ publishedDate?: string;
1618
+ author?: string;
1619
+ score?: number;
1620
+ id: string;
1621
+ image?: string;
1622
+ favicon?: string;
1623
+ } & ContentsResultComponent<T>;
1624
+ /**
1625
+ * Represents a search response object.
1626
+ * @typedef {Object} SearchResponse
1627
+ * @property {Result[]} results - The list of search results.
1628
+ * @property {string} [autopromptString] - The autoprompt string, if applicable.
1629
+ * @property {string} [autoDate] - The autoprompt date, if applicable.
1630
+ * @property {string} requestId - The request ID for the search.
1631
+ * @property {CostDollars} [costDollars] - The cost breakdown for this request.
1632
+ */
1633
+ type SearchResponse<T extends ContentsOptions> = {
1634
+ results: SearchResult<T>[];
1635
+ autopromptString?: string;
1636
+ autoDate?: string;
1637
+ requestId: string;
1638
+ costDollars?: CostDollars;
1639
+ };
1640
+ /**
1641
+ * Options for the answer endpoint
1642
+ * @typedef {Object} AnswerOptions
1643
+ * @property {boolean} [stream] - Whether to stream the response. Default false.
1644
+ * @property {boolean} [text] - Whether to include text in the source results. Default false.
1645
+ * @property {"exa" | "exa-pro"} [model] - The model to use for generating the answer. Default "exa".
1646
+ * @property {string} [systemPrompt] - A system prompt to guide the LLM's behavior when generating the answer.
1647
+ */
1648
+ type AnswerOptions = {
1649
+ stream?: boolean;
1650
+ text?: boolean;
1651
+ model?: "exa" | "exa-pro";
1652
+ systemPrompt?: string;
1653
+ };
1654
+ /**
1655
+ * Represents an answer response object from the /answer endpoint.
1656
+ * @typedef {Object} AnswerResponse
1657
+ * @property {string} answer - The generated answer text.
1658
+ * @property {SearchResult<{}>[]} citations - The sources used to generate the answer.
1659
+ * @property {CostDollars} [costDollars] - The cost breakdown for this request.
1660
+ * @property {string} [requestId] - Optional request ID for the answer.
1661
+ */
1662
+ type AnswerResponse = {
1663
+ answer: string;
1664
+ citations: SearchResult<{}>[];
1665
+ requestId?: string;
1666
+ costDollars?: CostDollars;
1667
+ };
1668
+ type AnswerStreamChunk = {
1669
+ /**
1670
+ * The partial text content of the answer (if present in this chunk).
1671
+ */
1672
+ content?: string;
1673
+ /**
1674
+ * Citations associated with the current chunk of text (if present).
1675
+ */
1676
+ citations?: Array<{
1677
+ id: string;
1678
+ url: string;
1679
+ title?: string;
1680
+ publishedDate?: string;
1681
+ author?: string;
1682
+ text?: string;
1683
+ }>;
1684
+ };
1685
+ /**
1686
+ * Represents a streaming answer response chunk from the /answer endpoint.
1687
+ * @typedef {Object} AnswerStreamResponse
1688
+ * @property {string} [answer] - A chunk of the generated answer text.
1689
+ * @property {SearchResult<{}>[]]} [citations] - The sources used to generate the answer.
1690
+ */
1691
+ type AnswerStreamResponse = {
1692
+ answer?: string;
1693
+ citations?: SearchResult<{}>[];
1694
+ };
1695
+ /**
1696
+ * Enum representing the status of a research task.
1697
+ */
1698
+ declare enum ResearchStatus {
1699
+ /** The research request has finished successfully. */
1700
+ completed = "completed",
1701
+ /** The research request failed. */
1702
+ failed = "failed"
1703
+ }
1704
+ /**
1705
+ * @typedef {Object} ResearchTaskResponse
1706
+ * @property {string} id - The unique identifier of the research request.
1707
+ * @property {ResearchStatus | string} status - The current status of the research request.
1708
+ * @property {Record<string, any> | null} output - The structured output, if the research has completed.
1709
+ * @property {SearchResult<{}>[]} citations - References used for the research.
1710
+ */
1711
+ type ResearchTaskResponse = {
1712
+ id: string;
1713
+ status: ResearchStatus | string;
1714
+ output: Record<string, any> | null;
1715
+ citations: SearchResult<{}>[];
1716
+ };
1717
+
1718
+ /**
1719
+ * The Exa class encapsulates the API's endpoints.
1720
+ */
1721
+ declare class Exa {
1722
+ private baseURL;
1723
+ private headers;
1724
+ /**
1725
+ * Websets API client
1726
+ */
1727
+ websets: WebsetsClient;
1728
+ /**
1729
+ * Helper method to separate out the contents-specific options from the rest.
1730
+ */
1731
+ private extractContentsOptions;
1732
+ /**
1733
+ * Constructs the Exa API client.
1734
+ * @param {string} apiKey - The API key for authentication.
1735
+ * @param {string} [baseURL] - The base URL of the Exa API.
1736
+ */
1737
+ constructor(apiKey?: string, baseURL?: string);
1738
+ /**
1739
+ * Makes a request to the Exa API.
1740
+ * @param {string} endpoint - The API endpoint to call.
1741
+ * @param {string} method - The HTTP method to use.
1742
+ * @param {any} [body] - The request body for POST requests.
1743
+ * @param {Record<string, any>} [params] - The query parameters.
1744
+ * @returns {Promise<any>} The response from the API.
1745
+ * @throws {ExaError} When any API request fails with structured error information
1746
+ */
1747
+ request<T = unknown>(endpoint: string, method: string, body?: any, params?: Record<string, any>): Promise<T>;
1748
+ /**
1749
+ * Performs a search with an Exa prompt-engineered query.
1750
+ *
1751
+ * @param {string} query - The query string.
1752
+ * @param {RegularSearchOptions} [options] - Additional search options
1753
+ * @returns {Promise<SearchResponse<{}>>} A list of relevant search results.
1754
+ */
1755
+ search(query: string, options?: RegularSearchOptions): Promise<SearchResponse<{}>>;
1756
+ /**
1757
+ * Performs a search with an Exa prompt-engineered query and returns the contents of the documents.
1758
+ *
1759
+ * @param {string} query - The query string.
1760
+ * @param {RegularSearchOptions & T} [options] - Additional search + contents options
1761
+ * @returns {Promise<SearchResponse<T>>} A list of relevant search results with requested contents.
1762
+ */
1763
+ searchAndContents<T extends ContentsOptions>(query: string, options?: RegularSearchOptions & T): Promise<SearchResponse<T>>;
1764
+ /**
1765
+ * Finds similar links to the provided URL.
1766
+ * @param {string} url - The URL for which to find similar links.
1767
+ * @param {FindSimilarOptions} [options] - Additional options for finding similar links.
1768
+ * @returns {Promise<SearchResponse<{}>>} A list of similar search results.
1769
+ */
1770
+ findSimilar(url: string, options?: FindSimilarOptions): Promise<SearchResponse<{}>>;
1771
+ /**
1772
+ * Finds similar links to the provided URL and returns the contents of the documents.
1773
+ * @param {string} url - The URL for which to find similar links.
1774
+ * @param {FindSimilarOptions & T} [options] - Additional options for finding similar links + contents.
1775
+ * @returns {Promise<SearchResponse<T>>} A list of similar search results, including requested contents.
1776
+ */
1777
+ findSimilarAndContents<T extends ContentsOptions>(url: string, options?: FindSimilarOptions & T): Promise<SearchResponse<T>>;
1778
+ /**
1779
+ * Retrieves contents of documents based on URLs.
1780
+ * @param {string | string[] | SearchResult[]} urls - A URL or array of URLs, or an array of SearchResult objects.
1781
+ * @param {ContentsOptions} [options] - Additional options for retrieving document contents.
1782
+ * @returns {Promise<SearchResponse<T>>} A list of document contents for the requested URLs.
1783
+ */
1784
+ getContents<T extends ContentsOptions>(urls: string | string[] | SearchResult<T>[], options?: T): Promise<SearchResponse<T>>;
1785
+ /**
1786
+ * Generate an answer to a query.
1787
+ * @param {string} query - The question or query to answer.
1788
+ * @param {AnswerOptions} [options] - Additional options for answer generation.
1789
+ * @returns {Promise<AnswerResponse>} The generated answer and source references.
1790
+ *
1791
+ * Example with systemPrompt:
1792
+ * ```ts
1793
+ * const answer = await exa.answer("What is quantum computing?", {
1794
+ * text: true,
1795
+ * model: "exa-pro",
1796
+ * systemPrompt: "Answer in a technical manner suitable for experts."
1797
+ * });
1798
+ * ```
1799
+ *
1800
+ * Note: For streaming responses, use the `streamAnswer` method:
1801
+ * ```ts
1802
+ * for await (const chunk of exa.streamAnswer(query)) {
1803
+ * // Handle chunks
1804
+ * }
1805
+ * ```
1806
+ */
1807
+ answer(query: string, options?: AnswerOptions): Promise<AnswerResponse>;
1808
+ /**
1809
+ * Stream an answer as an async generator
1810
+ *
1811
+ * Each iteration yields a chunk with partial text (`content`) or new citations.
1812
+ * Use this if you'd like to read the answer incrementally, e.g. in a chat UI.
1813
+ *
1814
+ * Example usage:
1815
+ * ```ts
1816
+ * for await (const chunk of exa.streamAnswer("What is quantum computing?", {
1817
+ * text: false,
1818
+ * systemPrompt: "Answer in a concise manner suitable for beginners."
1819
+ * })) {
1820
+ * if (chunk.content) process.stdout.write(chunk.content);
1821
+ * if (chunk.citations) {
1822
+ * console.log("\nCitations: ", chunk.citations);
1823
+ * }
1824
+ * }
1825
+ * ```
1826
+ */
1827
+ streamAnswer(query: string, options?: {
1828
+ text?: boolean;
1829
+ model?: "exa" | "exa-pro";
1830
+ systemPrompt?: string;
1831
+ }): AsyncGenerator<AnswerStreamChunk>;
1832
+ private processChunk;
1833
+ /**
1834
+ * Creates and runs a research task in a blocking manner.
1835
+ *
1836
+ * Both parameters are required and have fixed shapes:
1837
+ * 1. `input`
1838
+ * `{ instructions: string }`
1839
+ * • `instructions` – High-level guidance that tells the research agent what to do.
1840
+ * 2. `output`
1841
+ * defines the exact structure you expect back, and guides the research conducted by the agent.
1842
+ * `{ schema: JSONSchema }`.
1843
+ * The agent’s response will be validated against this schema.
1844
+ *
1845
+ * @param {{ instructions: string }} input The research prompt.
1846
+ * @param {{ schema: JSONSchema }} output The desired output schema.
1847
+ * @returns {Promise<ResearchTaskResponse>} The research response.
1848
+ *
1849
+ * @example
1850
+ * const response = await exa.researchTask(
1851
+ * { instructions: "I need a few key facts about honey pot ants." },
1852
+ * {
1853
+ * schema: {
1854
+ * type: "object",
1855
+ * required: ["scientificName", "primaryRegions"],
1856
+ * properties: {
1857
+ * scientificName: { type: "string" },
1858
+ * primaryRegions: { type: "string" },
1859
+ * },
1860
+ * },
1861
+ * },
1862
+ * );
1863
+ */
1864
+ researchTask(input: {
1865
+ instructions: string;
1866
+ }, output: {
1867
+ schema: JSONSchema;
1868
+ }): Promise<ResearchTaskResponse>;
1869
+ }
1870
+
1871
+ export { type AnswerOptions, type AnswerResponse, type AnswerStreamChunk, type AnswerStreamResponse, type BaseSearchOptions, type ContentsOptions, type ContentsResultComponent, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, CreateWebsetSearchParametersBehaviour, type Default, type EnrichmentResult, type Event, EventType, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type JSONSchema, type ListEventsResponse, type ListWebhooksOptions, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetsOptions, type ListWebsetsResponse, type LivecrawlOptions, type RegularSearchOptions, ResearchStatus, type ResearchTaskResponse, type SearchResponse, type SearchResult, type SubpagesResponse, type SummaryContentsOptions, type SummaryResponse, type TextContentsOptions, type TextResponse, type UpdateWebhookParameters, type UpdateWebsetRequest, type Webhook, WebhookStatus, type Webset, type WebsetEnrichment, WebsetEnrichmentFormat, WebsetEnrichmentStatus, WebsetEnrichmentsClient, type WebsetItem, WebsetItemEvaluationSatisfied, WebsetItemSource, WebsetItemsClient, type WebsetSearch, WebsetSearchCanceledReason, WebsetSearchStatus, WebsetSearchesClient, WebsetStatus, WebsetWebhooksClient, WebsetsClient, Exa as default };