Monoize
Transforms

Image: compress response images

Re-encode assistant images and tool images in responses and streams.

What it does

This transform re-encodes assistant images and typed images in tool results. It also processes image data URLs and image blocks in JSON function-tool arguments. The options match image_compress_input.

In streams, incomplete function argument fragments stay unchanged. The complete terminal arguments use the compressed image. Custom-tool input and unrelated Base64 stay unchanged.

When the selected output format is jpg, images with an alpha channel remain unchanged. The transform preserves their original bytes, media type, and dimensions. This applies even when every pixel is opaque. It overrides max_edge_px and skip_if_smaller in both responses and streams. Formats that support alpha continue to use the configured compression settings.

Reference

PropertyValue
Type IDimage_compress_output
Phaseresponse
ScopesProvider, API key

When to use

  • Image-generation responses are large and clients pay for transfer.
  • You want a uniform output format, for example WebP, regardless of the upstream format.

Configuration

OptionTypeRequiredDefaultDescription
output_formatstringNo"original"original, jpg, jpegxl_lossless, jpegxl, webp_lossless, webp, or png.
max_edge_pxintegerNo—Maximum width or height in pixels. Omit to keep the original dimensions.
jpeg_qualityintegerNo80Quality 1-100 for JPEG output.
jpegxl_qualityintegerNo90Quality 1-99 for lossy JPEG XL output.
jpegxl_effortintegerNo7JPEG XL encoding effort 1-10. Higher values compress more slowly.
webp_qualityintegerNo80Quality 1-100 for lossy WebP output.
skip_if_smallerbooleanNotrueKeep the original image when compression does not reduce the payload size.

Example rule

{
  "transform": "image_compress_output",
  "enabled": true,
  "phase": "response",
  "models": [
    "*image*"
  ],
  "config": {
    "output_format": "webp",
    "webp_quality": 80
  }
}

On this page