| Input | Model receives |
|---|---|
| UTF-8 text file | The filename and decoded text |
| Directory | A non-recursive listing of its immediate files and directories |
| PNG, JPEG, GIF, or WebP | Image media |
Add attachments
TUI
Type@ followed by a filename and select the result to attach a project file.
This is the preferred way to add source code and other text files:
Ctrl+V by
default. You can also drag a supported image into a terminal that exposes the
dropped file path to the TUI. The TUI reads PNG, JPEG, GIF, and WebP as image
attachments; a dropped SVG is inserted as text.
Desktop and web
Use Attach file, paste, or drag and drop. Attach UTF-8 text or a PNG, JPEG, GIF, or WebP image. The desktop file picker limits one selection to 20 MiB in total; the server also applies the per-attachment limit described below.CLI
Pass--file or -f to opencode2 run. Repeat the flag for multiple files:
API
The V2 prompt and command payloads accept afiles array. Each item requires a
uri and can include name and description:
file: URL for a file available to the server, or an inline
data URL:
file: URL, optional positive start and end query parameters
select one-based lines:
Configure image processing
Configure image normalization inopencode.json or opencode.jsonc:
opencode.jsonc
| Field | Default | Behavior |
|---|---|---|
auto_resize | true | Resize an image that exceeds any configured limit. If false, reject it. |
max_width | 2000 | Maximum width in pixels. Must be a positive integer. |
max_height | 2000 | Maximum height in pixels. Must be a positive integer. |
max_base64_bytes | 5242880 | Maximum byte length of the Base64-encoded image string. Must be a positive integer. |
In the current V2 runtime, these settings apply to image media produced by
the built-in
read tool. Images attached directly through the TUI, desktop,
web, CLI, or API bypass this normalization. Resize direct attachments before
adding them if the provider requires smaller media.read tool recognizes PNG, JPEG, GIF, and WebP by their contents and will
ingest at most 20 MiB of source image bytes. It decodes the image and compares
its width, height, and encoded Base64 length with all three configured limits.
When auto_resize is true, OpenCode preserves the aspect ratio, scales the
image down to the dimension limits, and tries progressively smaller PNG and
JPEG encodings until the Base64 limit is met. The resulting media type can
therefore change to PNG or JPEG. If no encoding fits, the tool call fails.
When auto_resize is false, exceeding any limit fails the tool call without
modifying the image. An image that cannot be decoded also fails. If the image
resizer cannot be loaded, the read tool returns the
original image instead, so these settings are processing limits rather than an
upload or security boundary.
Limits and provider behavior
- Direct prompt attachments are limited to 20 MiB decoded per item by the V2 server. Client-specific limits can be lower.
max_base64_bytescounts the encoded Base64 characters in bytes, not the decoded file size and not the completedata:URL.- Text attachments are inserted into the prompt as text and do not require a
multimodal model. Large text read through the
readtool has separate paging and truncation limits. - Image attachments use provider-native image input. Provider errors can still occur when OpenCode’s limits pass but the selected model’s limits do not.
- PDFs and other unsupported binary prompt attachments should be converted to text or supported images before attaching them.