Skip to main content

Getting started

Install the exa-js SDK
npm install exa-js
and then instantiate an Exa client
import Exa from "exa-js";

const exa = new Exa();  // Reads EXA_API_KEY from environment
// or explicitly: const exa = new Exa("your-api-key");

Get API Key

Follow this link to get your API key

search Method

The options.type parameter accepts: "auto" (default), "fast", "deep", or "neural". See RegularSearchOptions for all available options.

Input Example

const result = await exa.search("hottest AI startups", {
  numResults: 10
});

Input Parameters

ParameterTypeDescriptionDefault
querystring-Required
optionsRegularSearchOptions & { contents?: T | false | null | undefined }-Required

Return Example

{
  "autopromptString": "Here is a link to one of the hottest AI startups:",
  "results": [
    {
      "title": "Adept: Useful General Intelligence",
      "id": "https://www.adept.ai/",
      "url": "https://www.adept.ai/",
      "publishedDate": "2000-01-01",
      "author": null,
      "text": "Adept is building AI that can automate any software process..."
    }
  ],
  "requestId": "a78ebce717f4d712b6f8fe0d5d7753f8"
}

Result Object

FieldTypeDescription
resultsSearchResult<T>[]The list of search results.
requestIdstringThe request ID for the search.
contextstringThe context for the search (for deep search).
autoDatestringThe autoprompt date, if applicable.
statusesStatus[]Status information for each result.
costDollarsCostDollarsThe cost breakdown for this request.

searchAndContents Method

The options.type parameter accepts: "auto" (default), "fast", "deep", or "neural". See RegularSearchOptions for all available options.

Input Example

const result = await exa.searchAndContents("AI in healthcare", {
  text: true,
  highlights: true,
  numResults: 5
});

Input Parameters

ParameterTypeDescriptionDefault
querystringThe query string. *Required
optionsRegularSearchOptions & T-Required

Return Example

{
  "results": [
    {
      "title": "2023 AI Trends in Health Care",
      "id": "https://aibusiness.com/verticals/2023-ai-trends-in-health-care-",
      "url": "https://aibusiness.com/verticals/2023-ai-trends-in-health-care-",
      "publishedDate": "2022-12-29",
      "author": "Wylie Wong",
      "text": "While the health care industry was initially slow to adopt AI...",
      "highlights": [
        "AI is transforming healthcare through improved diagnostics and personalized treatment plans."
      ],
      "highlightScores": [
        0.85
      ]
    }
  ],
  "requestId": "b89fcd823e4f5a91c7d0fe1e6e8864f9"
}

Result Object

FieldTypeDescription
resultsSearchResult<T>[]The list of search results.
requestIdstringThe request ID for the search.
contextstringThe context for the search (for deep search).
autoDatestringThe autoprompt date, if applicable.
statusesStatus[]Status information for each result.
costDollarsCostDollarsThe cost breakdown for this request.

findSimilar Method

See FindSimilarOptions for all available options including excludeSourceDomain.

Input Example

const result = await exa.findSimilar("https://www.example.com/article", {
  numResults: 10,
  excludeSourceDomain: true
});

Input Parameters

ParameterTypeDescriptionDefault
urlstring-Required
optionsFindSimilarOptions & { contents?: T | false | null | undefined }-Required

Return Example

{
  "results": [
    {
      "title": "Similar Article: AI and Machine Learning",
      "id": "https://www.similarsite.com/ai-ml-article",
      "url": "https://www.similarsite.com/ai-ml-article",
      "publishedDate": "2023-05-15",
      "author": "Jane Doe",
      "text": "Artificial Intelligence (AI) and Machine Learning (ML) are revolutionizing various industries..."
    }
  ],
  "requestId": "08fdc6f20e9f3ea87f860af3f6ccc30f"
}

Result Object

FieldTypeDescription
resultsSearchResult<T>[]The list of search results.
requestIdstringThe request ID for the search.
contextstringThe context for the search (for deep search).
autoDatestringThe autoprompt date, if applicable.
statusesStatus[]Status information for each result.
costDollarsCostDollarsThe cost breakdown for this request.

findSimilarAndContents Method

See FindSimilarOptions for all available options including excludeSourceDomain.

Input Example

const result = await exa.findSimilarAndContents("https://www.example.com/article", {
  text: true,
  highlights: true,
  numResults: 5
});

Input Parameters

ParameterTypeDescriptionDefault
urlstringThe URL for which to find similar links. *Required
optionsFindSimilarOptions & T-Required

Return Example

