Interface ImageContent

All Superinterfaces:
ContentBlock, HasMeta

@Immutable public non-sealed interface ImageContent extends ContentBlock
An image provided to or from an LLM.

The image data is base64-encoded in data, with the corresponding mimeType describing the format (e.g. image/png, image/jpeg).

  • Method Details

    • data

      @Redacted String data()
      Returns the base64-encoded image data.
      Returns:
      the image data as a base64 string
    • mimeType

      String mimeType()
      Returns the MIME type of the image content.
      Returns:
      the image MIME type
    • annotations

      @Nullable Annotations annotations()
      Returns the annotations for this content, or null if none.
      Returns:
      the annotations, or null
    • meta

      @Nullable Map<String,Object> meta()
      Returns the request-level metadata for this content, or null if none.
      Specified by:
      meta in interface HasMeta
      Returns:
      the metadata entries, or null
    • type

      default ContentBlock.Type type()
      Description copied from interface: ContentBlock
      Returns the MCP protocol type discriminator for this content block variant.
      Specified by:
      type in interface ContentBlock
      Returns:
      the content type discriminator
    • check

      @Check default void check()
      Validates that required fields are not blank.
      Throws:
      IllegalArgumentException - if data or mimeType is blank
    • builder

      static ImageContent.Builder builder()
      Creates a new builder for constructing ImageContent instances.
      Returns:
      a new builder
    • base64

      static ImageContent base64(String data, String mimeType)
      Creates an image content block from base64-encoded data, with no metadata or annotations.
      Parameters:
      data - the base64-encoded image data
      mimeType - the image MIME type (e.g. image/png)
    • of

      @Deprecated(since="1.0.0-beta.15", forRemoval=true) static ImageContent of(String data, String mimeType)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates an image content block from base64-encoded data.
      Parameters:
      data - the base64-encoded image data
      mimeType - the image MIME type
      Returns:
      a new image content block
    • base64

      static ImageContent base64(String data, String mimeType, @Nullable Annotations annotations)
      Creates an image content block from base64-encoded data with given annotations and no metadata.
    • of

      @Deprecated(since="1.0.0-beta.15", forRemoval=true) static ImageContent of(String data, String mimeType, @Nullable Annotations annotations)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates an image content block from base64-encoded data with annotations.
      Parameters:
      data - the base64-encoded image data
      mimeType - the image MIME type
      annotations - the annotations, or null
      Returns:
      a new image content block
    • base64

      static ImageContent base64(String data, String mimeType, @Nullable Annotations annotations, @Nullable Map<String,Object> meta)
      Creates an image content block from base64-encoded data with metadata and optional annotations.
    • of

      @Deprecated(since="1.0.0-beta.15", forRemoval=true) static ImageContent of(String data, String mimeType, @Nullable Annotations annotations, @Nullable Map<String,Object> meta)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates an image content block from base64-encoded data with annotations and metadata.
      Parameters:
      data - the base64-encoded image data
      mimeType - the image MIME type
      annotations - the annotations, or null
      meta - the metadata, or null
      Returns:
      a new image content block