File attachments
Attachment support varies by client and file type. Keep original file bytes on your device. Send a file’s prepared text only after local tokenization and review. Leave a file out if your client cannot process it or show the prepared text for review. You can continue with the rest of the reviewed message. Detection can miss values, so check what your client shows. See Known limitations.
How it works
On a supported, reviewed client-side path:
- The client decodes the file and converts it to Markdown or text on your device.
- It adds the text to
messages[]. - It replaces detector matches with
<<CLOAK:…>>placeholders, also on your device. - It drops the raw file bytes.
- The CloakAPI gateway relays the request bytes. It does not process attachment bytes.
- The model provider receives what the client sent.
For direct gateway calls, the gateway does not process attachments[] as a file upload. The field is a legacy local-proxy input; a direct request must not rely on the gateway to remove or protect its base64 bytes.
Images and OCR
In the browser portal, extension, and desktop chat, review the text read on the device and the languages shown in the review. These clients default to English and supported browser or computer languages. The native SDK engine uses Tesseract with English by default. To use other languages with the native engine, install the packs and select them with CLOAK_OCR_LANGS or the C ABI’s ocr_langs option. See Reading text in images for the language settings of each client.
Clients
| Client | Where the file is processed | Review before sending | A file it cannot process |
|---|---|---|---|
| Browser portal | Extracted and tokenized on your device | Shows the prepared text | Left out with a notice |
| Desktop app | Read on your device; for cloud requests, tokenized on your device | Cloud requests: shows the exact outgoing text and waits for approval | Left out with a notice |
| Browser extension | On your device on supported upload paths | Review of the prepared attachment or placeholder on protected paths in version 0.1.97 | Omitted or represented by a placeholder, depending on the path |
| Local proxy | Converted and tokenized on your machine | No approval prompt | Omitted, with an attachment omitted note |
| Browser SDK | Extracted and tokenized in the browser | Your application must provide it | Returned as { ok: false, reason } |
| MCP server | On your machine; text and markup formats, not PDF, DOCX or XLSX | Up to the MCP host | — |
A dash means this page does not describe that behavior for the client.
Browser portal
In Chat (/chat), select the paperclip next to the composer to attach up to 5 files, or paste files from the clipboard (Ctrl/Cmd+V). The portal extracts and tokenizes supported file text on your device, then shows what it prepared so you can review it. An unreadable file is skipped with a notice; typed text can continue through review and send. If the receipt strip shows a count of tokenized files, that is a client-reported status; the signed fields do not independently prove file processing.
Desktop app
Select the attach button in the chat composer to open the native file picker. The app reads supported files on your device and adds the extracted text to the outgoing message. For cloud requests, the desktop app tokenizes extracted text on-device, shows the exact outgoing text and waits for approval before sending. A file it cannot read is left out with a notice. The file count in its receipt status is client-reported and is not independent proof of processing.
Browser extension
File-upload behavior varies by site. On some Claude and Grok upload paths, the extension prepares files on your device. On protected upload paths in version 0.1.97, a failed file relay does not send the original file. Where offered, you can leave the file out and continue with protected text, or cancel. On paths that offer a placeholder for an unsupported or unreadable file, you can review the placeholder before it is sent. Whether ChatGPT and Gemini accept substituted uploads has not been established. The tracked coverage map labels Claude and Grok full, and ChatGPT and Gemini text-only. The source contains upload-substitution tests for ChatGPT and Gemini, but they use synthetic capture stubs and do not prove that those providers accept the uploads today. Do not treat those test paths as verified upload support.
Local proxy
The local proxy accepts a non-standard attachments[] key, base64 in JSON, alongside the standard body. It decodes each file and converts it to Markdown or text on your machine with pure-Rust extractors (the same file pipeline the desktop app uses), adds the text to the message content, tokenizes it and strips the raw attachments[] before forwarding. If it cannot process a file, it omits that attachment, puts an attachment omitted note in its place and returns x-cloak-name-protection: reduced with a notice. It still tokenizes readable message text and files it can process.
The proxy forwards the processed text without an approval prompt. Keep files and images out of requests to the local proxy. Use a client that shows the exact prepared text and waits for approval.
Browser SDK
For a web app without the local proxy, the downloadable SDK’s browser entry, @cloakapi/sdk/browser, extracts a file’s text and tokenizes it in the browser. On this path the original file bytes stay on the device. cloakup uses this path to process files.
import { applyReviewDecisions, createBrowserEngine, extractFileForReview } from "@cloakapi/sdk/browser";
const engine = await createBrowserEngine(); // fail-closed: throws if unavailable
// Extract and tokenise ON-DEVICE. This does not send. protectFileForEgress is// not exported from @cloakapi/sdk/browser.const r = await extractFileForReview(file, { engine, pdfWorkerSrc });if (!r.ok) { // Show a non-blocking notice and leave this file out of the request. // Do not fall back to sending the original file bytes.} else { // r.body is a local candidate, not approval to POST. Show r.originalText and // r.spans, then build the reviewed text. Keep r.map on the device. const reviewed = applyReviewDecisions(r.originalText, r.spans); // Send reviewed.body only through a relay whose reviewRequest requires // approved === true and text === the exact string that will be posted.}extractFileForReview(file, { engine })returns{ ok: false, reason }for input the browser cannot extract. On success,bodyis a local candidate, not approval to send.applyReviewDecisions(originalText, spans, { decisions, manual })builds text from the decisions you pass. Your application must still show the content and reject a send unless the reviewed text is exactly the text submitted.protectFileForEgressis not exported from@cloakapi/sdk/browser.- The lower-level
extractTextFromFileonly extracts text; it does not tokenize it. - For an image the SDK cannot read, produce any caption or OCR text on the device before you pass it as
extractedText.
What the browser SDK extracts on your device today (parser dependencies load only when a file of that type is attached):
| Kind | Formats | Dependency (lazy import()) |
|---|---|---|
| Text | .txt .md .csv .tsv .json .xml .html .log .yaml … | none |
.pdf | pdfjs-dist (optional peer dep) | |
| Word | .docx | mammoth (optional peer dep) |
It cannot extract images, .xlsx or .pptx files, .zip archives or unknown binary files through extractTextFromFile. Leave out a file it cannot process, show a warning and let the user continue with the rest of the reviewed message. Do not send that file as raw bytes. Other clients may support more formats when they can extract, tokenize and show the prepared text for review.
pdfjs-dist and mammoth are optional peer dependencies of the SDK, reached only through dynamic import(). Install them in your app when you need PDF or Word support (npm i pdfjs-dist mammoth). An app that only needs text, CSV or JSON does not load them, and the SDK’s main bundle stays small.
MCP server
The MCP server’s file helper extracts supported text and markup formats. PDF, DOCX and XLSX files are not read directly. For images, install Tesseract and your language packs locally or supply pre-extracted text. Starting in 0.6.2, a local OCR read reports the languages it used and any unavailable packs. The MCP host controls any later network handling. See MCP server install and tool notes.
Supported formats
Each client reads a different set of formats. Leave a file out if the client cannot read it or show the prepared text for review.
| Format | Extensions | Browser portal, desktop app, browser extension | Browser SDK | MCP server | Local proxy |
|---|---|---|---|---|---|
| Plain text and Markdown | .txt, .log, .md, .markdown | Yes | Yes | Yes | Yes |
| CSV and TSV | .csv, .tsv | Yes | Yes | Yes | .csv only |
| JSON, XML, HTML, YAML | .json, .xml, .html, .htm, .yaml, .yml | Yes | Yes | Yes | Yes, except YAML |
| Jupyter notebook | .ipynb | Yes, as text | Only when the browser reports a JSON type | No | Yes |
| Email (MIME) | .eml | Yes | No | No | Yes |
.pdf | Yes | Yes, with pdfjs-dist | No | Yes | |
| Microsoft Word | .docx | Yes | Yes, with mammoth | No | Yes |
| Microsoft Word, legacy | .doc | No | No | No | Yes |
| Microsoft Excel | .xlsx, .xls | Yes | No | No | Yes |
| Microsoft PowerPoint | .pptx, .ppt | No | No | No | Yes |
| EPUB | .epub | No | No | No | Yes |
| OpenDocument and RTF | .odt, .ods, .odp, .rtf | No | No | No | Yes |
| Images | .png, .jpg, .jpeg, .webp, .bmp, .gif, .tiff, .tif | Yes, text read on the device | Supply locally extracted text | With a local Tesseract install or locally extracted text | Inline image data with local Tesseract |
| Source code and config files | .js, .ts, .py, .go, .toml, .ini and similar | No | Read as text when the browser reports a text type | Yes | No |
The portal and desktop file pickers also list .doc, .pptx, .ppt, .epub and .msg. Those files cannot be read on the device today so the client skips them and says so. Audio, video and archive files are not supported by the attachment flows described here.
Limits
| Limit | Value |
|---|---|
| Max file size | 20 MB per file (local proxy: CLOAK_DOCUMENT_MAX_BYTES, default 20 MiB) |
| Max files per request | 5 (portal, desktop app, extension) |
| Allowed formats | See Supported formats |
Receipt audit trail
When supported, a request with attachments can carry client-reported per-file attestations in its receipt: the format, file hashes before and after processing, and detector firings, under the registered v1.1-file-ext claim (see the extension registry). The receipt signature protects those recorded fields from undetected alteration; it does not prove that extraction or tokenization succeeded, or that every identifier was replaced.
{ "claims": { "file_attestations": [ { "mime": "application/pdf", "sha256_pre": "…", "sha256_post": "…", "exif_stripped": true, "processing_ms": 412 } ] }}To confirm that the signature and recorded fields are intact, verify the receipt with POST /api/v1/receipts/verify or in the browser at app.cloakapi.io/receipt-verifier; see Verification methods. Those fields do not prove that all file content was tokenized or that no raw content left the client.
Related
- File rebuild: rebuild a real file from a tokenized response, on the device that holds the alias map.
- Chat completions: streaming, idempotency and receipts.
- OpenReceipt protocol: the receipt envelope format.
- How privacy works: where tokenization happens.