{
  "results": [
    {
      "title": "The Impact of AI on Modern Technology",
      "id": "https://www.techblog.com/ai-impact",
      "url": "https://www.techblog.com/ai-impact",
      "publishedDate": "2023-06-01",
      "author": "John Smith",
      "text": "In recent years, artificial intelligence has made significant strides...",
      "highlights": [
        "AI is reshaping industries and creating new opportunities for innovation."
      ],
      "highlightScores": [
        0.92
      ]
    }
  ],
  "requestId": "c90gde934f5g6b02d8e1gf2f7f9975g0"
}

Result Object

FieldTypeDescription
resultsSearchResult<T>[]The list of search results.
requestIdstringThe request ID for the search.
contextstringThe context for the search (for deep search).
autoDatestringThe autoprompt date, if applicable.
statusesStatus[]Status information for each result.
costDollarsCostDollarsThe cost breakdown for this request.

getContents Method

Retrieves contents of documents based on URLs.

Input Example

const result = await exa.getContents([
  "https://www.example.com/article1",
  "https://www.example.com/article2"
], {
  text: { maxCharacters: 1000 },
  highlights: { query: "AI", numSentences: 2 }
});

Input Parameters

ParameterTypeDescriptionDefault
urlsstring | string[] | SearchResult<T>[]A URL or array of URLs, or an array of SearchResult objects. *Required
optionsT-Required

Return Example

{
  "results": [
    {
      "url": "https://example.com/article",
      "id": "https://example.com/article",
      "title": "Example Article",
      "text": "The full text content of the article..."
    }
  ]
}

Result Object

FieldTypeDescription
resultsSearchResult<T>[]The list of search results.
requestIdstringThe request ID for the search.
contextstringThe context for the search (for deep search).
autoDatestringThe autoprompt date, if applicable.
statusesStatus[]Status information for each result.
costDollarsCostDollarsThe cost breakdown for this request.

answer Method

Input Example

const result = await exa.answer("What is the capital of France?", {
  text: true,
  model: "exa"
});

Input Parameters

ParameterTypeDescriptionDefault
querystring-Required
optionsAnswerOptions | AnswerOptionsTyped&lt;ZodSchema<T&gt;>-Required

Return Example

{
  "answer": "The capital of France is Paris.",
  "citations": [
    {
      "id": "https://www.example.com/france",
      "url": "https://www.example.com/france",
      "title": "France - Wikipedia",
      "publishedDate": "2023-01-01",
      "author": null,
      "text": "France, officially the French Republic, is a country in... [truncated for brevity]"
    }
  ],
  "requestId": "abc123"
}

Result Object

FieldTypeDescription
answerstring | Record&lt;string, unknown&gt;The generated answer text (or object matching outputSchema if provided).
citationsSearchResult&lt;{}&gt;[]The sources used to generate the answer.
requestIdstringThe request ID for the answer.
costDollarsCostDollarsThe cost breakdown for this request.

streamAnswer Method

Input Example

for await (const chunk of exa.streamAnswer("What is quantum computing?", {
  text: true,
  model: "exa"
})) {
  if (chunk.content) process.stdout.write(chunk.content);
  if (chunk.citations) console.log("Citations:", chunk.citations);
}

Input Parameters

ParameterTypeDescriptionDefault
querystring-Required
options{ text?: boolean; model?: "exa" | "exa-pro"; systemPrompt?: string; outputSchema?: Record&lt;string, unknown&gt; | ZodSchema&lt;T&gt;; }-Required

Return Example

{
  "content": "The capital of France is Paris.",
  "citations": [
    {
      "id": "https://www.example.com/france",
      "url": "https://www.example.com/france",
      "title": "France - Wikipedia"
    }
  ]
}

Result Object

FieldTypeDescription
contentstringThe partial text content of the answer (if present in this chunk).
citationsArray&lt;{id, url, title?, publishedDate?, author?, text?}&gt;Citations associated with the current chunk of text (if present).

research.create Method

Input Example

const task = await exa.research.create({
  instructions: "Research the latest AI developments",
  model: "exa-research-fast"
});

Input Parameters

ParameterTypeDescriptionDefault
params{ instructions: string; model?: ResearchCreateRequest["model"]; outputSchema?: Record&lt;string, unknown&gt; | ZodSchema&lt;T&gt;; }-Required

Return Example

{
  "researchId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "status": "pending"
}

research.get Method

When called with stream: true, returns an AsyncGenerator<ResearchStreamEvent> for real-time SSE updates instead of a Promise<Research>.

Input Example

const result = await exa.research.get("a1b2c3d4-e5f6-7890-abcd-ef1234567890");

Input Parameters

ParameterTypeDescriptionDefault
researchIdstring-Required
options{ stream?: boolean; events?: boolean; outputSchema?: ZodSchema&lt;T&gt;; }-Required

