Skip to main content
Pass any file — image, PDF, audio, text, video, a URL, a data: URI, or a pathlib.Path — to agent.start(...) and the router turns it into a model-visible part or tells you why it could not.
An attachment is never dropped silently: it either becomes a content part the model sees, or it raises, or it warns and leaves a marker part in the prompt so the model can say it answered without the file.

Quick Start

1

Attach an image at start()

2

Attach a PDF at chat()

A PDF-capable model receives the document as a file part; a non-PDF model gets locally-extracted text, labelled as extracted.
3

Mix file types in one list

Each entry is routed independently by its type — a Path, a local file, and a URL in the same call.

How the router decides

The router inspects each attachment’s extension, checks the target model’s capability, and picks one of three outcomes.

What each file type does

The outcome depends on the file type and the target model’s capability.
Remote non-image files are not downloaded — the router performs no network I/O. Download the file and pass its local path instead. Image URLs are passed to the model as-is.

What raises vs what warns

Two failure classes are treated differently on purpose.
Two environment escape hatches flip the defaults: PRAISONAI_ATTACHMENTS_ON_MISSING=warn downgrades a missing/unreadable raise to a warning + marker part, and PRAISONAI_ATTACHMENTS_STRICT=1 escalates capability degrades to raises for pipelines that would rather fail than get a partial answer.

Capability helpers

Check what a model can ingest before you attach — the same probes the router uses.
Images are deliberately not gated on supports_vision — some local/Ollama models are reported conservatively by the underlying provider table but still accept images, so gating them would break those runs. Images are always passed as image_url parts, byte-for-byte identical to earlier releases.

Error handling

AttachmentError subclasses ValueError, so any existing except ValueError around chat() keeps catching it.

Best Practices

Pass pathlib.Path("report.pdf") for local files. The router resolves it and dispatches by extension — earlier releases silently dropped Path objects because an isinstance(str) check was False.
Pass the raw path or URL — do not pre-encode to a data: URI yourself. The router chooses the right part shape (image_url, file, input_audio, or text) per file type and model capability.
Send big images and documents via attachments= rather than embedding them in the prompt string, so their bytes never fill the conversation history.
Wrap chat() / start() in except AttachmentError as e when processing a list of files, so one bad path does not abort the whole batch.

Multimodal Agents

Attach media to tasks and run vision workflows.

Multimodal Tool Output

Return images and media from tools back to the agent.