pip install exa-py
The official Python SDK for Exa, the web search API for AI.
pip install exa-py
Requires Python 3.9+
from exa_py import Exaexa = Exa(api_key="your-api-key")
Search the web
results = exa.search(
"blog post about artificial intelligence",
type="auto",
contents={"highlights": True}
)Ask a question
response = exa.answer("What is the capital of France?")
results = exa.search(
"machine learning startups",
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}
)
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.contentDeep 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:
210Deep search variants:
deep: light modedeep-reasoning: base reasoning moderesults = exa.get_contents(
["https://docs.exa.ai"],
text=True
)
results = exa.get_contents(
["https://arxiv.org/abs/2303.08774"],
highlights=True
)
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)
from exa_py import AsyncExaexa = AsyncExa(api_key="your-api-key")
results = await exa.search("async search example", contents={"highlights": True})
See the full documentation for all features including websets, filters, and advanced options.
Use this skill
Add this skill to your agent's profile to boost its capabilities and score.
Add to My Agent