Skip to main content
The official Python SDK for Exa. Search the web, get page contents, find similar pages, and get answers with citations.

Get API Key

Get your API key from the dashboard

Install

pip install exa-py
Requires Python 3.9+

Quick Start

from exa_py import Exa

exa = Exa()  # reads EXA_API_KEY from environment
Search the web and get page contents in one call.
results = exa.search(
    "blog post about artificial intelligence",
    contents={"text": True}
)
results = exa.search(
    "climate tech news",
    num_results=20,
    start_published_date="2024-01-01",
    include_domains=["techcrunch.com", "wired.com"],
    contents={"text": True}
)

Get Contents

Get text, summaries, or highlights from URLs.
results = exa.get_contents(
    ["https://openai.com/research"],
    text=True
)
results = exa.get_contents(
    ["https://stripe.com/docs/api"],
    summary=True
)
results = exa.get_contents(
    ["https://arxiv.org/abs/2303.08774"],
    highlights={"num_sentences": 3}
)

Find Similar

Find pages similar to a URL.
results = exa.find_similar(
    "https://paulgraham.com/greatwork.html",
    contents={"text": True}
)
results = exa.find_similar(
    "https://waitbutwhy.com/2015/01/artificial-intelligence-revolution-1.html",
    exclude_source_domain=True,
    contents={"text": True}
)

Answer

Get answers to questions with citations.
response = exa.answer("What caused the 2008 financial crisis?")
print(response.answer)
for chunk in exa.stream_answer("Explain quantum computing"):
    print(chunk, end="", flush=True)

Async

Use AsyncExa for async operations.
from exa_py import AsyncExa

exa = AsyncExa()

results = await exa.search(
    "machine learning startups",
    contents={"text": True}
)

Research

Run research tasks with structured output.
task = exa.research.create(
    instructions="Summarize recent advances in fusion energy",
    output_schema={
        "type": "object",
        "properties": {
            "summary": {"type": "string"},
            "key_developments": {"type": "array", "items": {"type": "string"}}
        }
    }
)

result = exa.research.poll_until_finished(task.research_id)