Install and use the Exa JavaScript SDK
npm install exa-js
yarn add exa-js
pnpm add exa-js
import Exa from "exa-js"; const exa = new Exa(); // reads EXA_API_KEY from environment
const result = await exa.search( "blog post about artificial intelligence", { contents: { text: true } } );
const result = await exa.search("interesting articles about space", { numResults: 10, includeDomains: ["nasa.gov", "space.com"], startPublishedDate: "2024-01-01", contents: { text: true } });
const { results } = await exa.getContents(["https://openai.com/research"], { text: true });
const { results } = await exa.getContents(["https://stripe.com/docs/api"], { summary: true });
const { results } = await exa.getContents(["https://arxiv.org/abs/2303.08774"], { highlights: { numSentences: 3 } });
const result = await exa.findSimilar( "https://paulgraham.com/greatwork.html", { contents: { text: true } } );
const result = await exa.findSimilar( "https://waitbutwhy.com/2015/01/artificial-intelligence-revolution-1.html", { excludeSourceDomain: true, contents: { text: true } } );
const response = await exa.answer("What caused the 2008 financial crisis?"); console.log(response.answer);
for await (const chunk of exa.streamAnswer("Explain quantum computing")) { if (chunk.content) { process.stdout.write(chunk.content); } }
const task = await exa.research.create({ instructions: "Find the top 5 AI startups founded in 2024", outputSchema: { type: "object", properties: { startups: { type: "array", items: { type: "string" } } } } }); const result = await exa.research.pollUntilFinished(task.researchId);
import Exa from "exa-js"; import type { SearchResponse, RegularSearchOptions } from "exa-js";