Skip to main content

Documentation Index

Fetch the complete documentation index at: https://exa.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

New to Exa? Try the Coding Agent Quickstart to get started in under a minute.
The official Python SDK for Exa. Search the web, get page contents, and get answers with citations.

Get API Key

Get your API key from the dashboard

Install

bash pip install exa-py
Requires Python 3.9+

Quick Start

from exa_py import Exa

exa = Exa()  # reads EXA_API_KEY from environment
  • Start with exa.search(...).
  • Use type="auto" unless you have a clear latency or synthesis reason to change it.
  • Prefer contents={"highlights": True} for first integrations.
  • Switch to exa.get_contents(...) only when you already know the URLs.
  • Prefer max_age_hours over older livecrawl examples when you need freshness control.
On /search, text, highlights, and summary belong inside contents. On /contents, those same fields are top-level arguments.
Search the web and get page contents in one call.
highlights is a strong default for retrieval workflows because it preserves the most relevant evidence without pulling full page text into every response.
results = exa.search(
    "blog post about artificial intelligence",
    contents={"highlights": True}
)
results = exa.search(
    "climate tech news",
    num_results=20,
    start_published_date="2024-01-01",
    include_domains=["techcrunch.com", "wired.com"],
    contents={"highlights": True}
)
structured_results = exa.search(
    "Who is the CEO of OpenAI?",
    type="deep",
    system_prompt="Prefer official sources and avoid duplicate results",
    output_schema={
        "type": "object",
        "properties": {
            "leader": {"type": "string"},
            "title": {"type": "string"},
            "source_count": {"type": "number"}
        },
        "required": ["leader", "title"]
    },
    contents={"highlights": True}
)

print(structured_results.output.content if structured_results.output else None)
output_schema and system_prompt work across all search types. Keep output_schema focused on the fields you want in output.content, and use system_prompt to guide the final returned result. For more demanding synthesis, prefer reasoning-focused search types like deep-lite, deep, or deep-reasoning. Do not add citations/confidence fields there; grounding is returned automatically in output.grounding. Adding citation/confidence fields to output_schema creates duplicate data, weaker structure, and less reliable attribution.
Reasoning-focused search variants:
  • deep-lite: lowest-latency deep-search mode
  • deep: light mode
  • deep-reasoning: base reasoning mode
Need streaming structured synthesis? The raw /search endpoint supports stream: true together with outputSchema and returns OpenAI-compatible SSE chunks. See the Search API guide.

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=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={"highlights": True}
)

Research

The Research API (/research/v1) is legacy and deprecated. For new integrations, use exa.search(...) with type="deep-reasoning" and output_schema for structured research-style output.
result = exa.search(
    "Summarize recent advances in fusion energy",
    type="deep-reasoning",
    output_schema={
        "type": "object",
        "properties": {
            "summary": {"type": "string"},
            "key_developments": {"type": "array", "items": {"type": "string"}}
        }
    },
    contents={"highlights": True}
)

Resources