Skip to main content

Overview

The Prebuilt RAG API allows you to retrieve relevant document chunks from your ingested documents using semantic search. It returns the most relevant content for your query, making it ideal for building custom applications.

Endpoint

Authentication

Include your API token in the Authorization header:

Request

Headers

Body Parameters

Example Request

Example with Specific Documents (using file_ids)

Example with Specific Documents (using file_names - deprecated)

Response

Success Response (200 OK)

Chunk Object

Each chunk in the chunks array contains:

Example Response

Error Responses

Usage Examples

Python

Python with Custom LLM Integration

JavaScript

JavaScript with Custom LLM Integration

Use Cases

Custom Applications with Your LLM

Use this API to build custom features with your preferred LLM:
  1. Retrieve relevant chunks using semantic search
  2. Build context from the retrieved chunks
  3. Generate answers using any LLM (OpenAI, Anthropic, Google, etc.)
Build document search interfaces that show relevant excerpts:
  1. Query for relevant content
  2. Display chunks with file names and page numbers
  3. Allow users to navigate to source documents

Knowledge Base Q&A

Create custom Q&A systems with full control over:
  • Prompt engineering
  • Response formatting
  • Source citations
  • Multi-step reasoning

Best Practices

  1. Be specific in queries — Clear, specific queries return more relevant chunks
  2. Use file_names for focused search — Restrict to specific documents when you know the source
  3. Check relevance scores — Higher scores indicate better matches; consider filtering low-score chunks
  4. Include source citations — Use file_name and page_number to cite sources in your responses
  5. Combine with LLM — Use retrieved chunks as context for LLM-generated answers

Comparison with Chat API

Chat API

Get AI-generated answers with built-in LLM

Data Ingestion

Improve parsing quality for better retrieval results

Extraction API

Extract structured data from documents