Upload and process a document via uploadDocument. Supports both cloud URLs (UploadThing) and database paths (/api/files/...).
const response = await fetch("/api/uploadDocument", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
userId: "user_xxx",
documentUrl: "https://utfs.io/f/xxx", // or /api/files/123 for DB storage
documentName: "report.pdf",
category: "Compliance",
storageType: "cloud", // or "database"
mimeType: "application/pdf",
preferredProvider: "azure", // optional: azure, datalab, landing_ai
}),
});
const result = await response.json();For direct upload to database storage:
const formData = new FormData();
formData.append("file", file);
formData.append("userId", userId);
formData.append("documentName", file.name);
formData.append("categoryId", categoryId);
const response = await fetch("/api/upload-local", {
method: "POST",
body: formData,
});
const result = await response.json();const response = await fetch("/api/agents/documentQ&A/AIQueryRLM", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
documentId: "123",
message: "What are the key compliance requirements?",
categoryId: "456",
}),
});
const answer = await response.json();const response = await fetch("/api/agents/predictive-document-analysis", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
documentId: "123",
categoryId: "456",
}),
});
const analysis = await response.json();The unified ingestion layer supports:
- PDF — native extraction or OCR for scanned
- DOCX — Mammoth
- XLSX — SheetJS
- PPTX — custom adapter
- Images — OCR (Azure, Tesseract, etc.)
- CSV, text, HTML, Markdown — native or Cheerio
- OCR behavior is controlled via provider keys in environment variables.
- If OCR UI options are not visible, verify OCR keys are present.
- Use OCR for scanned/image-based PDFs; digital PDFs usually do not need it.
preferredProvidercan beazure,datalab, orlanding_aiwhen multiple are configured.