Class: RunApi::Runway::Resources::TextToVideo

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

Overview

Runway text-to-video resource. Generate video from a text prompt, optionally using a first-frame image for image-to-video generation.

Constant Summary collapse

ENDPOINT =
"/api/v1/runway/text_to_video"
RESPONSE_CLASS =
Types::TaskCreateResponse
COMPLETED_RESPONSE_CLASS =
Types::CompletedTaskResponse

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ TextToVideo

Returns a new instance of TextToVideo.



15
16
17
# File 'lib/runapi/runway/resources/text_to_video.rb', line 15

def initialize(http)
  @http = http
end

Instance Method Details

#create(**params) ⇒ RunApi::Runway::Types::TaskCreateResponse

Create a text-to-video task without waiting for completion.

Parameters:

  • params (Hash)

    text-to-video parameters (see #run for details)

Returns:



38
39
40
41
42
# File 'lib/runapi/runway/resources/text_to_video.rb', line 38

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

#get(id) ⇒ RunApi::Runway::Types::TaskResponse

Get text-to-video task status by task ID.

Parameters:

  • id (String)

    task ID

Returns:



48
49
50
# File 'lib/runapi/runway/resources/text_to_video.rb', line 48

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

#run(**params) ⇒ RunApi::Runway::Types::CompletedTaskResponse

Create a text-to-video task and wait until complete.

Parameters:

  • prompt (String)

    video description prompt

  • duration_seconds (Integer)

    video length: 5 or 10

  • output_resolution (String)

    ā€œ720pā€ or ā€œ1080pā€

  • first_frame_image_url (String, nil)

    opening frame image URL for image-to-video

  • aspect_ratio (String, nil)

    only for pure text-to-video (no first-frame image)

  • watermark (String, nil)

    watermark text burned into the output

  • callback_url (String, nil)

    webhook URL for completion notification

Returns:



29
30
31
32
# File 'lib/runapi/runway/resources/text_to_video.rb', line 29

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