What this doc covers
- Using Exa’s Auto search to pick the best search setting for each query
- Using searchAndContents() through Exa’s JavaScript SDK
In this example, we will build Exa Researcher, a JavaScript app that, given a research topic, automatically searches for relevant sources with Exa’s Auto search and synthesizes the information into a reliable research report. Fastest setup: Interact with the code in your browser with this Replit template. Alternatively, this interactive notebook was made with the Deno Javascript kernel for Jupyter so you can easily run it locally. Check out the plain JS version if you prefer a regular Javascript file you can run with NodeJS, or want to skip to the final result. If you’d like to run this notebook locally, Installing Deno and connecting Deno to Jupyter is fast and easy. To play with this code, first we need a Exa API key and an OpenAI API key.
Setup
Let’s import the Exa and OpenAI SDKs and put in our API keys to create a client object for each. Make sure to pick the right imports for your runtime and paste or load your API keys.TypeScript
TypeScript
Exa Auto search
The researcher should be able to automatically generate research reports for all kinds of different topics. Here’s two to start:TypeScript
TypeScript
TypeScript
Writing a report with GPT-4
The final step is to instruct the LLM to synthesize the content into a research report, including citations of the original links. We can do that by pairing the content and the URLs and writing them into the prompt.TypeScript
All Together Now
Now, let’s just wrap everything into one Researcher function that strings together all the functions we’ve written. Given a user’s research topic, the Researcher will generate search queries, feed those queries to Exa Auto search, and finally use an LLM to synthesize the retrieved information. Three simple steps!TypeScript
TypeScript

