Class: RunApi::Seedream::Resources::EditImage

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

Overview

Seedream image editing resource. Modifies source images according to a text prompt. 5 Pro and V4 accept up to 10 source images; 4.5 and 5-Lite accept up to 14.

Constant Summary collapse

ENDPOINT =
"/api/v1/seedream/edit_image"
RESPONSE_CLASS =
Types::EditImageResponse
COMPLETED_RESPONSE_CLASS =
Types::CompletedEditImageResponse
PROMPT_MAX_LENGTH =
3000
V4_PROMPT_MAX_LENGTH =
5000
PROMPT_MIN_LENGTH_LITE =
3

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ EditImage

Returns a new instance of EditImage.



19
20
21
# File 'lib/runapi/seedream/resources/edit_image.rb', line 19

def initialize(http)
  @http = http
end

Instance Method Details

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



28
29
30
31
32
# File 'lib/runapi/seedream/resources/edit_image.rb', line 28

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



34
35
36
# File 'lib/runapi/seedream/resources/edit_image.rb', line 34

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

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



23
24
25
26
# File 'lib/runapi/seedream/resources/edit_image.rb', line 23

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