Skip to main content

Python SDK for Exa API.

Project description

Exa Python SDK

PyPI version

The official Python SDK for Exa, the web search API for AI.

Documentation | Dashboard

Install

pip install exa-py

Requires Python 3.9+

Quick Start

from exa_py import Exa

exa = Exa(api_key="your-api-key")

# Search the web
results = exa.search(
    "blog post about artificial intelligence",
    type="auto",
    contents={"text": True}
)

# Find similar pages
results = exa.find_similar(
    "https://paulgraham.com/greatwork.html",
    contents={"text": True}
)

# Ask a question
response = exa.answer("What is the capital of France?")

Search

results = exa.search(
    "machine learning startups",
    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}
)
results = exa.search(
    "What are the latest battery breakthroughs?",
    type="deep",
    system_prompt="Prefer official sources and avoid duplicate results",
    output_schema={
        "type": "object",
        "properties": {
            "summary": {"type": "string"},
            "key_companies": {"type": "array", "items": {"type": "string"}},
        },
        "required": ["summary", "key_companies"],
    },
)
print(results.output.content if results.output else None)

Deep output_schema modes:

  • {"type": "text", "description": "..."}: return plain text in output.content
  • {"type": "object", ...}: return structured JSON in output.content

Deep search also supports system_prompt to guide both the search process and the final returned result, for example by preferring certain sources, emphasizing novel findings, avoiding duplicates, or constraining output style.

For type: "object", deep search currently enforces:

  • max nesting depth: 2
  • max total properties: 10

Deep search variants:

  • deep: light mode
  • deep-reasoning: base reasoning mode

Contents

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={"max_characters": 500}
)

Find Similar

results = exa.find_similar(
    "https://paulgraham.com/greatwork.html",
    contents={"text": True}
)
results = exa.find_similar(
    "https://amistrongeryet.substack.com/p/are-we-on-the-brink-of-agi",
    exclude_source_domain=True,
    contents={"text": True}
)

Answer

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

from exa_py import AsyncExa

exa = AsyncExa(api_key="your-api-key")

results = await exa.search("async search example")

Research

For complex research tasks with structured output:

response = 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"}}
        }
    }
)

More

See the full documentation for all features including websets, filters, and advanced options.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exa_py-2.8.0.tar.gz (50.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

exa_py-2.8.0-py3-none-any.whl (64.9 kB view details)

Uploaded Python 3

File details

Details for the file exa_py-2.8.0.tar.gz.

File metadata

  • Download URL: exa_py-2.8.0.tar.gz
  • Upload date:
  • Size: 50.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for exa_py-2.8.0.tar.gz
Algorithm Hash digest
SHA256 952d87a0850d4dbd335f463eb5f7a316e04c0753b4aebcb43e86ceb3484a9d54
MD5 b2c769566a4182fe643cc00c49ef3e23
BLAKE2b-256 2b9ad5f206fc6402eff86ea07ecf2abbc7875d50df6e717d646be50022092cd0

See more details on using hashes here.

File details

Details for the file exa_py-2.8.0-py3-none-any.whl.

File metadata

  • Download URL: exa_py-2.8.0-py3-none-any.whl
  • Upload date:
  • Size: 64.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for exa_py-2.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac940a435341deba91b818a2a1b16b143f203e6de7c9fbf58259ce0795f566c9
MD5 4dd84da4e65ab5c0827a6bab436a5423
BLAKE2b-256 d30ed4a6c1eb2cbe8d98a98e73698292f39b0048a555832d1fbbad38d5683f53

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page