This quickstart covers the parsing endpoint and is the fastest way to try Unsiloed AI. If you’d rather start with another capability, see the Extraction quickstart, the Classification guide, or the Splitting guide.
/parse endpoint, polls until parsing finishes, and saves the parsed result to disk as both JSON and Markdown. The full script is available in the dropdown below if you’d rather copy it and skip the walkthrough.
Show the Full Script
Show the Full Script
Set
UNSILOED_API_KEY in your environment and save the document you want to parse as document.pdf in the same directory before running.- Python
- JavaScript
- cURL
parse_document.py
Step 1: Set Up Your Environment
Before writing any code, we need three things: an API key, a document, and the runtime for our chosen language.1.1 Get an Unsiloed AI API Key
To get API access, sign up on Unsiloed AI. Export your key as an environment variable namedUNSILOED_API_KEY so it stays out of source control:
1.2 Pick a Document to Parse
The/parse endpoint supports PDF, DOCX, PPTX, JPG, PNG, and other formats. The walkthrough below assumes a PDF saved as document.pdf in your working directory. To use a different format, update the filename and content type in the snippets to match your file.
If you don’t have a document handy, download our sample PDF (a one-page Q1 2024 Sales Report) and save it as document.pdf.
1.3 Install Dependencies
- Python
- JavaScript
- cURL
You need Python 3.8 or newer. Install the
requests package:Step 2: Submit a Document
The/parse endpoint accepts a multipart upload and returns a job_id we can poll for results. All requests go to https://prod.visionapi.unsiloed.ai with the API key in the api-key header.
2.1 Set Up the Script
- Python
- JavaScript
- cURL
Create a file called
parse_document.py and start with the imports and configuration:parse_document.py
API_KEY reads your key from the environment so it doesn’t get hard-coded into the file, and BASE_URL points at the Unsiloed AI production endpoint. We’ll reuse both in every request below.2.2 Upload the Document
Send the file as a multipart upload to/parse. The endpoint expects the document under the form field name file.
- Python
- JavaScript
- cURL
Continue the file by uploading the document:The
parse_document.py
raise_for_status() call throws an HTTPError on any non-2xx response, so we don’t need to check .status_code ourselves.2.3 Capture the Job ID
- Python
- JavaScript
- cURL
Next, read and print the Run the script:The output should be a single line like
job_id:parse_document.py
Job submitted: 1699d429-9c2e-464e-b311-d4b68a8444b8.Step 3: Poll for Results
The job runs asynchronously. We GET/parse/{job_id} repeatedly until the status is Succeeded, then save the parsed output to disk.
A status of Succeeded means the result is ready; Failed means the job errored; any other value (Starting, Processing, and so on) means the job is still running.
3.1 Write the Polling Loop
- Python
- JavaScript
- cURL
Then drop in a polling loop. The
max_attempts cap stops the loop if the job hangs:parse_document.py
3.2 Save the Parsed Output
Persist the result to disk so downstream code can read it. We’ll write two files:result.json (the full response, including job metadata and segment-level layout) and output.md (the concatenated Markdown, suitable for previewing or feeding into a RAG pipeline).
- Python
- JavaScript
- cURL
Finally, write the result to disk:Run the script:You should see a few
parse_document.py
Status: Processing lines, then Status: Succeeded, then a final summary line. The two output files appear in the working directory.Error Responses
Failures fall into two buckets: HTTP errors raised before the job is queued, and aFailed status on a job that started but couldn’t complete.
HTTP Errors
The/parse endpoint returns plain-text bodies on HTTP errors, not JSON. Calling response.json() on them raises, so check the status code before parsing. The common cases:
401 Unauthorized: body isInvalid API key: Invalid API key. Theapi-keyheader is missing or wrong.400 Bad Request: body isContent type error. The upload form is malformed, usually because the file field isn’t multipart.404 Not Found: body isTask not found. Thejob_idyou polled doesn’t exist.
Failed Jobs
A job that was accepted but couldn’t be processed comes back withstatus: "Failed". The response shape matches a successful one, but chunks is empty and the message field describes what went wrong. For example, submitting a corrupt PDF returns:
Response Shape
A successful response contains job metadata plus achunks[] array. Each chunk has an embed Markdown string and an array of layout segments with their original positions on the page.
chunks[].embed: the chunk’s content rolled up as Markdown, ready to pass to an embedder. This is the field the walkthrough writes tooutput.md.
chunks[].segments[]: the layout primitives the chunk is built fromsegments[].segment_type: the region’s type, for exampleText,Table, orSectionHeader(see Element Types for the full set)segments[].bbox: the segment’s position on its page; pair it withpage_numberto identify which pagesegments[].markdown,html,content: the segment rendered as Markdown, HTML, or plain textsegments[].image: signed URL to a cropped image of the segmentsegments[].ocr: word-level OCR boxes for highlighting matches in the source PDFsegments[].confidence: the parser’s confidence in this segment’s classification, on a 0-1 scale. Lower values flag ambiguous regions but don’t necessarily mean the content is wrong, so treat it as a debugging signal rather than a hard threshold.
status:Succeeded,Failed, or one of the in-progress values (Starting,Processing, and so on)total_chunks: number of chunks in the resultcredit_used: credits consumed by this job
Sample Markdown Output
Running the script with the sample PDF writes this tooutput.md:
chunks[].embed joined with blank lines. The parser keeps headings, paragraphs, and tables as Markdown, so the output is ready to embed for RAG without further processing.
Next Steps
For more on parsing, including element types, processing modes, response format, and presigned URLs, see the Parsing overview.
Parsing Options
Configure chunking strategies, segment filters, and the OCR backend.
Structured Extraction
Pull typed fields out of a document using a JSON schema.
API Reference
Browse the full request and response specs for every endpoint.
FAQ
Check limits, supported formats, and answers to common questions.