Return Example

{
  "researchId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "status": "completed",
  "instructions": "What is the latest valuation of SpaceX?",
  "output": {
    "parsed": {
      "valuation": "$350 billion",
      "date": "December 2024",
      "source": "Financial Times"
    }
  }
}

research.pollUntilFinished Method

Options include pollInterval (default 1000ms), timeoutMs (default 10 minutes), and events (boolean to include event log).

Input Example

const result = await exa.research.pollUntilFinished("a1b2c3d4-e5f6-7890-abcd-ef1234567890", {
  pollInterval: 1000,
  timeoutMs: 600000
});

Input Parameters

ParameterTypeDescriptionDefault
researchIdstring-Required
options{ pollInterval?: number; timeoutMs?: number; events?: boolean; outputSchema?: ZodSchema&lt;T&gt;; }-Required

research.list Method

Input Example

const tasks = await exa.research.list({ limit: 10 });

Input Parameters

ParameterTypeDescriptionDefault
optionsListResearchRequest-Required

Return Example

{
  "data": [
    {
      "researchId": "task-1",
      "status": "completed",
      "instructions": "Research SpaceX valuation"
    }
  ],
  "hasMore": true,
  "nextCursor": "eyJjcmVhdGVkQXQiOiIyMDI0LTAxLTE1VDE4OjMwOjAwWiIsImlkIjoidGFzay0yIn0="
}

Types Reference

This section documents the types used throughout the SDK.

Content Options

These types configure content retrieval options for the contents parameter.

ContentsOptions

Options for retrieving page contents
FieldTypeDescription
textTextContentsOptions | trueOptions for retrieving text contents.
highlightsHighlightsContentsOptions | trueOptions for retrieving highlights.
summarySummaryContentsOptions | trueOptions for retrieving summary.
maxAgeHoursnumberMaximum age of cached content in hours. If content is older, it will be fetched fresh. Special values: 0 = always fetch fresh content, -1 = never fetch fresh (cache only). Example: 168 = fetch fresh for pages older than 7 days.
filterEmptyResultsbooleanIf true, filters out results with no contents. Default is true.
subpagesnumberNumber of subpages to return for each result.
subpageTargetstring | string[]Text used to match/rank subpages in the returned list.
extrasExtrasOptionsMiscellaneous data derived from results.
contextContextOptions | trueOptions for retrieving context.

BaseSearchOptions

Options for performing a search query
FieldTypeDescription
contentsContentsOptions-
numResultsnumber-
includeDomainsstring[]-
excludeDomainsstring[]-
startCrawlDatestring-
endCrawlDatestring-
startPublishedDatestring-
endPublishedDatestring-
category| "company" | "research paper" | "news" | "pdf" | "tweet" | "personal site" | "financial report" | "people"-
includeTextstring[]-
excludeTextstring[]-
flagsstring[]-
userLocationstring-

RegularSearchOptions

Search options for performing a search query. Uses a discriminated union to ensure additionalQueries is only allowed when type is “deep”.
FieldTypeDescription
type"auto" | "fast" | "deep" | "neural"The type of search to perform. Default is “auto”.
numResultsnumberNumber of search results to return. Default 10. Max 10 for basic plans.
includeDomainsstring[]List of domains to include in the search.
excludeDomainsstring[]List of domains to exclude in the search.
startCrawlDatestringStart date for results based on crawl date (ISO format).
endCrawlDatestringEnd date for results based on crawl date (ISO format).
startPublishedDatestringStart date for results based on published date (ISO format).
endPublishedDatestringEnd date for results based on published date (ISO format).
category"company" | "research paper" | "news" | "pdf" | "tweet" | "personal site" | "financial report" | "people"A data category to focus on.
includeTextstring[]List of strings that must be present in webpage text. Max 1 string of up to 5 words.
excludeTextstring[]List of strings that must not be present in webpage text. Max 1 string of up to 5 words.
contentsContentsOptionsOptions for retrieving page contents for each result.
moderationbooleanIf true, the search results are moderated for safety.
useAutopromptbooleanIf true, uses autoprompt to enhance the query.
userLocationstringThe two-letter ISO country code of the user, e.g. US.
additionalQueriesstring[]Alternative query formulations for deep search. Max 5 queries. Only for type: “deep”.

FindSimilarOptions

Options for finding similar links. Type: BaseSearchOptions & { excludeSourceDomain?: boolean; }

ExtrasOptions

FieldTypeDescription
linksnumber-
imageLinksnumber-

TextContentsOptions

Options for retrieving text from page.
FieldTypeDescription
maxCharactersnumber-
includeHtmlTagsboolean-
verbosityVerbosityOptions-
includeSectionsSectionTag[]-
excludeSectionsSectionTag[]-

