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 thechunks 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:- Retrieve relevant chunks using semantic search
- Build context from the retrieved chunks
- Generate answers using any LLM (OpenAI, Anthropic, Google, etc.)
Document Search
Build document search interfaces that show relevant excerpts:- Query for relevant content
- Display chunks with file names and page numbers
- 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
- Be specific in queries — Clear, specific queries return more relevant chunks
- Use file_names for focused search — Restrict to specific documents when you know the source
- Check relevance scores — Higher scores indicate better matches; consider filtering low-score chunks
- Include source citations — Use file_name and page_number to cite sources in your responses
- Combine with LLM — Use retrieved chunks as context for LLM-generated answers
Comparison with Chat API
Related
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

