Class: RunApi::Kling::Resources::TextToVideo
- Inherits:
-
Object
- Object
- RunApi::Kling::Resources::TextToVideo
- Includes:
- Core::ResourceHelpers
- Defined in:
- lib/runapi/kling/resources/text_to_video.rb
Overview
Kling text-to-video resource. Generate videos from text prompts.
Constant Summary collapse
- ENDPOINT =
"/api/v1/kling/text_to_video"- RESPONSE_CLASS =
Types::TextToVideoResponse
- COMPLETED_RESPONSE_CLASS =
Types::CompletedTextToVideoResponse
- V26_MODEL =
"kling-v2.6"- V3_TURBO_MODEL =
"kling-v3-turbo-text-to-video"- V3_TURBO_UNSUPPORTED_FIELDS =
%i[ enable_sound negative_prompt cfg_scale multi_shots multi_prompt first_frame_image_url last_frame_image_url kling_elements ].freeze
Instance Method Summary collapse
-
#create(options: nil, **params) ⇒ RunApi::Kling::Types::TextToVideoResponse
Create a text-to-video task.
-
#get(id, options: nil) ⇒ RunApi::Kling::Types::TextToVideoResponse
Get text-to-video task status by task ID.
-
#initialize(http) ⇒ TextToVideo
constructor
A new instance of TextToVideo.
-
#run(options: nil, **params) ⇒ RunApi::Kling::Types::CompletedTextToVideoResponse
Generate a text-to-video task and wait until complete.
Constructor Details
#initialize(http) ⇒ TextToVideo
Returns a new instance of TextToVideo.
28 29 30 |
# File 'lib/runapi/kling/resources/text_to_video.rb', line 28 def initialize(http) @http = http end |
Instance Method Details
#create(options: nil, **params) ⇒ RunApi::Kling::Types::TextToVideoResponse
Create a text-to-video task.
45 46 47 48 49 |
# File 'lib/runapi/kling/resources/text_to_video.rb', line 45 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::TextToVideoResponse
Get text-to-video task status by task ID.
55 56 57 |
# File 'lib/runapi/kling/resources/text_to_video.rb', line 55 def get(id, options: nil) request(:get, "#{ENDPOINT}/#{id}", options: ) end |
#run(options: nil, **params) ⇒ RunApi::Kling::Types::CompletedTextToVideoResponse
Generate a text-to-video task and wait until complete.
36 37 38 39 |
# File 'lib/runapi/kling/resources/text_to_video.rb', line 36 def run(options: nil, **params) task = create(options: , **params) poll_until_complete { get(task.id, options: ) } end |