Skip to main content

Haystack integration for Exa search API

Project description

exa-haystack

PyPI version License

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: from EXA_API_KEY env var)
  • num_results: Number of results to return (default: 10)
  • use_autoprompt: Enable Exa's autoprompt feature (default: True)
  • type: Search type - "auto", "neural", or "keyword" (default: "auto")
  • include_domains: List of domains to include
  • exclude_domains: List of domains to exclude
  • start_published_date: Filter results after this date (ISO format)
  • end_published_date: Filter results before this date (ISO format)
  • category: Search category filter

ExaFindSimilar

Find similar pages using Exa's /findSimilar endpoint.

Parameters:

  • api_key: Exa API key (default: from EXA_API_KEY env var)
  • num_results: Number of results to return (default: 10)
  • include_domains: List of domains to include
  • exclude_domains: List of domains to exclude

ExaContents

Fetch content for URLs using Exa's /contents endpoint.

Parameters:

  • api_key: Exa API key (default: from EXA_API_KEY env var)
  • text: Include full text content (default: True)
  • highlights: Include highlighted snippets (default: False)
  • summary: Include AI-generated summary (default: False)

License

Apache-2.0

Project details


Download files

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

Source Distribution

exa_haystack-1.0.0.tar.gz (16.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_haystack-1.0.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file exa_haystack-1.0.0.tar.gz.

File metadata

  • Download URL: exa_haystack-1.0.0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for exa_haystack-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c2487cb82200527b4036b8eca893eb87158e4e51c95bf07101a03498395ea8e4
MD5 96355591a9e3fca4fa24b7b0d699576e
BLAKE2b-256 cd98932248d6d78c04bf14234187c687f5c458185ab615047631a6677044f1e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for exa_haystack-1.0.0.tar.gz:

Publisher: publish.yml on exa-labs/exa-haystack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exa_haystack-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: exa_haystack-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for exa_haystack-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27c2f3e23cee60ffbdee2f9650637e2fe6db6f00bbe3aeaa6e1d8754b0096910
MD5 f7bb4bbee026253e7f6e78d3c5decdd1
BLAKE2b-256 5d2c93939793cd7ba909b0cce7f1bc650ae8e60c4cfdf0bcdf67701f3a19b6c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for exa_haystack-1.0.0-py3-none-any.whl:

Publisher: publish.yml on exa-labs/exa-haystack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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