UnSearch Docs

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.

POST /api/v1/rag/search

Fast RAG-optimized search that returns sources with optional synthesized context.

Body Parameters

ParameterTypeDefaultDescription
querystringrequiredSearch query
max_sourcesinteger5Max sources to return
scrape_contentbooleantrueScrape full page content
enginesstring[]["google"]Search engines to use
include_contextbooleantrueGenerate 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

ParameterTypeDefaultDescription
topicstringrequiredResearch topic
depthstring"standard""quick", "standard", "deep"
num_queriesintegerNumber of search queries to generate
target_sourcesintegerTarget number of sources
categoriesstring[]Query categories to focus on
enginesstring[]["google"]Search engines
scrape_contentbooleantrueScrape content from sources
generate_embeddingsbooleanfalseGenerate vector embeddings
languagestring"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"
}

POST /api/v1/rag/semantic-search

Search over a previously built research corpus using semantic similarity.

Body Parameters

ParameterTypeDefaultDescription
corpus_idstringrequiredCorpus ID from research
querystringrequiredSemantic search query
limitinteger10Max results
min_relevancenumber0.5Minimum 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
}

POST /api/v1/rag/images

Search for images across multiple engines.

Body Parameters

ParameterTypeDefaultDescription
querystringrequiredImage search query
max_resultsinteger10Max image results
safe_searchstring"moderate""strict", "moderate", "off"
enginesstring[]["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
}

On this page