Skip to main content

In this example, we will build an LLM-based news summarizer with the Exa API to keep us up-to-date with the latest news on a given topic. We’ll do this in three steps:
  1. Generate search queries for Exa using an LLM
  2. Retrieve relevant URLs and their contents using Exa
  3. Summarize webpage contents using GPT-3.5 Turbo
This is a form of Retrieval Augmented Generation (RAG), combining Exa’s search capabilities with GPT’s summarization abilities. The Jupyter notebook for this tutorial is available on Colab for easy experimentation. You can also check it out on Github, including a plain Python version if you want to skip to the complete product.

Get Started

1

Pre-requisites and installation

Install the required packages:
You’ll need both an Exa API key and an OpenAI API key to run this example. You can get your OpenAI API key here.

Get your Exa API key

Set up your API keys:
2

Initialize the clients

Import and set up both the OpenAI and Exa clients:
3

Generate a search query

First, we’ll use GPT to generate an optimized search query based on the user’s question:
4

Search for recent articles

Now we’ll use Exa to search for recent articles, filtering by publication date:
We use start_published_date to filter for recent content.
5

Get article contents

Because we requested contents={"text": True}, the article contents are available directly:
Unlike traditional search engines that only return URLs, Exa gives us direct access to the webpage contents, eliminating the need for web scraping.
6

Generate a summary

Finally, we’ll use GPT to create a concise summary of the article:
And we’re done! We’ve built an app that translates a question into a search query, uses Exa to search for useful links and their contents, and summarizes the content to effortlessly answer questions about the latest news.Through Exa, we have given our LLM access to the entire Internet. The possibilities are endless.
Last modified on May 22, 2026