Environment:ALwrity ALwrity Exa API
| Knowledge Sources | |
|---|---|
| Domains | Search, Research, NLP |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
Exa neural search API environment providing competitor discovery, content research, and hallucination detection grounding via the exa-py SDK.
Description
This environment layer provides access to the Exa neural search API, which finds semantically similar websites and content for competitive intelligence and research grounding. The `exa-py` SDK (pinned to `1.9.1`) is the Python client. The service initializes lazily — keys may be injected per-request via middleware, so the SDK is not assumed to be available at import time.
`ExaService` handles competitor discovery, content analysis, and summarization with a configurable timeout (default 30s). `ResearchService` uses Exa for research content retrieval, and `HallucinationDetector` uses Exa results as evidence for fact-checking.
Usage
Use this environment for:
- Competitor discovery — neural search to find similar websites (`ExaService.discover_competitors`)
- Research content retrieval — grounding content generation with sources
- Hallucination detection — fact-checking pipeline evidence retrieval
- Onboarding site brief generation — Exa query maps for website analysis
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Any (Python 3.11 compatible) | No OS-specific requirements |
| Hardware | Minimal | API calls are network-bound |
| Disk | N/A | Results are cached in SQLite, not on disk |
Dependencies
Python Packages
- `exa-py` == 1.9.1 (pinned exact version)
- `httpx` >= 0.28.1 (for async HTTP if used directly)
- `aiohttp` >= 3.9.0
Credentials
- `EXA_API_KEY`: Exa API key (required). May be set in `.env` or injected per-request via `api_key_injection_middleware`.
Quick Install
# Install Exa SDK
pip install exa-py==1.9.1
# Set API key in .env
echo 'EXA_API_KEY=your_exa_api_key_here' >> .env
Code Evidence
Lazy initialization with middleware key injection from `backend/services/research/exa_service.py:41-51`:
def __init__(self, timeout_seconds: int = 30):
self.api_key = os.getenv("EXA_API_KEY")
self.exa = None
self.enabled = False
self.timeout_seconds = timeout_seconds
# Don't assume key is available at import time in production.
# Keys may be injected per-request via middleware, so defer init.
self._try_initialize()
Graceful degradation when key missing from `backend/services/research/exa_service.py:66-72`:
if not self.api_key:
logger.warning("EXA_API_KEY not configured; Exa service will be disabled")
self.enabled = False
self.exa = None
return
Pinned version in `backend/requirements.txt:36`:
exa-py==1.9.1
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `EXA_API_KEY not configured; Exa service will be disabled` | API key not in env or middleware | Set `EXA_API_KEY` in `.env` or inject via `api_key_injection_middleware` |
| `asyncio.TimeoutError` during Exa call | API call exceeded 30s timeout | Increase `timeout_seconds` or retry |
| `Failed to initialize Exa service` | Invalid API key or network issue | Verify key at Exa dashboard |
Compatibility Notes
- Per-request key injection: The service supports lazy re-initialization via `_try_initialize()`, allowing middleware to inject user-specific keys at request time.
- Pinned version: `exa-py==1.9.1` is pinned to avoid breaking API changes. Upgrading requires testing the SDK client interface.
- Graceful degradation: When the key is missing, the service disables itself rather than raising — callers must check `self.enabled` before use.