Root field pdf_preprocess
When POST /v1/chat/completions messages contain a parseable PDF (validated input_file in a user message, normalized internally to a file part with file_data / file_id / file_url), this service may preprocess the PDF before forwarding upstream.
Default behavior (important)
- Omit root
pdf_preprocess, or pass an object withoutengine: both meannative—no expansion; keep the file part for upstream (model must support native PDF input). engineonly fails validation on invalid values (400 / invalid body).false/null: disables the preprocess config object (exact semantics vs “omit object” follow the README).
engine values
engine | Behavior |
|---|---|
native | No expansion; keep normalized file part. |
ocr | Replace the PDF part with per-page JPEG image_url (data URLs); no [PDF] meta line or full text layer; user text in the same user message is kept. |
markdown | Meta text + Markdown-style text from the PDF text layer (no complex layout fidelity). |
Optional parameters
max_pages: defaults and caps inpdf-preprocess/constants(README summary; typical default 10, cap 50 order of magnitude).merge_pages: whentrue, affectsocrrendering only (merge pages vertically into one JPEG).
Runtime and ops
- WASM: env
GATEWAY_PDFIUM_WASM_PATHpoints topdfium.wasm; if unset, try@embedpdf/pdfiumpackage path (depends on cwd—set explicitly in production). - Preprocess failures may return 4xx / 504 with
error.codesuch aspdf_password_required,pdf_expand_too_large, etc.—full list and size/timeout limits in the README and constants source.
SDK mapping
Put config in chatRequest.plugins.pdf; @routerbrain/sdk serializes it to JSON root pdf_preprocess—see SDK: chat.send.
See also
- Deployment README “PDF preprocessing” section
- Chat Completions