exa-js 2.10.1 → 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 CHANGED
@@ -50,8 +50,8 @@ const result = await exa.search("interesting articles about space", {
50
50
  ```
51
51
 
52
52
  ```ts
53
- const deepResult = await exa.search("Who leads OpenAI's safety team?", {
54
- type: "deep",
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(deepResult.output?.content);
67
+ console.log(resultWithOutput.output?.content);
68
68
  ```
69
69
 
70
- Deep `outputSchema` modes:
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
- Deep search also supports `systemPrompt` to guide both the search process and the final returned result, for example by preferring certain sources, emphasizing novel findings, avoiding duplicates, or constraining output style.
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"`, deep search currently enforces:
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`: light mode
82
- - `deep-reasoning`: base reasoning mode
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
@@ -16,9 +16,8 @@ interface SearchMonitorSearch {
16
16
  contents?: ContentsOptions;
17
17
  }
18
18
  interface SearchMonitorTrigger {
19
- type: "cron";
20
- expression: string;
21
- timezone?: string;
19
+ type: "interval";
20
+ period: string;
22
21
  }
23
22
  interface SearchMonitorWebhook {
24
23
  url: string;
@@ -3287,6 +3286,7 @@ type ContentsOptions = {
3287
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.
3288
3287
  * @property {string[]} [flags] - Experimental flags
3289
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 })`.
3290
3290
  */
3291
3291
  type BaseSearchOptions = {
3292
3292
  contents?: ContentsOptions;
@@ -3302,6 +3302,7 @@ type BaseSearchOptions = {
3302
3302
  excludeText?: string[];
3303
3303
  flags?: string[];
3304
3304
  userLocation?: string;
3305
+ stream?: boolean;
3305
3306
  };
3306
3307
  /**
3307
3308
  * Base search options shared across all search types
@@ -3312,8 +3313,21 @@ type BaseRegularSearchOptions = BaseSearchOptions & {
3312
3313
  */
3313
3314
  moderation?: boolean;
3314
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;
3315
3329
  };
3316
- type DeepSearchType = "deep" | "deep-reasoning";
3330
+ type DeepSearchType = "deep-lite" | "deep" | "deep-reasoning";
3317
3331
  /**
3318
3332
  * Deep search output schema mode for plain text responses.
3319
3333
  */
@@ -3339,7 +3353,7 @@ type DeepObjectOutputSchema = {
3339
3353
  required?: string[];
3340
3354
  };
3341
3355
  /**
3342
- * Deep search output schema.
3356
+ * Search output schema.
3343
3357
  * - `type: "text"` returns plain text in `output.content` (with optional description guidance).
3344
3358
  * - `type: "object"` returns structured JSON in `output.content`.
3345
3359
  *
@@ -3355,7 +3369,7 @@ type DeepContentsOptions = Omit<ContentsOptions, "context"> & {
3355
3369
  context?: Omit<ContextOptions, never> | true;
3356
3370
  };
3357
3371
  /**
3358
- * Search options for deep search type, which supports additional queries.
3372
+ * Search options for deep search types, which additionally support additional queries.
3359
3373
  */
3360
3374
  type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
3361
3375
  type: DeepSearchType;
@@ -3365,19 +3379,6 @@ type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
3365
3379
  * @example ["machine learning", "ML algorithms", "neural networks"]
3366
3380
  */
3367
3381
  additionalQueries?: string[];
3368
- /**
3369
- * Additional instructions that guide both deep-search planning and the final returned synthesis.
3370
- * Use this to prefer certain sources, emphasize novelty, avoid duplicates, or constrain output style.
3371
- */
3372
- systemPrompt?: string;
3373
- /**
3374
- * Output schema for deep search responses.
3375
- * - `type: "text"` for plain text output (optionally guided by `description`)
3376
- * - `type: "object"` for structured JSON output
3377
- *
3378
- * Note: For object schemas, the API enforces max depth 2 and max 10 total properties.
3379
- */
3380
- outputSchema?: DeepOutputSchema;
3381
3382
  /**
3382
3383
  * Options for retrieving page contents.
3383
3384
  */
@@ -3688,7 +3689,7 @@ type DeepSearchOutput = {
3688
3689
  * @typedef {Object} SearchResponse
3689
3690
  * @property {Result[]} results - The list of search results.
3690
3691
  * @property {string} [context] - Deprecated. The context for the search.
3691
- * @property {DeepSearchOutput} [output] - Deep search synthesized output object with `content` and `grounding`.
3692
+ * @property {DeepSearchOutput} [output] - Search synthesized output object returned when `outputSchema` is provided.
3692
3693
  * @property {string} [autoDate] - The autoprompt date, if applicable.
3693
3694
  * @property {string} requestId - The request ID for the search.
3694
3695
  * @property {CostDollars} [costDollars] - The cost breakdown for this request.
@@ -3760,6 +3761,7 @@ type AnswerStreamChunk = {
3760
3761
  text?: string;
3761
3762
  }>;
3762
3763
  };
3764
+ type SearchStreamChunk = AnswerStreamChunk;
3763
3765
  /**
3764
3766
  * Represents a streaming answer response chunk from the /answer endpoint.
3765
3767
  * @typedef {Object} AnswerStreamResponse
@@ -3810,6 +3812,7 @@ declare class Exa {
3810
3812
  * Helper method to separate out the contents-specific options from the rest.
3811
3813
  */
3812
3814
  private extractContentsOptions;
3815
+ private buildSearchRequestBody;
3813
3816
  /**
3814
3817
  * Constructs the Exa API client.
3815
3818
  * @param {string} apiKey - The API key for authentication.
@@ -3870,6 +3873,15 @@ declare class Exa {
3870
3873
  search(query: string, options: Omit<DeepSearchOptions, "contents"> | Omit<NonDeepSearchOptions, "contents">): Promise<SearchResponse<{
3871
3874
  text: true;
3872
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>;
3873
3885
  /**
3874
3886
  * @deprecated Use `search()` instead. The search method now returns text contents by default.
3875
3887
  *
@@ -4013,8 +4025,9 @@ declare class Exa {
4013
4025
  outputSchema?: Record<string, unknown>;
4014
4026
  userLocation?: string;
4015
4027
  }): AsyncGenerator<AnswerStreamChunk>;
4028
+ private streamChatCompletions;
4016
4029
  private processChunk;
4017
4030
  private parseSSEStream;
4018
4031
  }
4019
4032
 
4020
- 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
@@ -16,9 +16,8 @@ interface SearchMonitorSearch {
16
16
  contents?: ContentsOptions;
17
17
  }
18
18
  interface SearchMonitorTrigger {
19
- type: "cron";
20
- expression: string;
21
- timezone?: string;
19
+ type: "interval";
20
+ period: string;
22
21
  }
23
22
  interface SearchMonitorWebhook {
24
23
  url: string;
@@ -3287,6 +3286,7 @@ type ContentsOptions = {
3287
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.
3288
3287
  * @property {string[]} [flags] - Experimental flags
3289
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 })`.
3290
3290
  */
3291
3291
  type BaseSearchOptions = {
3292
3292
  contents?: ContentsOptions;
@@ -3302,6 +3302,7 @@ type BaseSearchOptions = {
3302
3302
  excludeText?: string[];
3303
3303
  flags?: string[];
3304
3304
  userLocation?: string;
3305
+ stream?: boolean;
3305
3306
  };
3306
3307
  /**
3307
3308
  * Base search options shared across all search types
@@ -3312,8 +3313,21 @@ type BaseRegularSearchOptions = BaseSearchOptions & {
3312
3313
  */
3313
3314
  moderation?: boolean;
3314
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;
3315
3329
  };
3316
- type DeepSearchType = "deep" | "deep-reasoning";
3330
+ type DeepSearchType = "deep-lite" | "deep" | "deep-reasoning";
3317
3331
  /**
3318
3332
  * Deep search output schema mode for plain text responses.
3319
3333
  */
@@ -3339,7 +3353,7 @@ type DeepObjectOutputSchema = {
3339
3353
  required?: string[];
3340
3354
  };
3341
3355
  /**
3342
- * Deep search output schema.
3356
+ * Search output schema.
3343
3357
  * - `type: "text"` returns plain text in `output.content` (with optional description guidance).
3344
3358
  * - `type: "object"` returns structured JSON in `output.content`.
3345
3359
  *
@@ -3355,7 +3369,7 @@ type DeepContentsOptions = Omit<ContentsOptions, "context"> & {
3355
3369
  context?: Omit<ContextOptions, never> | true;
3356
3370
  };
3357
3371
  /**
3358
- * Search options for deep search type, which supports additional queries.
3372
+ * Search options for deep search types, which additionally support additional queries.
3359
3373
  */
3360
3374
  type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
3361
3375
  type: DeepSearchType;
@@ -3365,19 +3379,6 @@ type DeepSearchOptions = Omit<BaseRegularSearchOptions, "contents"> & {
3365
3379
  * @example ["machine learning", "ML algorithms", "neural networks"]
3366
3380
  */
3367
3381
  additionalQueries?: string[];
3368
- /**
3369
- * Additional instructions that guide both deep-search planning and the final returned synthesis.
3370
- * Use this to prefer certain sources, emphasize novelty, avoid duplicates, or constrain output style.
3371
- */
3372
- systemPrompt?: string;
3373
- /**
3374
- * Output schema for deep search responses.
3375
- * - `type: "text"` for plain text output (optionally guided by `description`)
3376
- * - `type: "object"` for structured JSON output
3377
- *
3378
- * Note: For object schemas, the API enforces max depth 2 and max 10 total properties.
3379
- */
3380
- outputSchema?: DeepOutputSchema;
3381
3382
  /**
3382
3383
  * Options for retrieving page contents.
3383
3384
  */
@@ -3688,7 +3689,7 @@ type DeepSearchOutput = {
3688
3689
  * @typedef {Object} SearchResponse
3689
3690
  * @property {Result[]} results - The list of search results.
3690
3691
  * @property {string} [context] - Deprecated. The context for the search.
3691
- * @property {DeepSearchOutput} [output] - Deep search synthesized output object with `content` and `grounding`.
3692
+ * @property {DeepSearchOutput} [output] - Search synthesized output object returned when `outputSchema` is provided.
3692
3693
  * @property {string} [autoDate] - The autoprompt date, if applicable.
3693
3694
  * @property {string} requestId - The request ID for the search.
3694
3695
  * @property {CostDollars} [costDollars] - The cost breakdown for this request.
@@ -3760,6 +3761,7 @@ type AnswerStreamChunk = {
3760
3761
  text?: string;
3761
3762
  }>;
3762
3763
  };
3764
+ type SearchStreamChunk = AnswerStreamChunk;
3763
3765
  /**
3764
3766
  * Represents a streaming answer response chunk from the /answer endpoint.
3765
3767
  * @typedef {Object} AnswerStreamResponse
@@ -3810,6 +3812,7 @@ declare class Exa {
3810
3812
  * Helper method to separate out the contents-specific options from the rest.
3811
3813
  */
3812
3814
  private extractContentsOptions;
3815
+ private buildSearchRequestBody;
3813
3816
  /**
3814
3817
  * Constructs the Exa API client.
3815
3818
  * @param {string} apiKey - The API key for authentication.
@@ -3870,6 +3873,15 @@ declare class Exa {
3870
3873
  search(query: string, options: Omit<DeepSearchOptions, "contents"> | Omit<NonDeepSearchOptions, "contents">): Promise<SearchResponse<{
3871
3874
  text: true;
3872
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>;
3873
3885
  /**
3874
3886
  * @deprecated Use `search()` instead. The search method now returns text contents by default.
3875
3887
  *
@@ -4013,8 +4025,9 @@ declare class Exa {
4013
4025
  outputSchema?: Record<string, unknown>;
4014
4026
  userLocation?: string;
4015
4027
  }): AsyncGenerator<AnswerStreamChunk>;
4028
+ private streamChatCompletions;
4016
4029
  private processChunk;
4017
4030
  private parseSSEStream;
4018
4031
  }
4019
4032
 
4020
- 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.10.1",
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 === void 0 || !("contents" in options)) {
1791
- return await this.request("/search", "POST", {
1792
- query,
1793
- ...options,
1794
- contents: { text: { maxCharacters: DEFAULT_MAX_CHARACTERS } }
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("/search", "POST", { query, ...options });
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
- const response = await fetchImpl(this.baseURL + "/answer", {
1937
- method: "POST",
1938
- headers: this.headers,
1939
- body: JSON.stringify(body)
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());