Class: RunApi::Wan::Resources::TextToImage
- Inherits:
-
Object
- Object
- RunApi::Wan::Resources::TextToImage
- Includes:
- Core::ResourceHelpers
- Defined in:
- lib/runapi/wan/resources/text_to_image.rb
Overview
Generates images from text prompts with optional color palette and bounding box constraints. Supports batch generation via output_count. Pro model supports thinking_mode for enhanced prompt reasoning.
Constant Summary collapse
- ENDPOINT =
"/api/v1/wan/text_to_image"- RESPONSE_CLASS =
Types::ImageTaskResponse
- COMPLETED_RESPONSE_CLASS =
Types::CompletedImageTaskResponse
Instance Method Summary collapse
-
#create(**params) ⇒ RunApi::Wan::Types::ImageTaskResponse
Create a text-to-image generation task.
-
#get(id) ⇒ RunApi::Wan::Types::ImageTaskResponse
Get text-to-image status by task ID.
-
#initialize(http) ⇒ TextToImage
constructor
A new instance of TextToImage.
-
#run(**params) ⇒ RunApi::Wan::Types::CompletedImageTaskResponse
Generate an image and wait until complete.
Constructor Details
#initialize(http) ⇒ TextToImage
Returns a new instance of TextToImage.
16 17 18 |
# File 'lib/runapi/wan/resources/text_to_image.rb', line 16 def initialize(http) @http = http end |
Instance Method Details
#create(**params) ⇒ RunApi::Wan::Types::ImageTaskResponse
Create a text-to-image generation task.
33 34 35 36 37 |
# File 'lib/runapi/wan/resources/text_to_image.rb', line 33 def create(**params) params = compact_params(params) validate_params!(params) request(:post, ENDPOINT, body: params) end |
#get(id) ⇒ RunApi::Wan::Types::ImageTaskResponse
Get text-to-image status by task ID.
43 44 45 |
# File 'lib/runapi/wan/resources/text_to_image.rb', line 43 def get(id) request(:get, "#{ENDPOINT}/#{id}") end |
#run(**params) ⇒ RunApi::Wan::Types::CompletedImageTaskResponse
Generate an image and wait until complete.
24 25 26 27 |
# File 'lib/runapi/wan/resources/text_to_image.rb', line 24 def run(**params) task = create(**params) poll_until_complete { get(task.id) } end |