Exa helps you locate precise content online using embeddings-based search. Its API offers three key features:

Page Search: Find web pages through natural language queries, with an option to use traditional keyword searches if needed.
Content Extraction: Access clean, parsed HTML from search results, with the option to focus on relevant sections using the highlights feature.
Similar Page Discovery: Input a link to identify and retrieve pages with related content or meaning.

Example

This code sets up an ExaHandler to perform a search using an API key. It retrieves content based on the provided query, automatically determining the search type and returning up to five results, making it easy to find relevant information quickly.

To access ExaSearch services, you’ll need to create an ExaSearch account, obtain an API key, and subscribe to the required API for your application. For more details, refer to the ExaSearch documentation.

Set up a Exa API key as an environmental variable and run the following code.

export EXA_API_KEY = "**************************"
exa_handler.py
import os
import asyncio

from superagentx.handler.exa_search import ExaHandler


async def search_contents(query):
    exa_handler = ExaHandler()
    return await exa_handler.search_contents(
        query=query,
        search_type="auto",
        use_autoprompt=True,
        num_results=5,
    )


async def main(query):
    res = await search_contents(query)
    print(res)

if __name__ == '__main__':
    query = "What is Agentic AI Framework?"
    asyncio.run(main(query))

Result

exa search
URL: https://aima.eecs.berkeley.edu/2nd-ed/ai.html
ID: http://aima.eecs.berkeley.edu/2nd-ed/ai.html
Score: 0.19881151616573334
Published Date: 2006-09-12T00:00:00.000Z
Author:
Image: None
Text: This page links to 849 pages around the web with
information on Artificial Intelligence. Links in  Bold*  followed by a star are especially useful
and interesting sites. Links with a + sign at the end have "tooltip"
information that will pop up if you put your mouse over the link for a
second or two. If you have new links to add, mail them to peter@norvig.com.