Skip to main content

Overview

Attach images and other files to your prompts for tasks like image analysis or document processing.

Components

You must place <ImageAttachment> and <FileAttachment> inside a <User> tag. Placing them inside <System> or <Assistant> throws "ImageAttachment and FileAttachment tags must be inside User tag." at template compile time.

ImageAttachment

The <ImageAttachment> component attaches an image to your prompt:
Parameters:
  • image (required): URL to the image file
  • mimeType (optional): MIME type of the image (for example, image/jpeg, image/png)

FileAttachment

The <FileAttachment> component attaches any type of file:
Parameters:
  • data (required): URL to the file
  • mimeType (required): MIME type of the file (for example, application/pdf, text/plain)

Example

A complete prompt using both attachment types:
describe-media.prompt.mdx

Next steps

Attachments render into the prompt’s messages alongside the surrounding text. See the SDK usage section of Running prompts (under the Local tab) to render the prompt with prompt.format() and pass it to your SDK.

Have questions?

Reach out any time: