Normandy.Components.ContentBlock.Image
(normandy v0.6.2)
View Source
Represents an image content block inside a multimodal message.
Supports two source types:
:base64— inline base64-encoded image data with a media type.:url— hosted image referenced by URL.
Use alongside Normandy.Components.ContentBlock.Text in a list assigned to
a message's :content field to send an image to a Claude model.
Cache control
An optional cache_control field carries an Anthropic prompt-cache
breakpoint annotation that the adapter ships verbatim on the wire.
Use with_cache/1 for the default ephemeral type, or with_cache/2
for a custom map (e.g. %{"type" => "ephemeral", "ttl" => "1h"}).
Atom keys are accepted and stringified at serialization time.
Summary
Functions
Builds a base64-sourced image block. media_type (e.g. "image/png",
"image/jpeg") is required and positional — matching the Anthropic API,
where the server cannot infer the format from the raw bytes.
Builds a URL-sourced image block.
Converts the block into the Anthropic/Claudio content-block map shape
(string keys). Includes cache_control only when set.
Annotates this block with an ephemeral cache breakpoint.
Annotates this block with a caller-supplied cache_control map.
Types
Functions
Builds a base64-sourced image block. media_type (e.g. "image/png",
"image/jpeg") is required and positional — matching the Anthropic API,
where the server cannot infer the format from the raw bytes.
Builds a URL-sourced image block.
Converts the block into the Anthropic/Claudio content-block map shape
(string keys). Includes cache_control only when set.
Raises ArgumentError when the struct is in an incomplete state (e.g.
source: :base64 with nil data, or source: :url with nil url).
The constructors (new_base64/2, new_url/1) enforce valid state, so
this only fires when a caller bypasses them.
Annotates this block with an ephemeral cache breakpoint.
Annotates this block with a caller-supplied cache_control map.
Atom keys are accepted; they are stringified when serialized.