Class: RunApi::Qwen2::Resources::TextToImage
- Inherits:
-
Object
- Object
- RunApi::Qwen2::Resources::TextToImage
- Includes:
- Core::ResourceHelpers
- Defined in:
- lib/runapi/qwen_2/resources/text_to_image.rb
Overview
Qwen2 text-to-image resource. Generates images with natural-language prompts.
Constant Summary collapse
- ENDPOINT =
"/api/v1/qwen_2/text_to_image"- RESPONSE_CLASS =
Types::TextToImageResponse
- COMPLETED_RESPONSE_CLASS =
Types::CompletedTextToImageResponse
Instance Method Summary collapse
-
#create(**params) ⇒ RunApi::Qwen2::Types::TextToImageResponse
Create a text-to-image task.
-
#get(id) ⇒ RunApi::Qwen2::Types::TextToImageResponse
Get text-to-image status by task ID.
-
#initialize(http) ⇒ TextToImage
constructor
A new instance of TextToImage.
-
#run(**params) ⇒ RunApi::Qwen2::Types::CompletedTextToImageResponse
Generate an image and wait until complete.
Constructor Details
#initialize(http) ⇒ TextToImage
Returns a new instance of TextToImage.
15 16 17 |
# File 'lib/runapi/qwen_2/resources/text_to_image.rb', line 15 def initialize(http) @http = http end |
Instance Method Details
#create(**params) ⇒ RunApi::Qwen2::Types::TextToImageResponse
Create a text-to-image task.
32 33 34 35 36 |
# File 'lib/runapi/qwen_2/resources/text_to_image.rb', line 32 def create(**params) params = compact_params(params) validate_params!(params) request(:post, ENDPOINT, body: params) end |
#get(id) ⇒ RunApi::Qwen2::Types::TextToImageResponse
Get text-to-image status by task ID.
42 43 44 |
# File 'lib/runapi/qwen_2/resources/text_to_image.rb', line 42 def get(id) request(:get, "#{ENDPOINT}/#{id}") end |
#run(**params) ⇒ RunApi::Qwen2::Types::CompletedTextToImageResponse
Generate an image and wait until complete.
23 24 25 26 |
# File 'lib/runapi/qwen_2/resources/text_to_image.rb', line 23 def run(**params) task = create(**params) poll_until_complete { get(task.id) } end |