exa-js 2.10.2 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +21 -9
- package/dist/index.d.mts +38 -18
- package/dist/index.d.ts +38 -18
- package/dist/index.js +43 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -50,8 +50,8 @@ const result = await exa.search("interesting articles about space", {
|
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
|
-
const
|
|
54
|
-
type: "
|
|
53
|
+
const resultWithOutput = await exa.search("Who leads OpenAI's safety team?", {
|
|
54
|
+
type: "auto",
|
|
55
55
|
systemPrompt: "Prefer official sources and avoid duplicate results",
|
|
56
56
|
outputSchema: {
|
|
57
57
|
type: "object",
|
|
@@ -64,22 +64,34 @@ const deepResult = await exa.search("Who leads OpenAI's safety team?", {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
console.log(
|
|
67
|
+
console.log(resultWithOutput.output?.content);
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
```ts
|
|
71
|
+
for await (const chunk of exa.streamSearch("Who leads OpenAI's safety team?", {
|
|
72
|
+
type: "auto"
|
|
73
|
+
})) {
|
|
74
|
+
if (chunk.content) {
|
|
75
|
+
process.stdout.write(chunk.content);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Search `outputSchema` modes:
|
|
71
81
|
- `type: "text"`: return plain text in `output.content` (optionally guided by `description`)
|
|
72
82
|
- `type: "object"`: return structured JSON in `output.content`
|
|
73
83
|
|
|
74
|
-
|
|
84
|
+
`systemPrompt` and `outputSchema` are supported on every search type.
|
|
85
|
+
Search streaming is available via `streamSearch(...)`, which yields OpenAI-style chat completion chunks.
|
|
75
86
|
|
|
76
|
-
For `type: "object"`,
|
|
87
|
+
For `type: "object"`, search currently enforces:
|
|
77
88
|
- max nesting depth: `2`
|
|
78
89
|
- max total properties: `10`
|
|
79
90
|
|
|
80
|
-
Deep search variants
|
|
81
|
-
- `deep
|
|
82
|
-
- `deep
|
|
91
|
+
Deep search variants that also support `additionalQueries`:
|
|
92
|
+
- `deep-lite`
|
|
93
|
+
- `deep`
|
|
94
|
+
- `deep-reasoning`
|
|
83
95
|
|
|
84
96
|
## Contents
|
|
85
97
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1022,6 +1022,8 @@ interface components {
|
|
|
1022
1022
|
/** @enum {string} */
|
|
1023
1023
|
source: WebsetExcludeSource;
|
|
1024
1024
|
}[];
|
|
1025
|
+
/** @description Optional soft cap for people searches. When set, the search will try to include at most this many matching people from the same current employer company. */
|
|
1026
|
+
maxPeoplePerCompany?: number;
|
|
1025
1027
|
/** @description Natural language search query describing what you are looking for.
|
|
1026
1028
|
*
|
|
1027
1029
|
* Be specific and descriptive about your requirements, characteristics, and any constraints that help narrow down the results.
|
|
@@ -1078,6 +1080,8 @@ interface components {
|
|
|
1078
1080
|
metadata?: {
|
|
1079
1081
|
[key: string]: string;
|
|
1080
1082
|
};
|
|
1083
|
+
/** @description Optional soft cap for people searches. When set, the search will try to include at most this many matching people from the same current employer company. */
|
|
1084
|
+
maxPeoplePerCompany?: number;
|
|
1081
1085
|
/** @description Natural language search query describing what you are looking for.
|
|
1082
1086
|
*
|
|
1083
1087
|
* Be specific and descriptive about your requirements, characteristics, and any constraints that help narrow down the results.
|
|
@@ -2317,6 +2321,8 @@ interface components {
|
|
|
2317
2321
|
}[];
|
|
2318
2322
|
/** @description The unique identifier for the search */
|
|
2319
2323
|
id: string;
|
|
2324
|
+
/** @description The soft cap requested for matching people from the same current employer company, or null when no cap was requested. */
|
|
2325
|
+
maxPeoplePerCompany: number | null;
|
|
2320
2326
|
/**
|
|
2321
2327
|
* @description Set of key-value pairs you want to associate with this object.
|
|
2322
2328
|
* @default {}
|
|
@@ -3286,6 +3292,7 @@ type ContentsOptions = {
|
|
|
3286
3292
|
* @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.
|
|
3287
3293
|
* @property {string[]} [flags] - Experimental flags
|
|
3288
3294
|
* @property {string} [userLocation] - The two-letter ISO country code of the user, e.g. US.
|
|
3295
|
+
* @property {boolean} [stream] - Whether to stream back OpenAI-style chat completion chunks. Use `streamSearch()` instead of `search({ stream: true })`.
|
|
3289
3296
|
*/
|
|
3290
3297
|
type BaseSearchOptions = {
|
|
3291
3298
|
contents?: ContentsOptions;
|
|
@@ -3301,6 +3308,7 @@ type BaseSearchOptions = {
|
|
|
3301
3308
|
excludeText?: string[];
|
|
3302
3309
|
flags?: string[];
|
|
3303
3310
|
userLocation?: string;
|
|
3311
|
+
stream?: boolean;
|
|
3304
3312
|
};
|
|
3305
3313
|
/**
|
|
3306
3314
|
* Base search options shared across all search types
|
|
@@ -3311,8 +3319,21 @@ type BaseRegularSearchOptions = BaseSearchOptions & {
|
|
|
3311
3319
|
*/
|
|
3312
3320
|
moderation?: boolean;
|
|
3313
3321
|
useAutoprompt?: boolean;
|
|
3322
|
+
/**
|
|
3323
|
+
* Additional instructions that guide both the search process and the final returned synthesis.
|
|
3324
|
+
* Use this to prefer certain sources, emphasize novelty, avoid duplicates, or constrain output style.
|
|
3325
|
+
*/
|
|
3326
|
+
systemPrompt?: string;
|
|
3327
|
+
/**
|
|
3328
|
+
* Output schema for search responses. When provided, the API returns synthesized output in `output`.
|
|
3329
|
+
* - `type: "text"` for plain text output (optionally guided by `description`)
|
|
3330
|
+
* - `type: "object"` for structured JSON output
|
|
3331
|
+
*
|
|
3332
|
+
* Note: For object schemas, the API enforces max depth 2 and max 10 total properties.
|
|
3333
|
+
*/
|
|
3334
|
+
outputSchema?: DeepOutputSchema;
|
|
3314
3335
|
};
|
|
3315
|
-
type DeepSearchType = "deep" | "deep-reasoning";
|
|
3336
|
+
type DeepSearchType = "deep-lite" | "deep" | "deep-reasoning";
|
|
3316
3337
|
/**
|
|
3317
3338
|
* Deep search output schema mode for plain text responses.
|
|
3318
3339
|
*/
|
|
@@ -3338,7 +3359,7 @@ type DeepObjectOutputSchema = {
|
|
|
3338
3359
|
required?: string[];
|
|
3339
3360
|
};
|
|
3340
3361
|
/**
|
|
3341
|
-
*
|
|
3362
|
+
* Search output schema.
|
|
3342
3363
|
* - `type: "text"` returns plain text in `output.content` (with optional description guidance).
|
|
3343
3364
|
* - `type: "object"` returns structured JSON in `output.content`.
|
|
3344
3365
|
*
|
|
@@ -3354,7 +3375,7 @@ type DeepContentsOptions = Omit<ContentsOptions, "context"> & {
|
|
|
3354
3375
|
context?: Omit<ContextOptions, never> | true;
|
|
3355
3376
|
};
|
|
3356
3377
|
/**
|
|
3357
|
-
* Search options for deep search
|
|
3378
|
+
* Search options for deep search types, which additionally support additional queries.
|
|
3358
3379
|
*/
|
|
3359
3380
|
type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
|
|
3360
3381
|
type: DeepSearchType;
|
|
@@ -3364,19 +3385,6 @@ type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
|
|
|
3364
3385
|
* @example ["machine learning", "ML algorithms", "neural networks"]
|
|
3365
3386
|
*/
|
|
3366
3387
|
additionalQueries?: string[];
|
|
3367
|
-
/**
|
|
3368
|
-
* Additional instructions that guide both deep-search planning and the final returned synthesis.
|
|
3369
|
-
* Use this to prefer certain sources, emphasize novelty, avoid duplicates, or constrain output style.
|
|
3370
|
-
*/
|
|
3371
|
-
systemPrompt?: string;
|
|
3372
|
-
/**
|
|
3373
|
-
* Output schema for deep search responses.
|
|
3374
|
-
* - `type: "text"` for plain text output (optionally guided by `description`)
|
|
3375
|
-
* - `type: "object"` for structured JSON output
|
|
3376
|
-
*
|
|
3377
|
-
* Note: For object schemas, the API enforces max depth 2 and max 10 total properties.
|
|
3378
|
-
*/
|
|
3379
|
-
outputSchema?: DeepOutputSchema;
|
|
3380
3388
|
/**
|
|
3381
3389
|
* Options for retrieving page contents.
|
|
3382
3390
|
*/
|
|
@@ -3687,7 +3695,7 @@ type DeepSearchOutput = {
|
|
|
3687
3695
|
* @typedef {Object} SearchResponse
|
|
3688
3696
|
* @property {Result[]} results - The list of search results.
|
|
3689
3697
|
* @property {string} [context] - Deprecated. The context for the search.
|
|
3690
|
-
* @property {DeepSearchOutput} [output] -
|
|
3698
|
+
* @property {DeepSearchOutput} [output] - Search synthesized output object returned when `outputSchema` is provided.
|
|
3691
3699
|
* @property {string} [autoDate] - The autoprompt date, if applicable.
|
|
3692
3700
|
* @property {string} requestId - The request ID for the search.
|
|
3693
3701
|
* @property {CostDollars} [costDollars] - The cost breakdown for this request.
|
|
@@ -3759,6 +3767,7 @@ type AnswerStreamChunk = {
|
|
|
3759
3767
|
text?: string;
|
|
3760
3768
|
}>;
|
|
3761
3769
|
};
|
|
3770
|
+
type SearchStreamChunk = AnswerStreamChunk;
|
|
3762
3771
|
/**
|
|
3763
3772
|
* Represents a streaming answer response chunk from the /answer endpoint.
|
|
3764
3773
|
* @typedef {Object} AnswerStreamResponse
|
|
@@ -3809,6 +3818,7 @@ declare class Exa {
|
|
|
3809
3818
|
* Helper method to separate out the contents-specific options from the rest.
|
|
3810
3819
|
*/
|
|
3811
3820
|
private extractContentsOptions;
|
|
3821
|
+
private buildSearchRequestBody;
|
|
3812
3822
|
/**
|
|
3813
3823
|
* Constructs the Exa API client.
|
|
3814
3824
|
* @param {string} apiKey - The API key for authentication.
|
|
@@ -3869,6 +3879,15 @@ declare class Exa {
|
|
|
3869
3879
|
search(query: string, options: Omit<DeepSearchOptions, "contents"> | Omit<NonDeepSearchOptions, "contents">): Promise<SearchResponse<{
|
|
3870
3880
|
text: true;
|
|
3871
3881
|
}>>;
|
|
3882
|
+
/**
|
|
3883
|
+
* Stream a search response as an async generator of OpenAI-style chat completion chunks.
|
|
3884
|
+
*
|
|
3885
|
+
* Each iteration yields a chunk with partial text (`content`) or new citations.
|
|
3886
|
+
* Use this if you'd like to read synthesized search output incrementally.
|
|
3887
|
+
*/
|
|
3888
|
+
streamSearch(query: string, options?: RegularSearchOptions & {
|
|
3889
|
+
contents?: ContentsOptions | false | null | undefined;
|
|
3890
|
+
}): AsyncGenerator<SearchStreamChunk>;
|
|
3872
3891
|
/**
|
|
3873
3892
|
* @deprecated Use `search()` instead. The search method now returns text contents by default.
|
|
3874
3893
|
*
|
|
@@ -4012,8 +4031,9 @@ declare class Exa {
|
|
|
4012
4031
|
outputSchema?: Record<string, unknown>;
|
|
4013
4032
|
userLocation?: string;
|
|
4014
4033
|
}): AsyncGenerator<AnswerStreamChunk>;
|
|
4034
|
+
private streamChatCompletions;
|
|
4015
4035
|
private processChunk;
|
|
4016
4036
|
private parseSSEStream;
|
|
4017
4037
|
}
|
|
4018
4038
|
|
|
4019
|
-
export { type AnswerOptions, type AnswerOptionsTyped, type AnswerResponse, type AnswerResponseTyped, type AnswerStreamChunk, type AnswerStreamResponse, type ArticleEntity, type BaseSearchOptions, type CompanyEntity, type ContentsOptions, type ContentsResultComponent, type ContextOptions, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateCriterionParameters, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateImportParameters, CreateImportParametersFormat, type CreateImportResponse, type CreateImportWithCsvParameters, type CreateMonitorParameters, type CreateSearchMonitorParams, type CreateSearchMonitorResponse, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, type CsvDataInput, type CustomEntity, type DeepObjectOutputSchema, type DeepOutputSchema, type DeepSearchOutput, type DeepSearchOutputGrounding, type DeepSearchOutputGroundingCitation, type DeepSearchOutputGroundingConfidence, type DeepSearchType, type DeepTextOutputSchema, type Default, type EnrichmentResult, type Entity, type EntityCompanyProperties, type EntityCompanyPropertiesFinancials, type EntityCompanyPropertiesFundingRound, type EntityCompanyPropertiesHeadquarters, type EntityCompanyPropertiesWebTraffic, type EntityCompanyPropertiesWorkforce, type EntityDateRange, type EntityPersonProperties, type EntityPersonPropertiesCompanyRef, type EntityPersonPropertiesWorkHistoryEntry, type Event, EventType, EventsClient, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type GroundingCitation, type GroundingEntry, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type Import, ImportFailedReason, ImportFormat, ImportObject, ImportStatus, ImportsClient, type JSONSchema, type ListEventsResponse, type ListImportsResponse, type ListMonitorRunsResponse, type ListMonitorsOptions, type ListMonitorsResponse, type ListResearchRequest, type ListResearchResponse, type ListSearchMonitorRunsParams, type ListSearchMonitorRunsResponse, type ListSearchMonitorsParams, type ListSearchMonitorsResponse, type ListWebhookAttemptsResponse, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetItemsOptions, type ListWebsetsResponse, type LivecrawlOptions, type Monitor, type MonitorBehavior, type MonitorCadence, MonitorObject, type MonitorRun, MonitorRunObject, MonitorRunStatus, MonitorRunType, MonitorStatus, type PersonEntity, type PreviewWebsetParameters, type PreviewWebsetResponse, type RegularSearchOptions, type Research, type ResearchCreateParamsTyped, type ResearchCreateRequest, type ResearchCreateResponse, type ResearchDefinitionEvent, type ResearchEvent, type ResearchOperation, type ResearchOutputEvent, type ResearchPaperEntity, type ResearchPlanDefinitionEvent, type ResearchPlanOperationEvent, type ResearchPlanOutputEvent, type ResearchStatus, type ResearchStreamEvent, type ResearchStreamEventTyped, type ResearchTaskDefinitionEvent, type ResearchTaskOperationEvent, type ResearchTaskOutputEvent, type ResearchTyped, type SearchMonitor, type SearchMonitorRun, type SearchMonitorRunFailReason, type SearchMonitorRunOutput, type SearchMonitorRunStatus, SearchMonitorRunsClient, type SearchMonitorSearch, type SearchMonitorStatus, type SearchMonitorTrigger, type SearchMonitorWebhook, type SearchMonitorWebhookEvent, SearchMonitorsClient, type SearchResponse, type SearchResult, type SectionTag, type Status, type SubpagesResponse, type SummaryContentsOptions, type SummaryContentsOptionsTyped, type SummaryResponse, type TextContentsOptions, type TextResponse, type TriggerSearchMonitorResponse, type UpdateEnrichmentParameters, type UpdateImport, type UpdateMonitor, UpdateMonitorStatus, type UpdateSearchMonitorParams, type UpdateWebhookParameters, type UpdateWebsetRequest, type VerbosityOptions, type WaitUntilCompletedOptions, type Webhook, type WebhookAttempt, WebhookStatus, type Webset, type WebsetEnrichment, WebsetEnrichmentFormat, WebsetEnrichmentStatus, WebsetEnrichmentsClient, WebsetExcludeSource, type WebsetHeadersLike, WebsetImportSource, type WebsetItem, type WebsetItemArticleProperties, type WebsetItemCompanyProperties, type WebsetItemCustomProperties, type WebsetItemEvaluation, WebsetItemEvaluationSatisfied, type WebsetItemPersonProperties, type WebsetItemResearchPaperProperties, WebsetItemSource, WebsetItemsClient, WebsetMonitorsClient, type WebsetSearch, WebsetSearchBehavior, WebsetSearchCanceledReason, WebsetSearchScopeSource, WebsetSearchStatus, WebsetSearchesClient, WebsetStatus, WebsetWebhooksClient, WebsetsClient, Exa as default };
|
|
4039
|
+
export { type AnswerOptions, type AnswerOptionsTyped, type AnswerResponse, type AnswerResponseTyped, type AnswerStreamChunk, type AnswerStreamResponse, type ArticleEntity, type BaseSearchOptions, type CompanyEntity, type ContentsOptions, type ContentsResultComponent, type ContextOptions, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateCriterionParameters, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateImportParameters, CreateImportParametersFormat, type CreateImportResponse, type CreateImportWithCsvParameters, type CreateMonitorParameters, type CreateSearchMonitorParams, type CreateSearchMonitorResponse, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, type CsvDataInput, type CustomEntity, type DeepObjectOutputSchema, type DeepOutputSchema, type DeepSearchOutput, type DeepSearchOutputGrounding, type DeepSearchOutputGroundingCitation, type DeepSearchOutputGroundingConfidence, type DeepSearchType, type DeepTextOutputSchema, type Default, type EnrichmentResult, type Entity, type EntityCompanyProperties, type EntityCompanyPropertiesFinancials, type EntityCompanyPropertiesFundingRound, type EntityCompanyPropertiesHeadquarters, type EntityCompanyPropertiesWebTraffic, type EntityCompanyPropertiesWorkforce, type EntityDateRange, type EntityPersonProperties, type EntityPersonPropertiesCompanyRef, type EntityPersonPropertiesWorkHistoryEntry, type Event, EventType, EventsClient, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type GroundingCitation, type GroundingEntry, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type Import, ImportFailedReason, ImportFormat, ImportObject, ImportStatus, ImportsClient, type JSONSchema, type ListEventsResponse, type ListImportsResponse, type ListMonitorRunsResponse, type ListMonitorsOptions, type ListMonitorsResponse, type ListResearchRequest, type ListResearchResponse, type ListSearchMonitorRunsParams, type ListSearchMonitorRunsResponse, type ListSearchMonitorsParams, type ListSearchMonitorsResponse, type ListWebhookAttemptsResponse, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetItemsOptions, type ListWebsetsResponse, type LivecrawlOptions, type Monitor, type MonitorBehavior, type MonitorCadence, MonitorObject, type MonitorRun, MonitorRunObject, MonitorRunStatus, MonitorRunType, MonitorStatus, type PersonEntity, type PreviewWebsetParameters, type PreviewWebsetResponse, type RegularSearchOptions, type Research, type ResearchCreateParamsTyped, type ResearchCreateRequest, type ResearchCreateResponse, type ResearchDefinitionEvent, type ResearchEvent, type ResearchOperation, type ResearchOutputEvent, type ResearchPaperEntity, type ResearchPlanDefinitionEvent, type ResearchPlanOperationEvent, type ResearchPlanOutputEvent, type ResearchStatus, type ResearchStreamEvent, type ResearchStreamEventTyped, type ResearchTaskDefinitionEvent, type ResearchTaskOperationEvent, type ResearchTaskOutputEvent, type ResearchTyped, type SearchMonitor, type SearchMonitorRun, type SearchMonitorRunFailReason, type SearchMonitorRunOutput, type SearchMonitorRunStatus, SearchMonitorRunsClient, type SearchMonitorSearch, type SearchMonitorStatus, type SearchMonitorTrigger, type SearchMonitorWebhook, type SearchMonitorWebhookEvent, SearchMonitorsClient, type SearchResponse, type SearchResult, type SearchStreamChunk, type SectionTag, type Status, type SubpagesResponse, type SummaryContentsOptions, type SummaryContentsOptionsTyped, type SummaryResponse, type TextContentsOptions, type TextResponse, type TriggerSearchMonitorResponse, type UpdateEnrichmentParameters, type UpdateImport, type UpdateMonitor, UpdateMonitorStatus, type UpdateSearchMonitorParams, type UpdateWebhookParameters, type UpdateWebsetRequest, type VerbosityOptions, type WaitUntilCompletedOptions, type Webhook, type WebhookAttempt, WebhookStatus, type Webset, type WebsetEnrichment, WebsetEnrichmentFormat, WebsetEnrichmentStatus, WebsetEnrichmentsClient, WebsetExcludeSource, type WebsetHeadersLike, WebsetImportSource, type WebsetItem, type WebsetItemArticleProperties, type WebsetItemCompanyProperties, type WebsetItemCustomProperties, type WebsetItemEvaluation, WebsetItemEvaluationSatisfied, type WebsetItemPersonProperties, type WebsetItemResearchPaperProperties, WebsetItemSource, WebsetItemsClient, WebsetMonitorsClient, type WebsetSearch, WebsetSearchBehavior, WebsetSearchCanceledReason, WebsetSearchScopeSource, WebsetSearchStatus, WebsetSearchesClient, WebsetStatus, WebsetWebhooksClient, WebsetsClient, Exa as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1022,6 +1022,8 @@ interface components {
|
|
|
1022
1022
|
/** @enum {string} */
|
|
1023
1023
|
source: WebsetExcludeSource;
|
|
1024
1024
|
}[];
|
|
1025
|
+
/** @description Optional soft cap for people searches. When set, the search will try to include at most this many matching people from the same current employer company. */
|
|
1026
|
+
maxPeoplePerCompany?: number;
|
|
1025
1027
|
/** @description Natural language search query describing what you are looking for.
|
|
1026
1028
|
*
|
|
1027
1029
|
* Be specific and descriptive about your requirements, characteristics, and any constraints that help narrow down the results.
|
|
@@ -1078,6 +1080,8 @@ interface components {
|
|
|
1078
1080
|
metadata?: {
|
|
1079
1081
|
[key: string]: string;
|
|
1080
1082
|
};
|
|
1083
|
+
/** @description Optional soft cap for people searches. When set, the search will try to include at most this many matching people from the same current employer company. */
|
|
1084
|
+
maxPeoplePerCompany?: number;
|
|
1081
1085
|
/** @description Natural language search query describing what you are looking for.
|
|
1082
1086
|
*
|
|
1083
1087
|
* Be specific and descriptive about your requirements, characteristics, and any constraints that help narrow down the results.
|
|
@@ -2317,6 +2321,8 @@ interface components {
|
|
|
2317
2321
|
}[];
|
|
2318
2322
|
/** @description The unique identifier for the search */
|
|
2319
2323
|
id: string;
|
|
2324
|
+
/** @description The soft cap requested for matching people from the same current employer company, or null when no cap was requested. */
|
|
2325
|
+
maxPeoplePerCompany: number | null;
|
|
2320
2326
|
/**
|
|
2321
2327
|
* @description Set of key-value pairs you want to associate with this object.
|
|
2322
2328
|
* @default {}
|
|
@@ -3286,6 +3292,7 @@ type ContentsOptions = {
|
|
|
3286
3292
|
* @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.
|
|
3287
3293
|
* @property {string[]} [flags] - Experimental flags
|
|
3288
3294
|
* @property {string} [userLocation] - The two-letter ISO country code of the user, e.g. US.
|
|
3295
|
+
* @property {boolean} [stream] - Whether to stream back OpenAI-style chat completion chunks. Use `streamSearch()` instead of `search({ stream: true })`.
|
|
3289
3296
|
*/
|
|
3290
3297
|
type BaseSearchOptions = {
|
|
3291
3298
|
contents?: ContentsOptions;
|
|
@@ -3301,6 +3308,7 @@ type BaseSearchOptions = {
|
|
|
3301
3308
|
excludeText?: string[];
|
|
3302
3309
|
flags?: string[];
|
|
3303
3310
|
userLocation?: string;
|
|
3311
|
+
stream?: boolean;
|
|
3304
3312
|
};
|
|
3305
3313
|
/**
|
|
3306
3314
|
* Base search options shared across all search types
|
|
@@ -3311,8 +3319,21 @@ type BaseRegularSearchOptions = BaseSearchOptions & {
|
|
|
3311
3319
|
*/
|
|
3312
3320
|
moderation?: boolean;
|
|
3313
3321
|
useAutoprompt?: boolean;
|
|
3322
|
+
/**
|
|
3323
|
+
* Additional instructions that guide both the search process and the final returned synthesis.
|
|
3324
|
+
* Use this to prefer certain sources, emphasize novelty, avoid duplicates, or constrain output style.
|
|
3325
|
+
*/
|
|
3326
|
+
systemPrompt?: string;
|
|
3327
|
+
/**
|
|
3328
|
+
* Output schema for search responses. When provided, the API returns synthesized output in `output`.
|
|
3329
|
+
* - `type: "text"` for plain text output (optionally guided by `description`)
|
|
3330
|
+
* - `type: "object"` for structured JSON output
|
|
3331
|
+
*
|
|
3332
|
+
* Note: For object schemas, the API enforces max depth 2 and max 10 total properties.
|
|
3333
|
+
*/
|
|
3334
|
+
outputSchema?: DeepOutputSchema;
|
|
3314
3335
|
};
|
|
3315
|
-
type DeepSearchType = "deep" | "deep-reasoning";
|
|
3336
|
+
type DeepSearchType = "deep-lite" | "deep" | "deep-reasoning";
|
|
3316
3337
|
/**
|
|
3317
3338
|
* Deep search output schema mode for plain text responses.
|
|
3318
3339
|
*/
|
|
@@ -3338,7 +3359,7 @@ type DeepObjectOutputSchema = {
|
|
|
3338
3359
|
required?: string[];
|
|
3339
3360
|
};
|
|
3340
3361
|
/**
|
|
3341
|
-
*
|
|
3362
|
+
* Search output schema.
|
|
3342
3363
|
* - `type: "text"` returns plain text in `output.content` (with optional description guidance).
|
|
3343
3364
|
* - `type: "object"` returns structured JSON in `output.content`.
|
|
3344
3365
|
*
|
|
@@ -3354,7 +3375,7 @@ type DeepContentsOptions = Omit<ContentsOptions, "context"> & {
|
|
|
3354
3375
|
context?: Omit<ContextOptions, never> | true;
|
|
3355
3376
|
};
|
|
3356
3377
|
/**
|
|
3357
|
-
* Search options for deep search
|
|
3378
|
+
* Search options for deep search types, which additionally support additional queries.
|
|
3358
3379
|
*/
|
|
3359
3380
|
type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
|
|
3360
3381
|
type: DeepSearchType;
|
|
@@ -3364,19 +3385,6 @@ type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
|
|
|
3364
3385
|
* @example ["machine learning", "ML algorithms", "neural networks"]
|
|
3365
3386
|
*/
|
|
3366
3387
|
additionalQueries?: string[];
|
|
3367
|
-
/**
|
|
3368
|
-
* Additional instructions that guide both deep-search planning and the final returned synthesis.
|
|
3369
|
-
* Use this to prefer certain sources, emphasize novelty, avoid duplicates, or constrain output style.
|
|
3370
|
-
*/
|
|
3371
|
-
systemPrompt?: string;
|
|
3372
|
-
/**
|
|
3373
|
-
* Output schema for deep search responses.
|
|
3374
|
-
* - `type: "text"` for plain text output (optionally guided by `description`)
|
|
3375
|
-
* - `type: "object"` for structured JSON output
|
|
3376
|
-
*
|
|
3377
|
-
* Note: For object schemas, the API enforces max depth 2 and max 10 total properties.
|
|
3378
|
-
*/
|
|
3379
|
-
outputSchema?: DeepOutputSchema;
|
|
3380
3388
|
/**
|
|
3381
3389
|
* Options for retrieving page contents.
|
|
3382
3390
|
*/
|
|
@@ -3687,7 +3695,7 @@ type DeepSearchOutput = {
|
|
|
3687
3695
|
* @typedef {Object} SearchResponse
|
|
3688
3696
|
* @property {Result[]} results - The list of search results.
|
|
3689
3697
|
* @property {string} [context] - Deprecated. The context for the search.
|
|
3690
|
-
* @property {DeepSearchOutput} [output] -
|
|
3698
|
+
* @property {DeepSearchOutput} [output] - Search synthesized output object returned when `outputSchema` is provided.
|
|
3691
3699
|
* @property {string} [autoDate] - The autoprompt date, if applicable.
|
|
3692
3700
|
* @property {string} requestId - The request ID for the search.
|
|
3693
3701
|
* @property {CostDollars} [costDollars] - The cost breakdown for this request.
|
|
@@ -3759,6 +3767,7 @@ type AnswerStreamChunk = {
|
|
|
3759
3767
|
text?: string;
|
|
3760
3768
|
}>;
|
|
3761
3769
|
};
|
|
3770
|
+
type SearchStreamChunk = AnswerStreamChunk;
|
|
3762
3771
|
/**
|
|
3763
3772
|
* Represents a streaming answer response chunk from the /answer endpoint.
|
|
3764
3773
|
* @typedef {Object} AnswerStreamResponse
|
|
@@ -3809,6 +3818,7 @@ declare class Exa {
|
|
|
3809
3818
|
* Helper method to separate out the contents-specific options from the rest.
|
|
3810
3819
|
*/
|
|
3811
3820
|
private extractContentsOptions;
|
|
3821
|
+
private buildSearchRequestBody;
|
|
3812
3822
|
/**
|
|
3813
3823
|
* Constructs the Exa API client.
|
|
3814
3824
|
* @param {string} apiKey - The API key for authentication.
|
|
@@ -3869,6 +3879,15 @@ declare class Exa {
|
|
|
3869
3879
|
search(query: string, options: Omit<DeepSearchOptions, "contents"> | Omit<NonDeepSearchOptions, "contents">): Promise<SearchResponse<{
|
|
3870
3880
|
text: true;
|
|
3871
3881
|
}>>;
|
|
3882
|
+
/**
|
|
3883
|
+
* Stream a search response as an async generator of OpenAI-style chat completion chunks.
|
|
3884
|
+
*
|
|
3885
|
+
* Each iteration yields a chunk with partial text (`content`) or new citations.
|
|
3886
|
+
* Use this if you'd like to read synthesized search output incrementally.
|
|
3887
|
+
*/
|
|
3888
|
+
streamSearch(query: string, options?: RegularSearchOptions & {
|
|
3889
|
+
contents?: ContentsOptions | false | null | undefined;
|
|
3890
|
+
}): AsyncGenerator<SearchStreamChunk>;
|
|
3872
3891
|
/**
|
|
3873
3892
|
* @deprecated Use `search()` instead. The search method now returns text contents by default.
|
|
3874
3893
|
*
|
|
@@ -4012,8 +4031,9 @@ declare class Exa {
|
|
|
4012
4031
|
outputSchema?: Record<string, unknown>;
|
|
4013
4032
|
userLocation?: string;
|
|
4014
4033
|
}): AsyncGenerator<AnswerStreamChunk>;
|
|
4034
|
+
private streamChatCompletions;
|
|
4015
4035
|
private processChunk;
|
|
4016
4036
|
private parseSSEStream;
|
|
4017
4037
|
}
|
|
4018
4038
|
|
|
4019
|
-
export { type AnswerOptions, type AnswerOptionsTyped, type AnswerResponse, type AnswerResponseTyped, type AnswerStreamChunk, type AnswerStreamResponse, type ArticleEntity, type BaseSearchOptions, type CompanyEntity, type ContentsOptions, type ContentsResultComponent, type ContextOptions, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateCriterionParameters, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateImportParameters, CreateImportParametersFormat, type CreateImportResponse, type CreateImportWithCsvParameters, type CreateMonitorParameters, type CreateSearchMonitorParams, type CreateSearchMonitorResponse, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, type CsvDataInput, type CustomEntity, type DeepObjectOutputSchema, type DeepOutputSchema, type DeepSearchOutput, type DeepSearchOutputGrounding, type DeepSearchOutputGroundingCitation, type DeepSearchOutputGroundingConfidence, type DeepSearchType, type DeepTextOutputSchema, type Default, type EnrichmentResult, type Entity, type EntityCompanyProperties, type EntityCompanyPropertiesFinancials, type EntityCompanyPropertiesFundingRound, type EntityCompanyPropertiesHeadquarters, type EntityCompanyPropertiesWebTraffic, type EntityCompanyPropertiesWorkforce, type EntityDateRange, type EntityPersonProperties, type EntityPersonPropertiesCompanyRef, type EntityPersonPropertiesWorkHistoryEntry, type Event, EventType, EventsClient, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type GroundingCitation, type GroundingEntry, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type Import, ImportFailedReason, ImportFormat, ImportObject, ImportStatus, ImportsClient, type JSONSchema, type ListEventsResponse, type ListImportsResponse, type ListMonitorRunsResponse, type ListMonitorsOptions, type ListMonitorsResponse, type ListResearchRequest, type ListResearchResponse, type ListSearchMonitorRunsParams, type ListSearchMonitorRunsResponse, type ListSearchMonitorsParams, type ListSearchMonitorsResponse, type ListWebhookAttemptsResponse, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetItemsOptions, type ListWebsetsResponse, type LivecrawlOptions, type Monitor, type MonitorBehavior, type MonitorCadence, MonitorObject, type MonitorRun, MonitorRunObject, MonitorRunStatus, MonitorRunType, MonitorStatus, type PersonEntity, type PreviewWebsetParameters, type PreviewWebsetResponse, type RegularSearchOptions, type Research, type ResearchCreateParamsTyped, type ResearchCreateRequest, type ResearchCreateResponse, type ResearchDefinitionEvent, type ResearchEvent, type ResearchOperation, type ResearchOutputEvent, type ResearchPaperEntity, type ResearchPlanDefinitionEvent, type ResearchPlanOperationEvent, type ResearchPlanOutputEvent, type ResearchStatus, type ResearchStreamEvent, type ResearchStreamEventTyped, type ResearchTaskDefinitionEvent, type ResearchTaskOperationEvent, type ResearchTaskOutputEvent, type ResearchTyped, type SearchMonitor, type SearchMonitorRun, type SearchMonitorRunFailReason, type SearchMonitorRunOutput, type SearchMonitorRunStatus, SearchMonitorRunsClient, type SearchMonitorSearch, type SearchMonitorStatus, type SearchMonitorTrigger, type SearchMonitorWebhook, type SearchMonitorWebhookEvent, SearchMonitorsClient, type SearchResponse, type SearchResult, type SectionTag, type Status, type SubpagesResponse, type SummaryContentsOptions, type SummaryContentsOptionsTyped, type SummaryResponse, type TextContentsOptions, type TextResponse, type TriggerSearchMonitorResponse, type UpdateEnrichmentParameters, type UpdateImport, type UpdateMonitor, UpdateMonitorStatus, type UpdateSearchMonitorParams, type UpdateWebhookParameters, type UpdateWebsetRequest, type VerbosityOptions, type WaitUntilCompletedOptions, type Webhook, type WebhookAttempt, WebhookStatus, type Webset, type WebsetEnrichment, WebsetEnrichmentFormat, WebsetEnrichmentStatus, WebsetEnrichmentsClient, WebsetExcludeSource, type WebsetHeadersLike, WebsetImportSource, type WebsetItem, type WebsetItemArticleProperties, type WebsetItemCompanyProperties, type WebsetItemCustomProperties, type WebsetItemEvaluation, WebsetItemEvaluationSatisfied, type WebsetItemPersonProperties, type WebsetItemResearchPaperProperties, WebsetItemSource, WebsetItemsClient, WebsetMonitorsClient, type WebsetSearch, WebsetSearchBehavior, WebsetSearchCanceledReason, WebsetSearchScopeSource, WebsetSearchStatus, WebsetSearchesClient, WebsetStatus, WebsetWebhooksClient, WebsetsClient, Exa as default };
|
|
4039
|
+
export { type AnswerOptions, type AnswerOptionsTyped, type AnswerResponse, type AnswerResponseTyped, type AnswerStreamChunk, type AnswerStreamResponse, type ArticleEntity, type BaseSearchOptions, type CompanyEntity, type ContentsOptions, type ContentsResultComponent, type ContextOptions, type CostDollars, type CostDollarsContents, type CostDollarsSeearch, type CreateCriterionParameters, type CreateEnrichmentParameters, CreateEnrichmentParametersFormat, type CreateImportParameters, CreateImportParametersFormat, type CreateImportResponse, type CreateImportWithCsvParameters, type CreateMonitorParameters, type CreateSearchMonitorParams, type CreateSearchMonitorResponse, type CreateWebhookParameters, type CreateWebsetParameters, type CreateWebsetSearchParameters, type CsvDataInput, type CustomEntity, type DeepObjectOutputSchema, type DeepOutputSchema, type DeepSearchOutput, type DeepSearchOutputGrounding, type DeepSearchOutputGroundingCitation, type DeepSearchOutputGroundingConfidence, type DeepSearchType, type DeepTextOutputSchema, type Default, type EnrichmentResult, type Entity, type EntityCompanyProperties, type EntityCompanyPropertiesFinancials, type EntityCompanyPropertiesFundingRound, type EntityCompanyPropertiesHeadquarters, type EntityCompanyPropertiesWebTraffic, type EntityCompanyPropertiesWorkforce, type EntityDateRange, type EntityPersonProperties, type EntityPersonPropertiesCompanyRef, type EntityPersonPropertiesWorkHistoryEntry, type Event, EventType, EventsClient, Exa, ExaError, type ExtrasOptions, type ExtrasResponse, type FindSimilarOptions, type GetWebsetResponse, type GroundingCitation, type GroundingEntry, type HighlightsContentsOptions, type HighlightsResponse, HttpStatusCode, type Import, ImportFailedReason, ImportFormat, ImportObject, ImportStatus, ImportsClient, type JSONSchema, type ListEventsResponse, type ListImportsResponse, type ListMonitorRunsResponse, type ListMonitorsOptions, type ListMonitorsResponse, type ListResearchRequest, type ListResearchResponse, type ListSearchMonitorRunsParams, type ListSearchMonitorRunsResponse, type ListSearchMonitorsParams, type ListSearchMonitorsResponse, type ListWebhookAttemptsResponse, type ListWebhooksResponse, type ListWebsetItemResponse, type ListWebsetItemsOptions, type ListWebsetsResponse, type LivecrawlOptions, type Monitor, type MonitorBehavior, type MonitorCadence, MonitorObject, type MonitorRun, MonitorRunObject, MonitorRunStatus, MonitorRunType, MonitorStatus, type PersonEntity, type PreviewWebsetParameters, type PreviewWebsetResponse, type RegularSearchOptions, type Research, type ResearchCreateParamsTyped, type ResearchCreateRequest, type ResearchCreateResponse, type ResearchDefinitionEvent, type ResearchEvent, type ResearchOperation, type ResearchOutputEvent, type ResearchPaperEntity, type ResearchPlanDefinitionEvent, type ResearchPlanOperationEvent, type ResearchPlanOutputEvent, type ResearchStatus, type ResearchStreamEvent, type ResearchStreamEventTyped, type ResearchTaskDefinitionEvent, type ResearchTaskOperationEvent, type ResearchTaskOutputEvent, type ResearchTyped, type SearchMonitor, type SearchMonitorRun, type SearchMonitorRunFailReason, type SearchMonitorRunOutput, type SearchMonitorRunStatus, SearchMonitorRunsClient, type SearchMonitorSearch, type SearchMonitorStatus, type SearchMonitorTrigger, type SearchMonitorWebhook, type SearchMonitorWebhookEvent, SearchMonitorsClient, type SearchResponse, type SearchResult, type SearchStreamChunk, type SectionTag, type Status, type SubpagesResponse, type SummaryContentsOptions, type SummaryContentsOptionsTyped, type SummaryResponse, type TextContentsOptions, type TextResponse, type TriggerSearchMonitorResponse, type UpdateEnrichmentParameters, type UpdateImport, type UpdateMonitor, UpdateMonitorStatus, type UpdateSearchMonitorParams, type UpdateWebhookParameters, type UpdateWebsetRequest, type VerbosityOptions, type WaitUntilCompletedOptions, type Webhook, type WebhookAttempt, WebhookStatus, type Webset, type WebsetEnrichment, WebsetEnrichmentFormat, WebsetEnrichmentStatus, WebsetEnrichmentsClient, WebsetExcludeSource, type WebsetHeadersLike, WebsetImportSource, type WebsetItem, type WebsetItemArticleProperties, type WebsetItemCompanyProperties, type WebsetItemCustomProperties, type WebsetItemEvaluation, WebsetItemEvaluationSatisfied, type WebsetItemPersonProperties, type WebsetItemResearchPaperProperties, WebsetItemSource, WebsetItemsClient, WebsetMonitorsClient, type WebsetSearch, WebsetSearchBehavior, WebsetSearchCanceledReason, WebsetSearchScopeSource, WebsetSearchStatus, WebsetSearchesClient, WebsetStatus, WebsetWebhooksClient, WebsetsClient, Exa as default };
|
package/dist/index.js
CHANGED
|
@@ -76,7 +76,7 @@ var import_cross_fetch = __toESM(require("cross-fetch"));
|
|
|
76
76
|
// package.json
|
|
77
77
|
var package_default = {
|
|
78
78
|
name: "exa-js",
|
|
79
|
-
version: "2.
|
|
79
|
+
version: "2.12.1",
|
|
80
80
|
description: "Exa SDK for Node.js and the browser",
|
|
81
81
|
publishConfig: {
|
|
82
82
|
access: "public"
|
|
@@ -1671,6 +1671,22 @@ var Exa2 = class {
|
|
|
1671
1671
|
restOptions: rest
|
|
1672
1672
|
};
|
|
1673
1673
|
}
|
|
1674
|
+
buildSearchRequestBody(query, options) {
|
|
1675
|
+
const requestOptions = { ...options ?? {} };
|
|
1676
|
+
delete requestOptions.stream;
|
|
1677
|
+
if (options === void 0 || !("contents" in options)) {
|
|
1678
|
+
return {
|
|
1679
|
+
query,
|
|
1680
|
+
...requestOptions,
|
|
1681
|
+
contents: { text: { maxCharacters: DEFAULT_MAX_CHARACTERS } }
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
if (options.contents === false || options.contents === null || options.contents === void 0) {
|
|
1685
|
+
delete requestOptions.contents;
|
|
1686
|
+
return { query, ...requestOptions };
|
|
1687
|
+
}
|
|
1688
|
+
return { query, ...requestOptions };
|
|
1689
|
+
}
|
|
1674
1690
|
/**
|
|
1675
1691
|
* Constructs the Exa API client.
|
|
1676
1692
|
* @param {string} apiKey - The API key for authentication.
|
|
@@ -1787,18 +1803,29 @@ var Exa2 = class {
|
|
|
1787
1803
|
return response;
|
|
1788
1804
|
}
|
|
1789
1805
|
async search(query, options) {
|
|
1790
|
-
if (options
|
|
1791
|
-
|
|
1792
|
-
query,
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
});
|
|
1796
|
-
}
|
|
1797
|
-
if (options.contents === false || options.contents === null || options.contents === void 0) {
|
|
1798
|
-
const { contents, ...restOptions } = options;
|
|
1799
|
-
return await this.request("/search", "POST", { query, ...restOptions });
|
|
1806
|
+
if (options?.stream) {
|
|
1807
|
+
throw new ExaError(
|
|
1808
|
+
"For streaming responses, please use streamSearch() instead:\n\nfor await (const chunk of exa.streamSearch(query)) {\n // Handle chunks\n}",
|
|
1809
|
+
400 /* BadRequest */
|
|
1810
|
+
);
|
|
1800
1811
|
}
|
|
1801
|
-
return await this.request(
|
|
1812
|
+
return await this.request(
|
|
1813
|
+
"/search",
|
|
1814
|
+
"POST",
|
|
1815
|
+
this.buildSearchRequestBody(query, options)
|
|
1816
|
+
);
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Stream a search response as an async generator of OpenAI-style chat completion chunks.
|
|
1820
|
+
*
|
|
1821
|
+
* Each iteration yields a chunk with partial text (`content`) or new citations.
|
|
1822
|
+
* Use this if you'd like to read synthesized search output incrementally.
|
|
1823
|
+
*/
|
|
1824
|
+
streamSearch(query, options) {
|
|
1825
|
+
return this.streamChatCompletions("/search", {
|
|
1826
|
+
...this.buildSearchRequestBody(query, options),
|
|
1827
|
+
stream: true
|
|
1828
|
+
});
|
|
1802
1829
|
}
|
|
1803
1830
|
/**
|
|
1804
1831
|
* @deprecated Use `search()` instead. The search method now returns text contents by default.
|
|
@@ -1933,11 +1960,10 @@ var Exa2 = class {
|
|
|
1933
1960
|
outputSchema,
|
|
1934
1961
|
userLocation: options?.userLocation
|
|
1935
1962
|
};
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
});
|
|
1963
|
+
yield* this.streamChatCompletions("/answer", body);
|
|
1964
|
+
}
|
|
1965
|
+
async *streamChatCompletions(endpoint, body) {
|
|
1966
|
+
const response = await this.rawRequest(endpoint, "POST", body);
|
|
1941
1967
|
if (!response.ok) {
|
|
1942
1968
|
const message = await response.text();
|
|
1943
1969
|
throw new ExaError(message, response.status, (/* @__PURE__ */ new Date()).toISOString());
|