Environment:666ghj BettaFish Tavily API Key
| Knowledge Sources | |
|---|---|
| Domains | Search, API_Integration |
| Last Updated | 2026-10-08 21:30 GMT |
Overview
Tavily news search API key for time-bounded web search with news publication dates in the Query Engine.
Description
This environment provides access to the Tavily Search API, which is specialized for news and web search with time-bounding capabilities. The Query Engine uses Tavily to perform news-specific searches with date filtering (last 24 hours, last week, or custom date ranges). Each search result includes a `published_date` field for time-bounded analysis. The API is accessed via the `tavily-python` SDK.
Usage
Use this environment when running Query Engine news search tasks. It is required by the TavilyNewsAgency implementation for all news search operations including basic search, deep search, 24-hour search, weekly search, and date-range search.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Any | API calls are remote |
| Hardware | CPU sufficient | No GPU required |
| Network | Outbound HTTPS | Must reach `api.tavily.com` |
Dependencies
System Packages
- None beyond Python runtime
Python Packages
- `tavily-python` >= 0.3.0
Credentials
The following environment variables must be set in `.env`:
- `TAVILY_API_KEY`: Tavily API key (required; no default)
Quick Install
pip install tavily-python>=0.3.0
Code Evidence
API key validation from `QueryEngine/tools/search.py:39-42,83-93`:
try:
from tavily import TavilyClient
except ImportError:
raise ImportError("Tavily库未安装,请运行 `pip install tavily-python` 进行安装。")
class TavilyNewsAgency:
def __init__(self, api_key: Optional[str] = None):
if api_key is None:
api_key = os.getenv("TAVILY_API_KEY")
if not api_key:
raise ValueError("Tavily API Key未找到!请设置TAVILY_API_KEY环境变量或在初始化时提供")
self._client = TavilyClient(api_key=api_key)
Configuration from `QueryEngine/utils/config.py:35`:
TAVILY_API_KEY: str = Field(..., description="Tavily API(申请地址:https://www.tavily.com/)API密钥")
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `ImportError: Tavily库未安装` | `tavily-python` not installed | `pip install tavily-python` |
| `ValueError: Tavily API Key未找到` | `TAVILY_API_KEY` not set | Apply at https://www.tavily.com/ and set in `.env` |
| `tavily.errors.InvalidAPIKey` | Invalid API key | Re-apply or verify key in Tavily dashboard |
Compatibility Notes
- Required field: `TAVILY_API_KEY` is a required (non-optional) field in QueryEngine config — the engine will not start without it.
- Search topic: All searches default to `topic='general'` but are designed for news search patterns.
- Published dates: Tavily returns `published_date` for news results, enabling time-bounded analysis.