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
- 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.
27 28 29 |
# File 'lib/runapi/kling/resources/text_to_video.rb', line 27 def initialize(http) @http = http end |
Instance Method Details
#create(options: nil, **params) ⇒ RunApi::Kling::Types::TextToVideoResponse
Create a text-to-video task.
44 45 46 47 48 |
# File 'lib/runapi/kling/resources/text_to_video.rb', line 44 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.
54 55 56 |
# File 'lib/runapi/kling/resources/text_to_video.rb', line 54 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.
35 36 37 38 |
# File 'lib/runapi/kling/resources/text_to_video.rb', line 35 def run(options: nil, **params) task = create(options: , **params) poll_until_complete { get(task.id, options: ) } end |