runapi-kling 0.2.10 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e320ba4bacde45051ec892890b4538a8fe2c415d86facc8c3c950bfeb43bd94e
4
- data.tar.gz: 4ae9148e0a4b579a47f65c6b02ba40d3cc1c95bec9254fd423bf45b442ea99f3
3
+ metadata.gz: 60b66152ad919ac0d68333e322d2020f9b6b1494b1595d39cc40bdd3bdde4f16
4
+ data.tar.gz: a599aa79714ccb068cb43ebedcb3092ed00435185941f4b20a853fdacf9a4524
5
5
  SHA512:
6
- metadata.gz: c1bc8ee1eb14d11292751fa2c24318335bb07b4a7bfa02b82454c30f9da7889281bf29067d5fc34d7d29c337d12fbadf934924c9a61c7df34b64bfe6ad937939
7
- data.tar.gz: e64c06c27bebb03e97c45801a268ad752ab63a3b22cd24e85b7d3baf9d8fc4f7b16cb0547336c820c7a5c560a326fbf49614bf6806e6e9d3e9ec4561e486265d
6
+ metadata.gz: 0e5605502283c0488cbfcf1a521b14a4cc172d389cbc452fa0c4169afd2ce8fd2e147a0fd5230cac020fd43a91393d1fe1bc578da1238ae3c1425b6a28bb63b6
7
+ data.tar.gz: 7728476306ee7d0ab8d0877275093548347f60d6c08c831fab3e3f809643e5da95951b5561c0abbafa0ba4b8262ed6e38174f7dd838c845fde2fd52f22889afa
@@ -18,6 +18,7 @@ module RunApi
18
18
  attr_reader :image_to_video
19
19
  # @return [Resources::MotionControl] Motion control operations.
20
20
  attr_reader :motion_control
21
+ attr_reader :extend_video
21
22
 
22
23
  def initialize(api_key: nil, **options)
23
24
  super
@@ -25,6 +26,7 @@ module RunApi
25
26
  @ai_avatar = Resources::AiAvatar.new(http)
26
27
  @image_to_video = Resources::ImageToVideo.new(http)
27
28
  @motion_control = Resources::MotionControl.new(http)
29
+ @extend_video = Resources::ExtendVideo.new(http)
28
30
  end
29
31
  end
30
32
  end
@@ -64,8 +64,29 @@ module RunApi
64
64
  }
65
65
  }
66
66
  },
