Overview
This guide walks you through parsing one or more files with the Sciforium API, extracting plain text from the results, and sending that text to an LLM with a question.Prerequisites
- A Sciforium API key — get one at console.sciforium.com
- Python 3.8+
- The file(s) you want to parse accessible on disk (or uploaded to Colab — see the note below)
Step 1 — Configuration
Set the four variables below before running anything else.FILE_PATH— absolute path to the file you want to parse. Supported formats: PDF, DOCX, DOC, TXT, MD, CSV, HTML, JSON - anyutf-8encoded file.QUESTION— the question you want to ask the LLM about the document.MODEL— the LLM model identifier (e.g.openai/gpt-oss-120b,anthropic/claude-sonnet-4-6).SCIFORIUM_API_KEY— your Sciforium API key.
Step 2 — Install dependencies
Run this once ifopenai or requests aren’t already installed.
Step 3 — Initialize the client
This constructs the Sciforium endpoint URLs and resolves the API key, falling back to theSCIFORIUM_API_KEY environment variable if set.
Step 4a — Parse a single file
Reads the file fromFILE_PATH, base64-encodes it, and POSTs it to the Sciforium parse endpoint. The response contains structured content (pages, text, metadata) for the file.
Step 4b — Batch parse (optional)
Use this instead of Step 4a to parse multiple files in parallel with a thread pool. Add all your file paths toFILE_PATHS.
Run either Step 4a or Step 4b — not both. If you use this batch step, update Step 6 to iterate over
parse_responses (plural) instead of parse_response.Step 5 — Inspect the raw response (optional)
Print the full JSON to explore the response schema or debug issues. You can skip this step — it has no side effects.Step 6 — Extract text from parse results
This walks the parse response and stitches all page text into a singledocument_text string. Pages are labeled [Page N] so the LLM can reference them. Files that failed to parse are skipped with a warning.
Step 7 — Ask the LLM
Senddocument_text plus your QUESTION to the configured model via the Sciforium OpenAI-compatible gateway.