ReqLLM.Images (ReqLLM v1.14.0)

View Source

Image generation functionality for ReqLLM.

This module provides image generation capabilities with support for:

  • Prompt-based image generation (generate_image/3)
  • Model validation for image support

Image results are returned as canonical ReqLLM.Response structs where the assistant message contains ReqLLM.Message.ContentPart entries of type :image and/or :image_url.

Summary

Functions

Generates images using an AI model with full response metadata.

Returns the base image generation options schema.

Returns a list of model specs that likely support image generation.

Validates that a model supports image generation operations.

Functions

generate_image(model_spec, prompt_or_messages, opts \\ [])

@spec generate_image(
  ReqLLM.model_input(),
  String.t() | list() | ReqLLM.Context.t(),
  keyword()
) :: {:ok, ReqLLM.Response.t()} | {:error, term()}

Generates images using an AI model with full response metadata.

Returns a canonical ReqLLM.Response where images are represented as message content parts.

schema()

@spec schema() :: NimbleOptions.t()

Returns the base image generation options schema.

supported_models()

@spec supported_models() :: [String.t()]

Returns a list of model specs that likely support image generation.

Uses capability metadata when present, otherwise falls back to a conservative name-based heuristic (models containing "image" or "imagen").

validate_model(model_spec)

@spec validate_model(ReqLLM.model_input()) ::
  {:ok, LLMDB.Model.t()} | {:error, term()}

Validates that a model supports image generation operations.