Skip to main content

How RAG Works

StepProcess
1. UploadAdd files or connect external sources
2. ChunkDocuments split into ~250 token segments
3. EmbedVector embeddings generated for each chunk
4. SearchUser query matched against embeddings
5. RetrieveTop chunks injected into LLM context

Create Dataset

curl -X POST https://api.cuadra.ai/v1/datasets \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: create-ds-001" \
  -d '{"name": "Product Docs", "description": "API guides"}'

Upload Documents

Adding documents is a two-step process: upload the file, then associate it with a dataset.

Step 1: Upload File

curl -X POST https://api.cuadra.ai/v1/files \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Idempotency-Key: upload-001" \
  -F "file=@product-guide.pdf"

Step 2: Associate with Dataset

curl -X POST https://api.cuadra.ai/v1/files/file_abc123/associations \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"datasetId": "ds_xyz789"}'

Supported Formats

FormatExtensionsMax Size
PDF.pdf50MB
Word.docx50MB
Text.txt, .md50MB
Data.csv, .json50MB

External Connectors

Sync content from external data sources.
ConnectorStatus
Google Drive✅ Available
Notion✅ Available

Connect Google Drive

curl -X POST https://api.cuadra.ai/v1/connections \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "connectorSlug": "google_drive",
    "redirectUrl": "https://your-app.com/oauth/callback"
  }'

Connect a dataset to enable RAG:
curl -X POST https://api.cuadra.ai/v1/models/model_abc/datasets \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"datasetId": "ds_xyz", "usageType": "rag"}'

Best Practices

DoAvoid
Clean formatting before uploadScanned images without OCR
Use descriptive filenamesDuplicate content across files
Split large docs into sectionsMixing unrelated topics
Group related contentPII or sensitive data

Specifications

SpecValue
Max file size50MB
Chunk size~250 tokens
Search latency40-120ms

FAQ

What file formats work best?

Markdown and plain text yield the best results. PDFs work well if they’re text-based (not scanned images). Use OCR preprocessing for scanned documents.

How often is content re-indexed?

Uploaded files are indexed once at upload. External connectors (Google Drive) sync based on your configuration—typically every 1-24 hours.

Can I preview what chunks were created?

Not via API currently. Use the Dashboard → Datasets → View to inspect chunks.

How do I improve retrieval quality?

  1. Use specific, descriptive filenames
  2. Add summaries at the start of documents
  3. Remove boilerplate/headers that repeat across pages
  4. Split very long documents into logical sections

What happens if I delete a document?

The document and its chunks are removed. This affects new chats only—existing chat histories retain their context.