UnSearch Python SDK - Open-source Tavily alternative for AI search
Project description
UnSearch Python SDK
Comprehensive AI search API with full backend capabilities. Drop-in Tavily replacement with self-hosting and zero-retention options.
Features
- Tavily-compatible - Drop-in replacement for Tavily API
- Exa-compatible - Neural/semantic search endpoints
- RAG-optimized - Built for retrieval augmented generation
- 70+ search engines - Aggregated results from multiple sources
- Topic monitoring - Real-time web monitoring
- Fact verification - AI-powered fact-checking
- Zero-retention - Privacy-first architecture
Installation
pip install unsearch
# With LangChain support
pip install unsearch[langchain]
Quick Start
from unsearch import UnSearchClient
client = UnSearchClient(api_key="your-api-key")
# Basic search
response = client.search("What is machine learning?")
for result in response.results:
print(f"{result.title}: {result.url}")
# Search with AI answer
response = client.search(
"What is RAG?",
include_answer=True,
max_results=5
)
print(response.answer)
# Q&A shortcut
answer = client.qna_search("What is the capital of France?")
print(answer)
Migrate from Tavily
UnSearch is designed as a drop-in replacement for Tavily. Migration is simple:
Option 1: Direct replacement
# Before (Tavily)
from tavily import TavilyClient
client = TavilyClient(api_key="tvly-...")
# After (UnSearch)
from unsearch import UnSearchClient
client = UnSearchClient(api_key="uns-...")
Option 2: Alias (minimal code changes)
# Add this import alias
from unsearch import UnSearchClient as TavilyClient
# Your existing code works unchanged
client = TavilyClient(api_key="uns-...")
response = client.search("query")
LangChain Integration
from unsearch.langchain import UnSearchResults
# Create tool
tool = UnSearchResults(
api_key="your-api-key",
max_results=5,
include_answer=True
)
# Use in agent
results = tool.invoke("What is LangChain?")
Migrate from TavilySearchResults
# Before
from langchain_community.tools import TavilySearchResults
tool = TavilySearchResults(api_key="tvly-...")
# After (option 1)
from unsearch.langchain import UnSearchResults
tool = UnSearchResults(api_key="uns-...")
# After (option 2: alias)
from unsearch.langchain import UnSearchResults as TavilySearchResults
tool = TavilySearchResults(api_key="uns-...")
Self-Hosted Instance
# Point to your self-hosted UnSearch
client = UnSearchClient(
api_key="your-api-key",
base_url="https://your-unsearch-instance.com"
)
# Or use environment variable
# export UNSEARCH_BASE_URL=https://your-unsearch-instance.com
Zero-Retention Mode
For privacy-sensitive applications:
# Enable zero-retention (no data stored on server)
client = UnSearchClient(
api_key="your-api-key",
zero_retention=True
)
# Or per-request via header
# X-Zero-Retention: true
Async Support
from unsearch import AsyncUnSearchClient
async def search():
async with AsyncUnSearchClient(api_key="your-key") as client:
response = await client.search("async search query")
return response.results
API Reference
Agent API (Tavily-compatible)
| Method | Description |
|---|---|
search(query, **options) |
AI-optimized web search |
extract(urls, **options) |
Extract content from URLs |
research(query, **options) |
Multi-step deep research |
qna_search(query) |
Quick Q&A shortcut |
get_search_context(query, max_results) |
Get RAG context |
list_models() |
List available AI models |
Core Search API
| Method | Description |
|---|---|
core_search(query, **options) |
Full-featured search |
batch_search(queries, **options) |
Search multiple queries |
list_engines() |
List search engines |
RAG API
| Method | Description |
|---|---|
rag_research(topic, **options) |
Deep RAG research |
rag_search(query, **options) |
Quick RAG search |
semantic_search(corpus_id, query) |
Semantic search over corpus |
image_search(query) |
Image search |
list_corpora() |
List research corpora |
Neural API (Exa-compatible)
| Method | Description |
|---|---|
neural_search(query, **options) |
Neural/semantic search |
find_similar(url=None, text=None) |
Find similar content |
extract_highlights(query, content) |
Extract key highlights |
predictive_search(context) |
Predict next search |
Topic Monitoring API
| Method | Description |
|---|---|
create_monitor(topic, **options) |
Create topic monitor |
list_monitors() |
List all monitors |
get_monitor(monitor_id) |
Get a monitor |
pause_monitor(monitor_id) |
Pause a monitor |
resume_monitor(monitor_id) |
Resume a monitor |
delete_monitor(monitor_id) |
Delete a monitor |
get_monitor_results(monitor_id) |
Get monitor results |
Enhanced API (Advanced scraping)
| Method | Description |
|---|---|
enhanced_search(query, **options) |
Advanced search with extraction |
enhanced_scrape(urls, **options) |
Direct URL scraping |
enhanced_features() |
List enhanced features |
extract_tables(html_content) |
Extract tables from HTML |
chunk_content(text, strategy) |
Chunk text for RAG |
discover_urls(base_url, source) |
Discover URLs from sitemaps |
Knowledge Graph API
| Method | Description |
|---|---|
knowledge_extract(text) |
Extract entities & relationships |
knowledge_search(query) |
Search knowledge graph |
knowledge_people(query) |
Search for people |
knowledge_get_entity(entity_id) |
Get specific entity |
knowledge_graph() |
Get graph structure |
Agent Registration API
| Method | Description |
|---|---|
register_agent(name) |
Register new AI agent (sandbox) |
agent_status() |
Get agent status |
resend_claim() |
Resend claim link |
Verification API (Fact-checking)
| Method | Description |
|---|---|
verify_claim(claim, **options) |
Verify a claim |
check_source_credibility(url) |
Check source credibility |
batch_verify(claims) |
Batch verify claims |
Extended Examples
Deep Research
# Multi-step research with AI synthesis
research = client.research(
query="Impact of AI on healthcare",
depth="deep", # quick, standard, deep, comprehensive
max_sources=20,
include_analysis=True,
focus_areas=["diagnostics", "drug discovery"]
)
print(research.executive_summary)
print(research.key_findings)
Neural Search (Exa-compatible)
# Semantic search with auto-prompting
results = client.neural_search(
query="innovations in renewable energy",
num_results=10,
use_autoprompt=True, # AI expands query
include_highlights=True,
category="tech"
)
print("Expanded queries:", results.expanded_queries)
for r in results.results:
print(r.title, r.highlights)
Topic Monitoring
# Create a real-time monitor
monitor = client.create_monitor(
topic="artificial intelligence regulations",
keywords=["AI", "regulation", "EU"],
check_interval_minutes=60,
webhook_url="https://your-app.com/webhook",
deep_analysis=True
)
# Get results
results = client.get_monitor_results(monitor["id"], limit=50)
Fact Verification
# Verify a claim
verification = client.verify_claim(
claim="The Earth is approximately 4.5 billion years old",
depth="thorough"
)
print(f"Verdict: {verification.verdict}")
print(f"Confidence: {verification.confidence}%")
print(f"Summary: {verification.summary}")
# Check source credibility
credibility = client.check_source_credibility("https://example-news.com")
print(f"Score: {credibility.credibility_score}")
print(f"Bias: {credibility.bias_rating}")
Why UnSearch over Tavily?
| Feature | Tavily | UnSearch |
|---|---|---|
| Open Source | ❌ | ✅ |
| Self-Hostable | ❌ | ✅ |
| Zero Retention | ❌ | ✅ |
| Cost at Scale | ~$0.0075/query | $0.0003/query |
| Free Tier | 1,000/mo | 5,000/mo |
| Search Engines | Single | 70+ |
| Neural Search | ❌ | ✅ |
| Topic Monitoring | ❌ | ✅ |
| Fact Verification | ❌ | ✅ |
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 unsearch-0.2.1.tar.gz.
File metadata
- Download URL: unsearch-0.2.1.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4751e14cc4075811ea7b7d05787965071ae6dc86bbd83b1fd5dea1e7de3ca735
|
|
| MD5 |
e129e85aa2555d86bbcdea4985ff13f7
|
|
| BLAKE2b-256 |
00c522b333087769573970ee3699d635793326ed8f8ea389c3e79d9d26007f28
|
File details
Details for the file unsearch-0.2.1-py3-none-any.whl.
File metadata
- Download URL: unsearch-0.2.1-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cafc68ff4cbfa1ecf102866469365e06ff9bd5d57ab18636ad6491098cba7dc2
|
|
| MD5 |
e110eba123966fc27e19a4fd915fbdce
|
|
| BLAKE2b-256 |
90f7379c6e92b70e9e5cc894362451f8db767ccc9621ca5f0ffedfb295ab0763
|