Class: RunApi::Flux::Resources::TextToImage

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

Constant Summary collapse

ENDPOINT =
"/api/v1/flux/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.



13
14
15
# File 'lib/runapi/flux/resources/text_to_image.rb', line 13

def initialize(http)
  @http = http
end

Instance Method Details

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



22
23
24
25
26
# File 'lib/runapi/flux/resources/text_to_image.rb', line 22

def create(options: nil, **params)
  params = compact_params(params)
  validate_contract!(CONTRACT["text-to-image"], params)
  request(:post, ENDPOINT, body: params, options: options)
end

#get(id, options: nil) ⇒ Object



28
29
30
# File 'lib/runapi/flux/resources/text_to_image.rb', line 28

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

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



17
18
19
20
# File 'lib/runapi/flux/resources/text_to_image.rb', line 17

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