Message parts

Message userMsg = Message.builder()
    .role(Role.USER)
    .addPart(MessagePart.text("What's in this image?"))
    .addPart(MessagePart.fileFromPath(Path.of("chart.png")))
    .build();
Advertisement

Supported types

  • Images: JPEG, PNG, WebP up to 20MB.
  • PDFs: up to 1000 pages.
  • Audio: MP3, WAV up to 8.4 hours.
  • Video: MP4 up to 1 hour (Gemini 2.5).
Advertisement

Inline vs Cloud Storage

Small files (<20MB) go inline as base64. Larger files upload to Cloud Storage first, then reference via gs://.