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