Class: RunApi::Kling::Resources::ImageToVideo
- Inherits:
-
Object
- Object
- RunApi::Kling::Resources::ImageToVideo
- Includes:
- Core::ResourceHelpers
- Defined in:
- lib/runapi/kling/resources/image_to_video.rb
Overview
Kling image-to-video resource. Generate videos from an input image.
Constant Summary collapse
- ENDPOINT =
"/api/v1/kling/image_to_video"- RESPONSE_CLASS =
Types::ImageToVideoResponse
- COMPLETED_RESPONSE_CLASS =
Types::CompletedImageToVideoResponse
- V26_MODEL =
"kling-v2.6"- V3_OMNI_MODEL =
"kling-v3-omni"- V3_TURBO_MODEL =
"kling-v3-turbo-image-to-video"- V3_TURBO_UNSUPPORTED_FIELDS =
%i[ aspect_ratio negative_prompt cfg_scale last_frame_image_url ].freeze
Instance Method Summary collapse
-
#create(options: nil, **params) ⇒ RunApi::Kling::Types::ImageToVideoResponse
Create an image-to-video task.
-
#get(id, options: nil) ⇒ RunApi::Kling::Types::ImageToVideoResponse
Get image-to-video task status by task ID.
-
#initialize(http) ⇒ ImageToVideo
constructor
A new instance of ImageToVideo.
-
#run(options: nil, **params) ⇒ RunApi::Kling::Types::CompletedImageToVideoResponse
Generate an image-to-video task and wait until complete.
Constructor Details
#initialize(http) ⇒ ImageToVideo
Returns a new instance of ImageToVideo.
25 26 27 |
# File 'lib/runapi/kling/resources/image_to_video.rb', line 25 def initialize(http) @http = http end |
Instance Method Details
#create(options: nil, **params) ⇒ RunApi::Kling::Types::ImageToVideoResponse
Create an image-to-video task.
42 43 44 45 46 |
# File 'lib/runapi/kling/resources/image_to_video.rb', line 42 def create(options: nil, **params) params = compact_params(params) validate_params!(params) request(:post, ENDPOINT, body: params, options: ) end |
#get(id, options: nil) ⇒ RunApi::Kling::Types::ImageToVideoResponse
Get image-to-video task status by task ID.
52 53 54 |
# File 'lib/runapi/kling/resources/image_to_video.rb', line 52 def get(id, options: nil) request(:get, "#{ENDPOINT}/#{id}", options: ) end |
#run(options: nil, **params) ⇒ RunApi::Kling::Types::CompletedImageToVideoResponse
Generate an image-to-video task and wait until complete.
33 34 35 36 |
# File 'lib/runapi/kling/resources/image_to_video.rb', line 33 def run(options: nil, **params) task = create(options: , **params) poll_until_complete { get(task.id, options: ) } end |