NAME

Langertha::Role::ImageGeneration - Role for engines that support image generation

VERSION

version 0.503

DESCRIPTION

Engines that can generate images consume this role. It requires image_request and simple_image methods, and provides an image_model attribute, the async "simple_image_f" and "simple_image_result" / "simple_image_result_f".

image_model

The model name to use for image generation requests. Lazily defaults to default_image_model if the engine provides it, otherwise falls back to the general model attribute from Langertha::Role::Models.

simple_image_f

my $images = await $engine->simple_image_f('A cat in space', size => '1024x1024');

Async variant of simple_image: same arguments, returns a Future that resolves to the same value (for the OpenAI dialect an ArrayRef of image objects, see "image_response" in Langertha::Role::OpenAICompatible) and fails with the same error text. The request goes through the engine's async backend (Langertha::Role::AsyncHTTP), so "user_agent_timeout" in Langertha::Role::HTTP bounds it on Net::Async::HTTP too; without that module it runs synchronously over LWP.

simple_image_result

my $result = $engine->simple_image_result('A cat in space');
my $images = $result->value;
say $result->usage->output_tokens if $result->has_usage;

Like simple_image, but returns a Langertha::CallResult: the same image objects as value, plus the provider's usage (GPT image models report tokens), this response's rate_limit, the model and the measured total_seconds. Croaks like simple_image.

simple_image_result_f

my $result = await $engine->simple_image_result_f('A cat', size => '1024x1024');

Async variant of "simple_image_result", sent like "simple_image_f": resolves to the Langertha::CallResult and fails with the same error text.

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.