Open a PDF or scan
open_pdfOpen a PDF (or an image of a form: JPG/PNG/TIFF) and detect its fields.
The document comes from exactly ONE of:
- `file`: a PDF/image the user attached in the chat, for clients that
provide file parameters (no upload needed). A file without a
download_url cannot be fetched; an upload_token covers that case,
- `url`: a public link to the document,
- `upload_token`: from request_file_upload, for files on the user's
device or chat attachments that `file` cannot carry,
- `file_base64`: exact bytes of a small file (< ~200 KB). Larger base64
passed through a model gets truncated, and a compressed or rebuilt file
breaks field detection and no longer matches its template.
Resolution order: saved template (deterministic) -> embedded AcroForm ->
ML detection with per-field confidence. force_detect=True skips templates.
ML detection scans only the first `max_pages` pages; for a longer document
the result lists `unprocessed_page_indices`, which another open_pdf call
with a larger max_pages scans.
Returns a 24-hour `workspace_id` (`summary.workspace_id`), which every
subsequent workspace tool takes.
When to use:
- Call `open_pdf` once to load a document and initialize a workspace (or call
it again with a larger `max_pages` or `force_detect=True`).
- Use `list_fields` to re-read fields in an already-open workspace without
re-running detection, or `list_templates` to browse saved account templates.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | Public HTTP or HTTPS URL of the PDF or form image (JPG, PNG, TIFF, WEBP; max 50 MB). Mutually exclusive with `file`, `upload_token`, and `file_base64`. | |
| file | No | ||
| filename | No | Display filename for the workspace and default output filename stem (e.g. `'w9.pdf'`). Automatically inferred from the attachment or URL path when left at the default `'document.pdf'`. | document.pdf |
| max_pages | No | Maximum number of pages (starting from page 0, minimum 1) to scan during ML field detection. Unscanned pages are reported in `summary.unprocessed_page_indices`. | |
| file_base64 | No | Base64-encoded bytes of a small unmodified PDF or image (< ~200 KB). For larger files, use `file`, `url`, or `request_file_upload` + `upload_token` to avoid model truncation. Mutually exclusive with `file`, `url`, and `upload_token`. | |
| force_detect | No | If `True`, skips saved account templates and embedded AcroForm fields and forces a fresh ML detection pass across the first `max_pages` pages. | |
| upload_token | No | One-time upload token returned by `request_file_upload` after the file has been uploaded (or `'latest'` to use the most recent unconsumed upload). Mutually exclusive with `file`, `url`, and `file_base64`. | |
| min_confidence | No | Minimum ML detection confidence threshold in `0.0`–`1.0` (inclusive). ML-detected fields scoring below `min_confidence` are omitted; deterministic template and AcroForm fields always have confidence `1.0` and are kept. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||