Contents

Attachment

An asset provided to the model.

Declaration

struct Attachment<Content> where Content : AttachmentContent

Mentioned in

Overview

Use Attachment to include media such as images alongside text in your prompts and instructions.

let response = try await session.respond {
    "Describe this image:"
    Attachment(image)
}

Use the label(_:) method to assign a label to an attachment. Labels help the model identify specific attachments when making tool calls.

Prompt {
    "Compare these two images:"
    Attachment(firstImage)
        .label("image-0")
    Attachment(secondImage)
        .label("image-1")
}

Topics

Creating an attachment instance

Assigning a label

See Also

Prompt attachments