Class: RunApi::Wan::Resources::ImageToVideo

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

Overview

Generates videos driven by a source image. Flash variants trade fidelity for speed; 2.7 adds last-frame control, video continuation, and audio features.

Constant Summary collapse

ENDPOINT =
"/api/v1/wan/image_to_video"
RESPONSE_CLASS =
Types::VideoTaskResponse
COMPLETED_RESPONSE_CLASS =
Types::CompletedVideoTaskResponse

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ ImageToVideo

Returns a new instance of ImageToVideo.



15
16
17
# File 'lib/runapi/wan/resources/image_to_video.rb', line 15

def initialize(http)
  @http = http
end

Instance Method Details

#create(**params) ⇒ RunApi::Wan::Types::VideoTaskResponse

Create an image-to-video generation task.

Parameters:

  • params (Hash)

    image-to-video parameters

Returns:



32
33
34
35
36
# File 'lib/runapi/wan/resources/image_to_video.rb', line 32

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

#get(id) ⇒ RunApi::Wan::Types::VideoTaskResponse

Get image-to-video status by task ID.

Parameters:

  • id (String)

    task ID

Returns:



42
43
44
# File 'lib/runapi/wan/resources/image_to_video.rb', line 42

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

#run(**params) ⇒ RunApi::Wan::Types::CompletedVideoTaskResponse

Generate a video from an image and wait until complete.

Parameters:

  • params (Hash)

    image-to-video parameters

Returns:



23
24
25
26
# File 'lib/runapi/wan/resources/image_to_video.rb', line 23

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