Document Processing
The three-step upload flow and what happens behind the scenes
The three-step upload flow and what happens behind the scenes
Getting a document into Pyramid AI is a three-step process. This design keeps uploads fast and reliable — even for large files — by separating the upload from the processing.
Tell the API you’re about to upload a file. You provide the file name, type, and size. The API returns a presigned upload URL — a temporary, secure link where you’ll send the actual file.
Response:
The upload URL expires after 2 hours. If it expires before you upload, call the reserve endpoint again to get a fresh URL.
The file goes directly from your system to cloud storage — it never passes through the Pyramid API server. This means:
Send the actual file bytes to the presigned URL using a PUT request. This is a direct upload to cloud storage — no API key needed (the URL itself contains the authorization).
Use --data-binary (not -d) to preserve the file’s binary content. Using -d will corrupt binary files like PDFs.
Once the file is uploaded, tell the API to start processing it. You can submit multiple document IDs at once.
Response:
Behind the scenes, the processing pipeline does the following:
The system reads the file and extracts all text content. For PDFs, this includes OCR (optical character recognition) for scanned documents.
The extracted text is split into overlapping chunks — typically a few paragraphs each. Overlap ensures context isn’t lost at chunk boundaries.
Poll the document endpoint to check when processing is complete:
Watch the status field:
Processing typically takes 10–60 seconds for a standard PDF. Large documents (100+ pages) or scanned PDFs with OCR may take longer.
Common processing failures:
For uploading many files at once, repeat the reserve → upload → process cycle for each file, then call process with all document IDs:
This is more efficient than processing one at a time, as the pipeline can parallelize the work.