Python SDK for Exa API.
Project description
Exa Python SDK
The official Python SDK for Exa, the web search API for AI.
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 inoutput.content{"type": "object", ...}: return structured JSON inoutput.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 modedeep-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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file exa_py-2.8.1.tar.gz.
File metadata
- Download URL: exa_py-2.8.1.tar.gz
- Upload date:
- Size: 50.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7497916ea56d344e66b101c09238baef7bee2f3d3411213bde1a3c35484cf2ef
|
|
| MD5 |
ec5aa3e0c4312d05ce145e54d4f95fa1
|
|
| BLAKE2b-256 |
6598cb2974bd830b5b4483900f85766a6ac10359d09accf3ea43ba20c891dc0d
|
File details
Details for the file exa_py-2.8.1-py3-none-any.whl.
File metadata
- Download URL: exa_py-2.8.1-py3-none-any.whl
- Upload date:
- Size: 64.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2834c082355dee93ed3eeb60ed6e9c36cc9f4105f3f3bde9f11cf77ff4dbac0
|
|
| MD5 |
768b001150087fe1782e16ab52602135
|
|
| BLAKE2b-256 |
d7a68a6e5ee0274fbe268b83e567944dfb3273ae5ed750aaaadaaa7143dce2a1
|