Fastest way to add AI search to my SaaS product
Add AI-powered semantic search to a SaaS product in under an hour using Ragex. Create one knowledge base per customer for tenant isolation, upload their documents, and search — five API calls to a working feature.
TL;DR: Use Ragex that handles parsing, chunking, embedding, and reranking behind a single endpoint. Create one knowledge base per customer for tenant isolation, upload their documents, and call the search endpoint. You go from zero to working AI search in under 5 minutes with five API calls — starting at $29/mo.
What does the integration look like end-to-end?
The fastest path is to skip building your own retrieval pipeline entirely. Ragex gives you three endpoints: create a knowledge base, upload documents, and search. The API handles the entire pipeline — parsing 16 file types, chunking, embedding, indexing, and reranking — so you write product code instead of infrastructure code.
Here is a full working example in TypeScript that creates a per-customer knowledge base, uploads a document, waits for processing, and runs a search:
import { RagexClient } from 'ragex'
const client = new RagexClient({ apiKey: process.env.RAGEX_API_KEY })
// Step 1: Create a knowledge base for this customer (tenant isolation)
const kb = await client.createKnowledgeBase({
name: `Customer ${customerId}`,
metadata: { customerId, plan: 'pro' },
})
// Step 2: Upload the customer's documents
const doc = await client.uploadDocument(kb.id, './product-manual.pdf')
// Step 3: Poll until processing completes
let status = doc.status
while (status !== 'ready' && status !== 'failed') {
await new Promise((r) => setTimeout(r, 2000))
const updated = await client.getDocument(kb.id, doc.id)
status = updated.status
}
// Step 4: Search the customer's documents
const results = await client.search(kb.id, {
query: 'How do I configure SSO?',
topK: 5,
})
// Step 5: Pass results to your LLM as context
const context = results.results.map((r) => r.text).join('\n\n')
That is five API calls from zero to AI-powered search scoped to a single customer's documents.
How do I handle multi-tenancy for a SaaS product?
Multi-tenancy is the first concern for any SaaS integration. The approach is simple: create one knowledge base per customer. Each knowledge base is an isolated query boundary — searches against one KB never return results from another. Your customers' data stays separated at the infrastructure level, not just the application level.
When a new customer signs up, create a knowledge base and store the returned ID alongside their account record. When they upload files, route documents to their knowledge base. When they search, query against their knowledge base only. No cross-tenant data leakage is possible because the API enforces isolation at the knowledge base level.
For customers who need finer-grained control, attach metadata to documents at upload time and filter at query time. For example, a customer with multiple projects can tag documents by project and search within a specific one:
// Upload with metadata
await client.uploadDocument(kb.id, './spec.pdf', {
metadata: { projectId: 'proj_123', department: 'engineering' },
})
// Search with a metadata filter
const results = await client.search(kb.id, {
query: 'deployment requirements',
topK: 5,
filter: { projectId: { $eq: 'proj_123' } },
})
How do I handle document updates and processing events?
Documents are processed asynchronously. After upload, the status moves through pending, parsing, chunking, embedding, and finally ready. Rather than polling, you can register a webhook to get notified when processing completes or fails:
// Register a webhook for processing events
await fetch('https://api.example.com/v1/webhooks', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.RAGEX_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://your-app.com/api/webhooks/rag',
events: ['document.ready', 'document.failed'],
}),
})
When a customer updates a file, use the replace endpoint to trigger full re-processing. The old chunks are removed and new ones are generated automatically. Your search results reflect the latest version without manual cleanup.
What about search quality — do I need to tune anything?
No. Reranking is enabled by default, which means results are sorted by deep semantic relevance rather than just vector similarity. You do not need to choose embedding models, configure vector dimensions, or manage reranker infrastructure. The API makes those decisions and keeps them current. When better models become available, your search quality improves without a code change.
For most SaaS use cases, the default settings work well. If you need to adjust, the search endpoint accepts top_k to control how many results you get back and score_threshold to filter out low-confidence matches.
FAQ
How long does it take to integrate AI search into a SaaS product?
Most developers go from signup to a working prototype in a single coding session. The API is designed around five calls: create a knowledge base, upload a document, check status, search, and use the results. If you already have a file upload flow in your SaaS product, you are adding a few API calls to your existing code — not building a new system.
How much does this cost per customer?
Ragex starts at $29/mo on the Starter plan. Each customer gets their own knowledge base, but knowledge bases themselves are free to create. You pay based on total pages processed and queries made across all customers, not per knowledge base. This keeps per-customer costs low even as you scale.
Can I use this with my existing LLM provider?
Yes. The search endpoint returns ranked text chunks with relevance scores. You pass those chunks as context to whatever LLM you already use — OpenAI, Anthropic, a local model, or any other provider. The API handles retrieval; you handle generation. This means you can swap LLMs without touching your search integration.
What file types can my customers upload?
The API supports 16 file types out of the box. Nine types get advanced parsing that handles tables, images, and complex layouts: PDF, DOCX, PPTX, XLSX, PNG, JPG, WEBP, TIFF, and CSV. Seven additional types are ingested directly as text: TXT, MD, HTML, TSV, JSON, and others. Your customers can upload common business documents without you building format-specific parsers.
Last updated: 2026-02-26