RAG API
Search and research endpoints optimized for retrieval-augmented generation pipelines.
RAG API
Endpoints optimized for RAG pipelines — quick search with context generation, deep research with corpus building, semantic search, and image search.
Quick Search
POST /api/v1/rag/search
Fast RAG-optimized search that returns sources with optional synthesized context.
Body Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
query | string | required | Search query |
max_sources | integer | 5 | Max sources to return |
scrape_content | boolean | true | Scrape full page content |
engines | string[] | ["google"] | Search engines to use |
include_context | boolean | true | Generate synthesized context |
Example Request
curl -X POST 'https://api.unsearch.dev/api/v1/rag/search' \
-H 'X-API-Key: sk_live_xxxxx' \
-H 'Content-Type: application/json' \
-d '{
"query": "How does transformer architecture work?",
"max_sources": 5,
"include_context": true
}'Response
{
"query": "How does transformer architecture work?",
"context": "The transformer architecture, introduced in the 2017 paper 'Attention Is All You Need', relies on self-attention mechanisms...",
"sources": [
{
"url": "https://example.com/transformers",
"title": "Understanding Transformer Architecture",
"content": "Full scraped content...",
"summary": "Overview of the transformer model...",
"relevance_score": 0.95,
"word_count": 2340,
"engine": "google",
"scraped_at": "2025-03-01T12:00:00Z"
}
],
"source_count": 5,
"processing_time_ms": 1850
}Deep Research
POST /api/v1/rag/research
Multi-query research that builds a corpus of sources for deeper analysis.
Body Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
topic | string | required | Research topic |
depth | string | "standard" | "quick", "standard", "deep" |
num_queries | integer | — | Number of search queries to generate |
target_sources | integer | — | Target number of sources |
categories | string[] | — | Query categories to focus on |
engines | string[] | ["google"] | Search engines |
scrape_content | boolean | true | Scrape content from sources |
generate_embeddings | boolean | false | Generate vector embeddings |
language | string | "en" | Language code |
Query Categories: overview, history, current_state, technical, practical, comparison, expert_opinion, future_trends, case_studies, best_practices
Response
{
"topic": "transformer architecture",
"corpus_id": "corpus_abc123",
"sources": [
{
"url": "https://example.com/paper",
"title": "Attention Is All You Need",
"content": "...",
"summary": "Foundational paper...",
"relevance_score": 0.98,
"word_count": 5000,
"engine": "google_scholar"
}
],
"total_sources_found": 25,
"queries_executed": ["transformer architecture overview", "self-attention mechanism", "..."],
"processing_time_ms": 8500,
"depth": "standard"
}Semantic Search
POST /api/v1/rag/semantic-search
Search over a previously built research corpus using semantic similarity.
Body Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
corpus_id | string | required | Corpus ID from research |
query | string | required | Semantic search query |
limit | integer | 10 | Max results |
min_relevance | number | 0.5 | Minimum relevance threshold |
Response
{
"corpus_id": "corpus_abc123",
"query": "self-attention mechanism",
"results": [
{
"id": "src_001",
"score": 0.94,
"url": "https://example.com/paper",
"title": "Attention Is All You Need",
"summary": "Self-attention allows the model to attend to all positions..."
}
],
"total_results": 5,
"processing_time_ms": 45
}Image Search
POST /api/v1/rag/images
Search for images across multiple engines.
Body Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
query | string | required | Image search query |
max_results | integer | 10 | Max image results |
safe_search | string | "moderate" | "strict", "moderate", "off" |
engines | string[] | ["google_images"] | Image search engines |
Response
{
"query": "transformer architecture diagram",
"images": [
{
"url": "https://example.com/img.png",
"thumbnail_url": "https://example.com/thumb.png",
"title": "Transformer Architecture",
"source_url": "https://example.com/article",
"width": 1200,
"height": 800,
"engine": "google_images"
}
],
"total_results": 10,
"processing_time_ms": 320
}