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
MODEL =
"runway"

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ TextToVideo

Returns a new instance of TextToVideo.



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

def initialize(http)
  @http = http
end

Instance Method Details

#create(options: nil, **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:



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

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

#get(id, options: nil) ⇒ RunApi::Runway::Types::TaskResponse

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

Parameters:

  • id (String)

    task ID

Returns:



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

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

#run(options: nil, **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:



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

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