Class: RunApi::Imagen4::Resources::TextToImage

Inherits:
Object
  • Object
show all
Includes:
Core::ResourceHelpers
Defined in:
lib/runapi/imagen_4/resources/text_to_image.rb

Overview

Imagen 4 text-to-image generation resource. Generate images from text with three quality tiers.

Constant Summary collapse

ENDPOINT =
"/api/v1/imagen_4/text_to_image"
RESPONSE_CLASS =
Types::TextToImageResponse
COMPLETED_RESPONSE_CLASS =
Types::CompletedTextToImageResponse

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ TextToImage

Returns a new instance of TextToImage.



15
16
17
# File 'lib/runapi/imagen_4/resources/text_to_image.rb', line 15

def initialize(http)
  @http = http
end

Instance Method Details

#create(options: nil, **params) ⇒ Object



24
25
26
27
28
# File 'lib/runapi/imagen_4/resources/text_to_image.rb', line 24

def create(options: nil, **params)
  params = compact_params(params)
  validate_params!(params)
  request(:post, ENDPOINT, body: params, options: options)
end

#get(id, options: nil) ⇒ Object



30
31
32
# File 'lib/runapi/imagen_4/resources/text_to_image.rb', line 30

def get(id, options: nil)
  request(:get, "#{ENDPOINT}/#{id}", options: options)
end

#run(options: nil, **params) ⇒ Object



19
20
21
22
# File 'lib/runapi/imagen_4/resources/text_to_image.rb', line 19

def run(options: nil, **params)
  task = create(options: options, **params)
  poll_until_complete { get(task.id, options: options) }
end