HighlightsContentsOptions

Options for retrieving highlights from page. NOTE: For search type “deep”, these options will not be respected. Highlights will be generated with respect to your initial query, and may vary in quantity and length.
FieldTypeDescription
querystring-
numSentencesnumber-
highlightsPerUrlnumber-

SummaryContentsOptions

Options for retrieving summary from page.
FieldTypeDescription
querystring-
schemaRecord&lt;string, unknown&gt; | ZodSchema-

ContextOptions

Options for retrieving the context from a list of search results. The context is a string representation of all the search results.
FieldTypeDescription
maxCharactersnumber-

AnswerOptions

Options for the answer endpoint
FieldTypeDescription
textbooleanWhether to include text in the source results. Default false.
model"exa"The model to use for generating the answer. Default “exa”.
streambooleanWhether to stream the response. Default false.
systemPromptstringA system prompt to guide the LLM’s behavior when generating the answer.
outputSchemaRecord&lt;string, unknown&gt;A JSON Schema specification for the structure you expect the output to take.
userLocationstringThe two-letter ISO country code of the user, e.g. US.

Response Types

These types represent API response objects.

CostDollars

Represents the total cost breakdown. Only non-zero costs are included.
FieldTypeDescription
totalnumber-
searchCostDollarsSeearch-
contentsCostDollarsContents-

SearchResult

Represents a search result object.
FieldTypeDescription
titlestring | nullThe title of the search result.
urlstringThe URL of the search result.
idstringThe temporary ID for the document.
publishedDatestringThe estimated creation date of the content.
authorstringThe author of the content, if available.
scorenumberSimilarity score between the query/url and the result.
imagestringA representative image for the content, if any.
faviconstringA favicon for the site, if any.
textstringThe text content of the page (if text option enabled).
highlightsstring[]Highlighted text snippets (if highlights option enabled).
highlightScoresnumber[]Scores for each highlight.
summarystringSummary of the content (if summary option enabled).
entitiesEntity[]Structured entity data for company or person search results.

SearchResponse

Represents a search response object.
FieldTypeDescription
resultsSearchResult&lt;T&gt;[]The list of search results.
requestIdstringThe request ID for the search.
contextstringThe context for the search (for deep search).
autoDatestringThe autoprompt date, if applicable.
statusesStatus[]Status information for each result.
costDollarsCostDollarsThe cost breakdown for this request.

Status

FieldTypeDescription
idstring-
statusstring-
sourcestring-

AnswerResponse

Represents an answer response object from the /answer endpoint.
FieldTypeDescription
answerstring | Record&lt;string, unknown&gt;The generated answer text (or object matching outputSchema if provided).
citationsSearchResult&lt;{}&gt;[]The sources used to generate the answer.
requestIdstringThe request ID for the answer.
costDollarsCostDollarsThe cost breakdown for this request.

AnswerStreamChunk

FieldTypeDescription
contentstringThe partial text content of the answer (if present in this chunk).
citationsArray&lt;{id, url, title?, publishedDate?, author?, text?}&gt;Citations associated with the current chunk of text (if present).

Entity Types

These types represent structured entity data returned for company or person searches.

ResearchModel

The model to use for research tasks. Type: ‘exa-research-fast’ | ‘exa-research’ | ‘exa-research-pro’

EntityCompanyProperties

Structured properties for a company entity.
FieldTypeDescription
namestring | nullThe company name.
foundedYearnumber | nullThe year the company was founded.
descriptionstring | nullA description of the company.
workforceEntityCompanyPropertiesWorkforce | nullInformation about the company’s workforce.
headquartersEntityCompanyPropertiesHeadquarters | nullInformation about the company’s headquarters location.
financialsEntityCompanyPropertiesFinancials | nullFinancial information about the company.
webTrafficEntityCompanyPropertiesWebTraffic | nullWeb traffic statistics for the company.

EntityPersonProperties

Structured properties for a person entity.
FieldTypeDescription
namestring | nullThe person’s name.
locationstring | nullThe person’s location.
workHistoryEntityPersonPropertiesWorkHistoryEntry[]The person’s work history.

CompanyEntity

Structured entity data for a company.
FieldTypeDescription
idstringUnique identifier for the entity.
type"company"The entity type (always “company”).
versionnumberThe version of the entity schema.
propertiesEntityCompanyPropertiesStructured properties for the company.

PersonEntity

Structured entity data for a person.
FieldTypeDescription
idstringUnique identifier for the entity.
type"person"The entity type (always “person”).
versionnumberThe version of the entity schema.
propertiesEntityPersonPropertiesStructured properties for the person.