Haystack integration for Exa search API
Project description
exa-haystack
Haystack integration for Exa - the search engine designed for AI.
Installation
pip install exa-haystack
Usage
ExaWebSearch
Search the web using Exa's neural search:
from haystack_integrations.components.websearch.exa import ExaWebSearch
search = ExaWebSearch(num_results=5)
results = search.run(query="latest developments in quantum computing")
for doc in results["documents"]:
print(f"Title: {doc.meta['title']}")
print(f"URL: {doc.meta['url']}")
print(f"Content: {doc.content[:200]}...")
print()
ExaFindSimilar
Find pages similar to a given URL:
from haystack_integrations.components.websearch.exa import ExaFindSimilar
find_similar = ExaFindSimilar(num_results=5)
results = find_similar.run(url="https://example.com/article")
for doc in results["documents"]:
print(f"Similar: {doc.meta['title']} - {doc.meta['url']}")
ExaContents
Fetch full content for URLs:
from haystack_integrations.components.websearch.exa import ExaContents
contents = ExaContents(text=True, highlights=True, summary=True)
results = contents.run(urls=["https://example.com/article1", "https://example.com/article2"])
for doc in results["documents"]:
print(f"Title: {doc.meta['title']}")
print(f"Summary: {doc.meta.get('summary', 'N/A')}")
print(f"Content: {doc.content[:500]}...")
Using in a Pipeline
from haystack import Pipeline
from haystack.components.builders import PromptBuilder
from haystack.components.generators import OpenAIGenerator
from haystack_integrations.components.websearch.exa import ExaWebSearch
template = """
Based on the following search results, answer the question.
Search Results:
{% for doc in documents %}
Title: {{ doc.meta.title }}
Content: {{ doc.content }}
---
{% endfor %}
Question: {{ query }}
Answer:
"""
pipe = Pipeline()
pipe.add_component("search", ExaWebSearch(num_results=3))
pipe.add_component("prompt", PromptBuilder(template=template))
pipe.add_component("llm", OpenAIGenerator())
pipe.connect("search.documents", "prompt.documents")
pipe.connect("prompt", "llm")
result = pipe.run({
"search": {"query": "What is retrieval augmented generation?"},
"prompt": {"query": "What is retrieval augmented generation?"}
})
print(result["llm"]["replies"][0])
Configuration
Set your Exa API key as an environment variable:
export EXA_API_KEY="your-api-key"
Or pass it directly:
from haystack.utils import Secret
from haystack_integrations.components.websearch.exa import ExaWebSearch
search = ExaWebSearch(api_key=Secret.from_token("your-api-key"))
Components
ExaWebSearch
Main search component using Exa's /search endpoint.
Parameters:
api_key: Exa API key (default: fromEXA_API_KEYenv var)num_results: Number of results to return (default: 10)type: Search type —"auto","neural","fast","deep","deep-reasoning","deep-max","instant"(default:"auto")include_domains/exclude_domains: Domain filtersstart_published_date/end_published_date: Date range filters (ISO format)category: Search category filter ("company","research paper","news","pdf","tweet","personal site","financial report","people")additional_queries: Extra queries for deep searchoutput_schema: JSON schema for structured deep search output (returned asdeep_outputcomponent output)max_age_hours: Content freshness control (0= always livecrawl,-1= cache only, positive = max cache age in hours)livecrawl: Legacy freshness option (deprecated, usemax_age_hours)text/highlights/summary: Content options (bool or dict with sub-options)
ExaFindSimilar
Find similar pages using Exa's /findSimilar endpoint.
Parameters:
api_key: Exa API key (default: fromEXA_API_KEYenv var)num_results: Number of results to return (default: 10)include_domains/exclude_domains: Domain filtersexclude_source_domain: Exclude the source URL's domain from resultscategory: Search category filtermax_age_hours: Content freshness controllivecrawl: Legacy freshness option (deprecated, usemax_age_hours)text/highlights/summary: Content options
ExaContents
Fetch content for URLs using Exa's /contents endpoint.
Parameters:
api_key: Exa API key (default: fromEXA_API_KEYenv var)text: Include full text content (default: True)highlights: Include highlighted snippetssummary: Include AI-generated summarymax_age_hours: Content freshness controllivecrawl: Legacy freshness option (deprecated, usemax_age_hours)subpages/subpage_target: Crawl linked subpagesextras/flags: Additional extraction options
Outputs: documents (list of Documents) and statuses (per-URL status/error info)
ExaAnswer
Generate AI-powered answers with citations using Exa's /answer endpoint.
Parameters:
api_key: Exa API key (default: fromEXA_API_KEYenv var)model:"exa"or"exa-pro"(default:"exa")system_prompt: Custom system promptoutput_schema: JSON schema for structured answer output
ExaStreamAnswer
Streaming variant of ExaAnswer — yields answer chunks via SSE.
ExaResearch
Conduct deep research using Exa's /research/v1 endpoint.
Parameters:
api_key: Exa API key (default: fromEXA_API_KEYenv var)model:"exa-research-fast","exa-research", or"exa-research-pro"(default:"exa-research")output_schema: JSON schema for structured research outputpoll_interval/max_wait_time: Polling configuration
License
Apache-2.0
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_haystack-1.1.0.tar.gz.
File metadata
- Download URL: exa_haystack-1.1.0.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
445f505a314827513575c6c6b4e45c55925f3b2e06d9ab01dfd73485cda3b95e
|
|
| MD5 |
0223197fced0720a205606876d3f2045
|
|
| BLAKE2b-256 |
c18bb71ada18043520a1849dca050f8767147ae88103ea56a9fbc52a0c258cb8
|
Provenance
The following attestation bundles were made for exa_haystack-1.1.0.tar.gz:
Publisher:
publish.yml on exa-labs/exa-haystack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exa_haystack-1.1.0.tar.gz -
Subject digest:
445f505a314827513575c6c6b4e45c55925f3b2e06d9ab01dfd73485cda3b95e - Sigstore transparency entry: 1093227689
- Sigstore integration time:
-
Permalink:
exa-labs/exa-haystack@a0dc749e9ea8278c8571dcf5ce46ea60d79dbc27 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/exa-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a0dc749e9ea8278c8571dcf5ce46ea60d79dbc27 -
Trigger Event:
release
-
Statement type:
File details
Details for the file exa_haystack-1.1.0-py3-none-any.whl.
File metadata
- Download URL: exa_haystack-1.1.0-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01ebfc34011e1904b8acde3034ca8195619c1316e3cecdeae26f7c85b88f4d0e
|
|
| MD5 |
dcb6e236ae41a87adf9cdf626627158c
|
|
| BLAKE2b-256 |
c9700347a02ebba87ac66d2087de8792eacfa48e4e07e4bf8f432fdf9498be01
|
Provenance
The following attestation bundles were made for exa_haystack-1.1.0-py3-none-any.whl:
Publisher:
publish.yml on exa-labs/exa-haystack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exa_haystack-1.1.0-py3-none-any.whl -
Subject digest:
01ebfc34011e1904b8acde3034ca8195619c1316e3cecdeae26f7c85b88f4d0e - Sigstore transparency entry: 1093227691
- Sigstore integration time:
-
Permalink:
exa-labs/exa-haystack@a0dc749e9ea8278c8571dcf5ce46ea60d79dbc27 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/exa-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a0dc749e9ea8278c8571dcf5ce46ea60d79dbc27 -
Trigger Event:
release
-
Statement type: