Validation for the images: option.
Images are base64 data URLs (data:image/png;base64,...); build one from bytes with
SystemOneClient.image_data_url/2. Only providers whose APIs accept images can take
them, and they are checked before any request is sent:
| Provider | Accepted | Limits checked locally |
|---|---|---|
:openai | any image/* data URL | none documented |
:cloudflare | PNG, JPEG, WebP | at most 4 images, 4 MiB each and 8 MiB in total, decoded |
| others | no | returns {:error, {:unsupported_option, :images, provider}} |
Remote http(s) image URLs are rejected for every provider because neither API
accepts them.
Summary
Functions
Checks images for provider.
Types
@type error() :: :images_not_a_list | {:unsupported_option, :images, atom()} | {:invalid_image, non_neg_integer(), :not_a_data_url | :invalid_base64 | :too_large | {:unsupported_type, String.t()}} | {:too_many_images, pos_integer(), pos_integer()} | {:images_too_large, non_neg_integer(), pos_integer()}
Functions
Checks images for provider.
iex> SystemOneClient.Images.validate(["data:image/png;base64,YWJj"], :openai)
:ok
iex> SystemOneClient.Images.validate(["https://example.com/a.png"], :openai)
{:error, {:invalid_image, 0, :not_a_data_url}}