Skip to documentation
Documentation navigation

Documentation navigation

Documentation / guides

ImageBlock

Represent remote or inline image input with an explicit MIME type.

developer

ImageBlock carries an image source and its MIME type. The source sum type is represented by one ImageSource value with either a URL or inline bytes.

API surface

type ImageSource struct {
	URL  string
	Data []byte
}

type ImageBlock struct {
	MediaType MediaType
	Source    ImageSource
}
FieldMeaningValid shape
MediaTypeMIME type such as MediaTypeImagePNGProvider and caller agree on supported types
Source.URLRemote image referenceSet for URL-backed input
Source.DataInline bytesSet for inline input

The source comment says to set exactly one of URL or Data. The core package does not add a validation method, so a provider codec must reject or normalize an invalid combination at its boundary. Model.Caps.AcceptsImages is the inference-layer admission check for any image nested in messages or tool-result content.

Example

package main

import "github.com/looprig/core/content"

func main() {
	remote := &content.ImageBlock{
		MediaType: content.MediaTypeImagePNG,
		Source:    content.ImageSource{URL: "https://example.test/chart.png"},
	}
	inline := &content.ImageBlock{
		MediaType: content.MediaTypeImageJPEG,
		Source:    content.ImageSource{Data: []byte{0xff, 0xd8}},
	}
	_ = []content.Block{remote, inline}
}

The inference request validator walks all four sealed message types and nested ToolResultBlock.Content; it returns *inference.ImageInputUnsupportedError when the model does not advertise image input.

Proof

Related: Model capabilities, Conversation input.

← back to documentation