struct

Arcana::AI::Chat::ImagePart

Inherits Struct < Value < Object

An image in a chat message: a URL for the provider to fetch (https, or a data URL), or the bytes themselves.

Message.user("What does this picture show?", images: [ ImagePart.file("room.webp", detail: "low"), ImagePart.url("https://bucket.example/room.webp"), ])

Providers take them differently: OpenAI gets a URL (bytes as a data URL) and is the only one to use detail; Anthropic gets the bytes, or fetches an https URL itself; Gemini needs the bytes and can't fetch an https URL.

Constructors

bytes(data : Bytes, media_type : String, detail : String | Nil = nil) : self
Source
file(path : String, detail : String | Nil = nil) : self

Read an image file; the media type comes from its extension.

Source
url(url : String, detail : String | Nil = nil) : self
Source

Instance methods

data
Source
detail
Source
inline

The image as {media_type, base64 data}: the bytes, or the payload of a data URL. Nil for a URL the provider has to fetch.

Source
media_type
Source
to_url

The image as a URL: the one given, or a data URL of the bytes.

Source