exa-js 2.10.2 → 2.11.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.
- package/README.md +21 -9
- package/dist/index.d.mts +32 -18
- package/dist/index.d.ts +32 -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/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
|
@@ -3286,6 +3286,7 @@ type ContentsOptions = {
|
|
|
3286
3286
|
* @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
3287
|
* @property {string[]} [flags] - Experimental flags
|
|
3288
3288
|
* @property {string} [userLocation] - The two-letter ISO country code of the user, e.g. US.
|
|
3289
|
+
* @property {boolean} [stream] - Whether to stream back OpenAI-style chat completion chunks. Use `streamSearch()` instead of `search({ stream: true })`.
|
|
3289
3290
|
*/
|
|
3290
3291
|
type BaseSearchOptions = {
|
|
3291
3292
|
contents?: ContentsOptions;
|
|
@@ -3301,6 +3302,7 @@ type BaseSearchOptions = {
|
|
|
3301
3302
|
excludeText?: string[];
|
|
3302
3303
|
flags?: string[];
|
|
3303
3304
|
userLocation?: string;
|
|
3305
|
+
stream?: boolean;
|
|
3304
3306
|
};
|
|
3305
3307
|
/**
|
|
3306
3308
|
* Base search options shared across all search types
|
|
@@ -3311,8 +3313,21 @@ type BaseRegularSearchOptions = BaseSearchOptions & {
|
|
|
3311
3313
|
*/
|
|
3312
3314
|
moderation?: boolean;
|
|
3313
3315
|
useAutoprompt?: boolean;
|
|
3316
|
+
/**
|
|
3317
|
+
* Additional instructions that guide both the search process and the final returned synthesis.
|
|
3318
|
+
* Use this to prefer certain sources, emphasize novelty, avoid duplicates, or constrain output style.
|
|
3319
|
+
*/
|
|
3320
|
+
systemPrompt?: string;
|
|
3321
|
+
/**
|
|
3322
|
+
* Output schema for search responses. When provided, the API returns synthesized output in `output`.
|
|
3323
|
+
* - `type: "text"` for plain text output (optionally guided by `description`)
|
|
3324
|
+
* - `type: "object"` for structured JSON output
|
|
3325
|
+
*
|
|
3326
|
+
* Note: For object schemas, the API enforces max depth 2 and max 10 total properties.
|
|
3327
|
+
*/
|
|
3328
|
+
outputSchema?: DeepOutputSchema;
|
|
3314
3329
|
};
|
|
3315
|
-
type DeepSearchType = "deep" | "deep-reasoning";
|
|
3330
|
+
type DeepSearchType = "deep-lite" | "deep" | "deep-reasoning";
|
|
3316
3331
|
/**
|
|
3317
3332
|
* Deep search output schema mode for plain text responses.
|
|
3318
3333
|
*/
|
|
@@ -3338,7 +3353,7 @@ type DeepObjectOutputSchema = {
|
|
|
3338
3353
|
required?: string[];
|
|
3339
3354
|
};
|
|
3340
3355
|
/**
|
|
3341
|
-
*
|
|
3356
|
+
* Search output schema.
|
|
3342
3357
|
* - `type: "text"` returns plain text in `output.content` (with optional description guidance).
|
|
3343
3358
|
* - `type: "object"` returns structured JSON in `output.content`.
|
|
3344
3359
|
*
|
|
@@ -3354,7 +3369,7 @@ type DeepContentsOptions = Omit<ContentsOptions, "context"> & {
|
|
|
3354
3369
|
context?: Omit<ContextOptions, never> | true;
|
|
3355
3370
|
};
|
|
3356
3371
|
/**
|
|
3357
|
-
* Search options for deep search
|
|
3372
|
+
* Search options for deep search types, which additionally support additional queries.
|
|
3358
3373
|
*/
|
|
3359
3374
|
type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
|
|
3360
3375
|
type: DeepSearchType;
|
|
@@ -3364,19 +3379,6 @@ type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
|
|
|
3364
3379
|
* @example ["machine learning", "ML algorithms", "neural networks"]
|
|
3365
3380
|
*/
|
|
3366
3381
|
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
3382
|
/**
|
|
3381
3383
|
* Options for retrieving page contents.
|
|
3382
3384
|
*/
|
|
@@ -3687,7 +3689,7 @@ type DeepSearchOutput = {
|
|
|
3687
3689
|
* @typedef {Object} SearchResponse
|
|
3688
3690
|
* @property {Result[]} results - The list of search results.
|
|
3689
3691
|
* @property {string} [context] - Deprecated. The context for the search.
|
|
3690
|
-
* @property {DeepSearchOutput} [output] -
|
|
3692
|
+
* @property {DeepSearchOutput} [output] - Search synthesized output object returned when `outputSchema` is provided.
|
|
3691
3693
|
* @property {string} [autoDate] - The autoprompt date, if applicable.
|
|
3692
3694
|
* @property {string} requestId - The request ID for the search.
|
|
3693
3695
|
* @property {CostDollars} [costDollars] - The cost breakdown for this request.
|
|
@@ -3759,6 +3761,7 @@ type AnswerStreamChunk = {
|
|
|
3759
3761
|
text?: string;
|
|
3760
3762
|
}>;
|
|
3761
3763
|
};
|
|
3764
|
+
type SearchStreamChunk = AnswerStreamChunk;
|
|
3762
3765
|
/**
|
|
3763
3766
|
* Represents a streaming answer response chunk from the /answer endpoint.
|
|
3764
3767
|
* @typedef {Object} AnswerStreamResponse
|
|
@@ -3809,6 +3812,7 @@ declare class Exa {
|
|
|
3809
3812
|
* Helper method to separate out the contents-specific options from the rest.
|
|
3810
3813
|
*/
|
|
3811
3814
|
private extractContentsOptions;
|
|
3815
|
+
private buildSearchRequestBody;
|
|
3812
3816
|
/**
|
|
3813
3817
|
* Constructs the Exa API client.
|
|
3814
3818
|
* @param {string} apiKey - The API key for authentication.
|
|
@@ -3869,6 +3873,15 @@ declare class Exa {
|
|
|
3869
3873
|
search(query: string, options: Omit<DeepSearchOptions, "contents"> | Omit<NonDeepSearchOptions, "contents">): Promise<SearchResponse<{
|
|
3870
3874
|
text: true;
|
|
3871
3875
|
}>>;
|
|
3876
|
+
/**
|
|
3877
|
+
* Stream a search response as an async generator of OpenAI-style chat completion chunks.
|
|
3878
|
+
*
|
|
3879
|
+
* Each iteration yields a chunk with partial text (`content`) or new citations.
|
|
3880
|
+
* Use this if you'd like to read synthesized search output incrementally.
|
|
3881
|
+
*/
|
|
3882
|
+
streamSearch(query: string, options?: RegularSearchOptions & {
|
|
3883
|
+
contents?: ContentsOptions | false | null | undefined;
|
|
3884
|
+
}): AsyncGenerator<SearchStreamChunk>;
|
|
3872
3885
|
/**
|
|
3873
3886
|
* @deprecated Use `search()` instead. The search method now returns text contents by default.
|
|
3874
3887
|
*
|
|
@@ -4012,8 +4025,9 @@ declare class Exa {
|
|
|
4012
4025
|
outputSchema?: Record<string, unknown>;
|
|
4013
4026
|
userLocation?: string;
|
|
4014
4027
|
}): AsyncGenerator<AnswerStreamChunk>;
|
|
4028
|
+
private streamChatCompletions;
|
|
4015
4029
|
private processChunk;
|
|
4016
4030
|
private parseSSEStream;
|
|
4017
4031
|
}
|
|
4018
4032
|
|
|
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 };
|
|
4033
|
+
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
|
@@ -3286,6 +3286,7 @@ type ContentsOptions = {
|
|
|
3286
3286
|
* @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
3287
|
* @property {string[]} [flags] - Experimental flags
|
|
3288
3288
|
* @property {string} [userLocation] - The two-letter ISO country code of the user, e.g. US.
|
|
3289
|
+
* @property {boolean} [stream] - Whether to stream back OpenAI-style chat completion chunks. Use `streamSearch()` instead of `search({ stream: true })`.
|
|
3289
3290
|
*/
|
|
3290
3291
|
type BaseSearchOptions = {
|
|
3291
3292
|
contents?: ContentsOptions;
|
|
@@ -3301,6 +3302,7 @@ type BaseSearchOptions = {
|
|
|
3301
3302
|
excludeText?: string[];
|
|
3302
3303
|
flags?: string[];
|
|
3303
3304
|
userLocation?: string;
|
|
3305
|
+
stream?: boolean;
|
|
3304
3306
|
};
|
|
3305
3307
|
/**
|
|
3306
3308
|
* Base search options shared across all search types
|
|
@@ -3311,8 +3313,21 @@ type BaseRegularSearchOptions = BaseSearchOptions & {
|
|
|
3311
3313
|
*/
|
|
3312
3314
|
moderation?: boolean;
|
|
3313
3315
|
useAutoprompt?: boolean;
|
|
3316
|
+
/**
|
|
3317
|
+
* Additional instructions that guide both the search process and the final returned synthesis.
|
|
3318
|
+
* Use this to prefer certain sources, emphasize novelty, avoid duplicates, or constrain output style.
|
|
3319
|
+
*/
|
|
3320
|
+
systemPrompt?: string;
|
|
3321
|
+
/**
|
|
3322
|
+
* Output schema for search responses. When provided, the API returns synthesized output in `output`.
|
|
3323
|
+
* - `type: "text"` for plain text output (optionally guided by `description`)
|
|
3324
|
+
* - `type: "object"` for structured JSON output
|
|
3325
|
+
*
|
|
3326
|
+
* Note: For object schemas, the API enforces max depth 2 and max 10 total properties.
|
|
3327
|
+
*/
|
|
3328
|
+
outputSchema?: DeepOutputSchema;
|
|
3314
3329
|
};
|
|
3315
|
-
type DeepSearchType = "deep" | "deep-reasoning";
|
|
3330
|
+
type DeepSearchType = "deep-lite" | "deep" | "deep-reasoning";
|
|
3316
3331
|
/**
|
|
3317
3332
|
* Deep search output schema mode for plain text responses.
|
|
3318
3333
|
*/
|
|
@@ -3338,7 +3353,7 @@ type DeepObjectOutputSchema = {
|
|
|
3338
3353
|
required?: string[];
|
|
3339
3354
|
};
|
|
3340
3355
|
/**
|
|
3341
|
-
*
|
|
3356
|
+
* Search output schema.
|
|
3342
3357
|
* - `type: "text"` returns plain text in `output.content` (with optional description guidance).
|
|
3343
3358
|
* - `type: "object"` returns structured JSON in `output.content`.
|
|
3344
3359
|
*
|
|
@@ -3354,7 +3369,7 @@ type DeepContentsOptions = Omit<ContentsOptions, "context"> & {
|
|
|
3354
3369
|
context?: Omit<ContextOptions, never> | true;
|
|
3355
3370
|
};
|
|
3356
3371
|
/**
|
|
3357
|
-
* Search options for deep search
|
|
3372
|
+
* Search options for deep search types, which additionally support additional queries.
|
|
3358
3373
|
*/
|
|
3359
3374
|
type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
|
|
3360
3375
|
type: DeepSearchType;
|
|
@@ -3364,19 +3379,6 @@ type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
|
|
|
3364
3379
|
* @example ["machine learning", "ML algorithms", "neural networks"]
|
|
3365
3380
|
*/
|
|
3366
3381
|
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
3382
|
/**
|
|
3381
3383
|
* Options for retrieving page contents.
|
|
3382
3384
|
*/
|
|
@@ -3687,7 +3689,7 @@ type DeepSearchOutput = {
|
|
|
3687
3689
|
* @typedef {Object} SearchResponse
|
|
3688
3690
|
* @property {Result[]} results - The list of search results.
|
|
3689
3691
|
* @property {string} [context] - Deprecated. The context for the search.
|
|
3690
|
-
* @property {DeepSearchOutput} [output] -
|
|
3692
|
+
* @property {DeepSearchOutput} [output] - Search synthesized output object returned when `outputSchema` is provided.
|
|
3691
3693
|
* @property {string} [autoDate] - The autoprompt date, if applicable.
|
|
3692
3694
|
* @property {string} requestId - The request ID for the search.
|
|
3693
3695
|
* @property {CostDollars} [costDollars] - The cost breakdown for this request.
|
|
@@ -3759,6 +3761,7 @@ type AnswerStreamChunk = {
|
|
|
3759
3761
|
text?: string;
|
|
3760
3762
|
}>;
|
|
3761
3763
|
};
|
|
3764
|
+
type SearchStreamChunk = AnswerStreamChunk;
|
|
3762
3765
|
/**
|
|
3763
3766
|
* Represents a streaming answer response chunk from the /answer endpoint.
|
|
3764
3767
|
* @typedef {Object} AnswerStreamResponse
|
|
@@ -3809,6 +3812,7 @@ declare class Exa {
|
|
|
3809
3812
|
* Helper method to separate out the contents-specific options from the rest.
|
|
3810
3813
|
*/
|
|
3811
3814
|
private extractContentsOptions;
|
|
3815
|
+
private buildSearchRequestBody;
|
|
3812
3816
|
/**
|
|
3813
3817
|
* Constructs the Exa API client.
|
|
3814
3818
|
* @param {string} apiKey - The API key for authentication.
|
|
@@ -3869,6 +3873,15 @@ declare class Exa {
|
|
|
3869
3873
|
search(query: string, options: Omit<DeepSearchOptions, "contents"> | Omit<NonDeepSearchOptions, "contents">): Promise<SearchResponse<{
|
|
3870
3874
|
text: true;
|
|
3871
3875
|
}>>;
|
|
3876
|
+
/**
|
|
3877
|
+
* Stream a search response as an async generator of OpenAI-style chat completion chunks.
|
|
3878
|
+
*
|
|
3879
|
+
* Each iteration yields a chunk with partial text (`content`) or new citations.
|
|
3880
|
+
* Use this if you'd like to read synthesized search output incrementally.
|
|
3881
|
+
*/
|
|
3882
|
+
streamSearch(query: string, options?: RegularSearchOptions & {
|
|
3883
|
+
contents?: ContentsOptions | false | null | undefined;
|
|
3884
|
+
}): AsyncGenerator<SearchStreamChunk>;
|
|
3872
3885
|
/**
|
|
3873
3886
|
* @deprecated Use `search()` instead. The search method now returns text contents by default.
|
|
3874
3887
|
*
|
|
@@ -4012,8 +4025,9 @@ declare class Exa {
|
|
|
4012
4025
|
outputSchema?: Record<string, unknown>;
|
|
4013
4026
|
userLocation?: string;
|
|
4014
4027
|
}): AsyncGenerator<AnswerStreamChunk>;
|
|
4028
|
+
private streamChatCompletions;
|
|
4015
4029
|
private processChunk;
|
|
4016
4030
|
private parseSSEStream;
|
|
4017
4031
|
}
|
|
4018
4032
|
|
|
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 };
|
|
4033
|
+
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.11.0",
|
|
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());
|