67
+ "extend-video" => {
68
+ "models" => ["kling-v2.5-turbo-image-to-video-pro", "kling-v2.5-turbo-text-to-video-pro"],
69
+ "fields_by_model" => {
70
+ "kling-v2.5-turbo-image-to-video-pro" => {
71
+ "mode" => {
72
+ "enum" => ["std", "pro"]
73
+ },
74
+ "source_task_id" => {
75
+ "required" => true
76
+ }
77
+ },
78
+ "kling-v2.5-turbo-text-to-video-pro" => {
79
+ "mode" => {
80
+ "enum" => ["std", "pro"]
81
+ },
82
+ "source_task_id" => {
83
+ "required" => true
84
+ }
85
+ }
86
+ }
87
+ },
67
88
  "image-to-video" => {
68
- "models" => ["kling-v2.1-master-image-to-video", "kling-v2.1-pro", "kling-v2.1-standard", "kling-v2.5-turbo-image-to-video-pro", "kling-v2.6", "kling-v3-turbo-image-to-video"],
89
+ "models" => ["kling-v2.1-master-image-to-video", "kling-v2.1-pro", "kling-v2.1-standard", "kling-v2.5-turbo-image-to-video-pro", "kling-v2.6", "kling-v3-omni", "kling-v3-turbo-image-to-video"],
69
90
  "fields_by_model" => {
70
91
  "kling-v2.1-master-image-to-video" => {
71
92
  "duration_seconds" => {
@@ -151,6 +172,30 @@ module RunApi
151
172
  "length" => true
152
173
  }
153
174
  },
175
+ "kling-v3-omni" => {
176
+ "aspect_ratio" => {
177
+ "enum" => ["16:9", "9:16", "1:1"]
178
+ },
179
+ "duration_seconds" => {
180
+ "enum" => [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
181
+ "type" => "integer"
182
+ },
183
+ "first_frame_image_url" => {
184
+ "required" => true
185
+ },
186
+ "model" => {
187
+ "required" => true
188
+ },
189
+ "output_resolution" => {
190
+ "enum" => ["720p", "1080p", "4k"]
191
+ },
192
+ "prompt" => {
193
+ "required" => true,
194
+ "min" => 1,
195
+ "max" => 2500,
196
+ "length" => true
197
+ }
198
+ },
154
199
  "kling-v3-turbo-image-to-video" => {
155
200
  "duration_seconds" => {
156
201
  "enum" => [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
@@ -177,36 +222,41 @@ module RunApi
177
222
  "when" => {
178
223
  "model" => "kling-v2.1-master-image-to-video"
179
224
  },
180
- "forbidden" => ["output_resolution", "mode", "enable_sound"]
225
+ "forbidden" => ["output_resolution", "enable_sound"]
181
226
  }, {
182
227
  "when" => {
183
228
  "model" => "kling-v2.1-pro"
184
229
  },
185
- "forbidden" => ["output_resolution", "mode", "enable_sound"]
230
+ "forbidden" => ["output_resolution", "enable_sound"]
186
231
  }, {
187
232
  "when" => {
188
233
  "model" => "kling-v2.1-standard"
189
234
  },
190
- "forbidden" => ["output_resolution", "mode", "enable_sound"]
235
+ "forbidden" => ["output_resolution", "enable_sound"]
191
236
  }, {
192
237
  "when" => {
193
238
  "model" => "kling-v2.5-turbo-image-to-video-pro"
194
239
  },
195
- "forbidden" => ["output_resolution", "mode", "enable_sound"]
240
+ "forbidden" => ["output_resolution", "enable_sound"]
196
241
  }, {
197
242
  "when" => {
198
243
  "model" => "kling-v2.6"
199
244
  },
200
245
  "forbidden" => ["output_resolution", "negative_prompt", "cfg_scale"]
246
+ }, {
247
+ "when" => {
248
+ "model" => "kling-v3-omni"
249
+ },
250
+ "forbidden" => ["negative_prompt", "cfg_scale"]
201
251
  }, {
202
252
  "when" => {
203
253
  "model" => "kling-v3-turbo-image-to-video"
204
254
  },
205
- "forbidden" => ["mode", "enable_sound", "aspect_ratio", "negative_prompt", "cfg_scale", "last_frame_image_url"]
255
+ "forbidden" => ["enable_sound", "aspect_ratio", "negative_prompt", "cfg_scale", "last_frame_image_url"]
206
256
  }]
207
257
  },
208
258
  "motion-control" => {
209
- "models" => ["kling-3.0"],
259
+ "models" => ["kling-3.0", "kling-v2.6"],
210
260
  "fields_by_model" => {
211
261
  "kling-3.0" => {
212
262
  "background_source" => {
@@ -227,11 +277,40 @@ module RunApi
227
277
  "source_image_url" => {
228
278
  "required" => true
229
279
  }
280
+ },
281
+ "kling-v2.6" => {
282
+ "character_orientation" => {
283
+ "enum" => ["video", "image"],
284
+ "required" => true
285
+ },
286
+ "model" => {
287
+ "required" => true
288
+ },
289
+ "output_resolution" => {
290
+ "enum" => ["720p", "1080p"],
291
+ "required" => true
292
+ },
293
+ "prompt" => {
294
+ "max" => 2500,
295
+ "length" => true
296
+ },
297
+ "reference_video_url" => {
298
+ "required" => true
299
+ },
300
+ "source_image_url" => {
301
+ "required" => true
302
+ }
230
303
  }
231
- }
304
+ },
305
+ "rules" => [{
306
+ "when" => {
307
+ "model" => "kling-v2.6"
308
+ },
309
+ "forbidden" => ["background_source"]
310
+ }]
232
311
  },
233
312
  "text-to-video" => {
234
- "models" => ["kling-3.0", "kling-v2.1-master-text-to-video", "kling-v2.5-turbo-text-to-video-pro", "kling-v2.6", "kling-v3-turbo-text-to-video"],
313
+ "models" => ["kling-3.0", "kling-v2.1-master-text-to-video", "kling-v2.5-turbo-text-to-video-pro", "kling-v2.6", "kling-v3-omni", "kling-v3-turbo-text-to-video"],
235
314
  "fields_by_model" => {
236
315
  "kling-3.0" => {
237
316
  "aspect_ratio" => {
@@ -293,6 +372,27 @@ module RunApi
293
372
  "length" => true
294
373
  }
295
374
  },
375
+ "kling-v3-omni" => {
376
+ "aspect_ratio" => {
377
+ "enum" => ["16:9", "9:16", "1:1"]
378
+ },
379
+ "duration_seconds" => {
380
+ "enum" => [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
381
+ "type" => "integer"
382
+ },
383
+ "model" => {
384
+ "required" => true
385
+ },
386
+ "output_resolution" => {
387
+ "enum" => ["720p", "1080p", "4k"]
388
+ },
389
+ "prompt" => {
390
+ "required" => true,
391
+ "min" => 1,
392
+ "max" => 2500,
393
+ "length" => true
394
+ }
395
+ },
296
396
  "kling-v3-turbo-text-to-video" => {
297
397
  "aspect_ratio" => {
298
398
  "enum" => ["16:9", "9:16", "1:1"]
@@ -316,16 +416,6 @@ module RunApi
316
416
  }
317
417
  },
318
418
  "rules" => [{
319
- "when" => {
320
- "model" => "kling-3.0"
321
- },
322
- "forbidden" => ["mode"]
323
- }, {
324
- "when" => {
325
- "model" => "kling-v2.1-master-text-to-video"
326
- },
327
- "forbidden" => ["mode"]
328
- }, {
329
419
  "when" => {
330
420
  "model" => "kling-v2.5-turbo-text-to-video-pro"
331
421
  },
@@ -335,11 +425,16 @@ module RunApi
335
425
  "model" => "kling-v2.6"
336
426
  },
337
427
  "forbidden" => ["output_resolution", "negative_prompt", "cfg_scale", "multi_shots", "multi_prompt", "first_frame_image_url", "last_frame_image_url", "kling_elements"]
428
+ }, {
429
+ "when" => {
430
+ "model" => "kling-v3-omni"
431
+ },
432
+ "forbidden" => ["negative_prompt", "cfg_scale", "multi_shots", "multi_prompt", "first_frame_image_url", "last_frame_image_url", "kling_elements"]
338
433
  }, {
339
434
  "when" => {
340
435
  "model" => "kling-v3-turbo-text-to-video"
341
436
  },
342
- "forbidden" => ["mode", "enable_sound", "negative_prompt", "cfg_scale", "multi_shots", "multi_prompt", "first_frame_image_url", "last_frame_image_url", "kling_elements"]
437
+ "forbidden" => ["enable_sound", "negative_prompt", "cfg_scale", "multi_shots", "multi_prompt", "first_frame_image_url", "last_frame_image_url", "kling_elements"]
343
438
  }]
344
439
  }
345
440
  }.freeze
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module Kling
5
+ module Resources
6
+ # Continue a completed Kling V2.5 Turbo video task.
7
+ class ExtendVideo
8
+ include RunApi::Core::ResourceHelpers
9
+
10
+ ENDPOINT = "/api/v1/kling/extend_video"
11
+
12
+ def initialize(http)
13
+ @http = http
14
+ end
15
+
16
+ def run(options: nil, **params)
17
+ task = create(options: options, **params)
18
+ poll_until_complete { get(task.id, options: options) }
19
+ end
20
+
21
+ def create(options: nil, **params)
22
+ params = compact_params(params)
23
+ validate_contract!(CONTRACT["extend-video"], params)
24
+ request(:post, ENDPOINT, body: params, options: options)
25
+ end
26
+
27
+ def get(id, options: nil)
28
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -13,6 +13,7 @@ module RunApi
13
13
  RESPONSE_CLASS = Types::ImageToVideoResponse
14
14
  COMPLETED_RESPONSE_CLASS = Types::CompletedImageToVideoResponse
15
15
  V26_MODEL = "kling-v2.6"
16
+ V3_OMNI_MODEL = "kling-v3-omni"
16
17
  V3_TURBO_MODEL = "kling-v3-turbo-image-to-video"
17
18
  V3_TURBO_UNSUPPORTED_FIELDS = %i[
18
19
  aspect_ratio
@@ -58,12 +59,16 @@ module RunApi
58
59
  reject_unsupported_v3_turbo_fields!(params)
59
60
  validate_contract!(CONTRACT["image-to-video"], params)
60
61
 
61
- # Bespoke: last_frame_image_url is only allowed for select models
62
- # (model-gating, not expressible as a contract enum/required rule).
62
+ # Bespoke last-frame rules that the generated contract cannot express.
63
63
  model = param(params, :model)
64
64
  last_frame_image_url = param(params, :last_frame_image_url)
65
65
  if model == V26_MODEL
66
66
  validate_v26_params!(params, last_frame_image_url)
67
+ elsif last_frame_image_url && model == V3_OMNI_MODEL
68
+ duration_seconds = param(params, :duration_seconds) || 5
69
+ return if duration_seconds.to_i == 5
70
+
71
+ raise Core::ValidationError, "last_frame_image_url requires duration_seconds 5 for #{V3_OMNI_MODEL}"
67
72
  elsif last_frame_image_url && !%w[kling-v2.5-turbo-image-to-video-pro kling-v2.1-pro].include?(model)
68
73
  raise Core::ValidationError, "last_frame_image_url is only supported by kling-v2.5-turbo-image-to-video-pro and kling-v2.1-pro"
69
74
  end
data/lib/runapi/kling.rb CHANGED
@@ -7,6 +7,7 @@ require_relative "kling/resources/text_to_video"
7
7
  require_relative "kling/resources/ai_avatar"
8
8
  require_relative "kling/resources/image_to_video"
9
9
  require_relative "kling/resources/motion_control"
10
+ require_relative "kling/resources/extend_video"
10
11
  require_relative "kling/client"
11
12
 
12
13
  module RunApi
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-kling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.14
18
+ version: 0.2.15
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.2.14
25
+ version: 0.2.15
26
26
  description: The Kling Ruby SDK is the language-specific package for Kling on RunAPI.
27
27
  Use this package for video generation, animation, and video editing workflows when
28
28
  your application needs request bodies, task status lookup, and consistent RunAPI
@@ -41,6 +41,7 @@ files:
41
41
  - lib/runapi/kling/client.rb
42
42
  - lib/runapi/kling/contract_gen.rb
43
43
  - lib/runapi/kling/resources/ai_avatar.rb
44
+ - lib/runapi/kling/resources/extend_video.rb
44
45
  - lib/runapi/kling/resources/image_to_video.rb
45
46
  - lib/runapi/kling/resources/motion_control.rb
46
47
  - lib/runapi/kling/resources/text_to_video.rb
@@ -69,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
70
  - !ruby/object:Gem::Version
70
71
  version: '0'
71
72
  requirements: []
72
- rubygems_version: 4.0.10
73
+ rubygems_version: 4.0.17
73
74
  specification_version: 4
74
75
  summary: Kling API Ruby SDK for RunAPI
75
76
  test_files: []