runapi-kling 0.2.9 → 0.2.11

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: d2943605c3e518ce6a424760e18be4da5a853f87b167f2b4a61688e6aa810485
4
- data.tar.gz: b7b43a3379b6be598313bce535b399a240237eda145b4e644f11ae02709fbba7
3
+ metadata.gz: 52976b2c6ead958e307eb73e1074e9dae605dce26e58d3320aa0df15f3eb2d7d
4
+ data.tar.gz: 4c6255e788fa2950a268419a646e7d7c07c8bd2344f0f7925ef8a760b7773c25
5
5
  SHA512:
6
- metadata.gz: 7629e75af240e178d3d155d0f4d3430e5cbddeda6e34827fabdbcc0b54166d28c79633c6f2e2f385ea234ac4ed04c625d7174799ecfc60cf7376b664d83f885b
7
- data.tar.gz: eca5d1069c584b2edcc402c053a6d0355012ec09a5294ff72a7a04abd3473d3fd5595fbb6d48260afc72369c0f0ea6f5b3a8b4bb1223f6c5509b647262f71c01
6
+ metadata.gz: 6f3a374bb8b623a477b6656f2fccb06eba3e0ebb3b6b97ead65ae491fa21fd67a64c83715ed806e79027e0ca6031f6371f69c085a085281ec3c60068547b8263
7
+ data.tar.gz: a233a64e104565e7be3bef7181944756460c78c3c7f9e647f1826b6ce440860fa4ee9fcc1cd6c3368b69a4c40813646b3e0278f168e548aec5f3305ca101c99e
@@ -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-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" => {
@@ -127,6 +148,54 @@ module RunApi
127
148
  "required" => true
128
149
  }
129
150
  },
151
+ "kling-v2.6" => {
152
+ "aspect_ratio" => {
153
+ "enum" => ["16:9", "9:16", "1:1"]
154
+ },
155
+ "duration_seconds" => {
156
+ "enum" => [5, 10],
157
+ "type" => "integer"
158
+ },
159
+ "first_frame_image_url" => {
160
+ "required" => true
161
+ },
162
+ "mode" => {
163
+ "enum" => ["std", "pro"]
164
+ },
165
+ "model" => {
166
+ "required" => true
167
+ },
168
+ "prompt" => {
169
+ "required" => true,
170
+ "min" => 1,
171
+ "max" => 2500,
172
+ "length" => true
173
+ }
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
+ },
130
199
  "kling-v3-turbo-image-to-video" => {
131
200
  "duration_seconds" => {
132
201
  "enum" => [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
@@ -153,27 +222,37 @@ module RunApi
153
222
  "when" => {
154
223
  "model" => "kling-v2.1-master-image-to-video"
155
224
  },
156
- "forbidden" => ["output_resolution"]
225
+ "forbidden" => ["output_resolution", "enable_sound"]
157
226
  }, {
158
227
  "when" => {
159
228
  "model" => "kling-v2.1-pro"
160
229
  },
161
- "forbidden" => ["output_resolution"]
230
+ "forbidden" => ["output_resolution", "enable_sound"]
162
231
  }, {
163
232
  "when" => {
164
233
  "model" => "kling-v2.1-standard"
165
234
  },
166
- "forbidden" => ["output_resolution"]
235
+ "forbidden" => ["output_resolution", "enable_sound"]
167
236
  }, {
168
237
  "when" => {
169
238
  "model" => "kling-v2.5-turbo-image-to-video-pro"
170
239
  },
171
- "forbidden" => ["output_resolution"]
240
+ "forbidden" => ["output_resolution", "enable_sound"]
241
+ }, {
242
+ "when" => {
243
+ "model" => "kling-v2.6"
244
+ },
245
+ "forbidden" => ["output_resolution", "negative_prompt", "cfg_scale"]
246
+ }, {
247
+ "when" => {
248
+ "model" => "kling-v3-omni"
249
+ },
250
+ "forbidden" => ["negative_prompt", "cfg_scale"]
172
251
  }, {
173
252
  "when" => {
174
253
  "model" => "kling-v3-turbo-image-to-video"
175
254
  },
176
- "forbidden" => ["aspect_ratio", "negative_prompt", "cfg_scale", "last_frame_image_url"]
255
+ "forbidden" => ["enable_sound", "aspect_ratio", "negative_prompt", "cfg_scale", "last_frame_image_url"]
177
256
  }]
178
257
  },
179
258
  "motion-control" => {
@@ -202,7 +281,7 @@ module RunApi
202
281
  }
203
282
  },
204
283
  "text-to-video" => {
205
- "models" => ["kling-3.0", "kling-v2.1-master-text-to-video", "kling-v2.5-turbo-text-to-video-pro", "kling-v3-turbo-text-to-video"],
284
+ "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"],
206
285
  "fields_by_model" => {
207
286
  "kling-3.0" => {
208
287
  "aspect_ratio" => {
@@ -243,6 +322,48 @@ module RunApi
243
322
  "required" => true
244
323
  }
245
324
  },
325
+ "kling-v2.6" => {
326
+ "aspect_ratio" => {
327
+ "enum" => ["16:9", "9:16", "1:1"]
328
+ },
329
+ "duration_seconds" => {
330
+ "enum" => [5, 10],
331
+ "type" => "integer"
332
+ },
333
+ "mode" => {
334
+ "enum" => ["std", "pro"]
335
+ },
336
+ "model" => {
337
+ "required" => true
338
+ },
339
+ "prompt" => {
340
+ "required" => true,
341
+ "min" => 1,
342
+ "max" => 2500,
343
+ "length" => true
344
+ }
345
+ },
346
+ "kling-v3-omni" => {
347
+ "aspect_ratio" => {
348
+ "enum" => ["16:9", "9:16", "1:1"]
349
+ },
350
+ "duration_seconds" => {
351
+ "enum" => [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
352
+ "type" => "integer"
353
+ },
354
+ "model" => {
355
+ "required" => true
356
+ },
357
+ "output_resolution" => {
358
+ "enum" => ["720p", "1080p", "4k"]
359
+ },
360
+ "prompt" => {
361
+ "required" => true,
362
+ "min" => 1,
363
+ "max" => 2500,
364
+ "length" => true
365
+ }
366
+ },
246
367
  "kling-v3-turbo-text-to-video" => {
247
368
  "aspect_ratio" => {
248
369
  "enum" => ["16:9", "9:16", "1:1"]
@@ -266,6 +387,21 @@ module RunApi
266
387
  }
267
388
  },
268
389
  "rules" => [{
390
+ "when" => {
391
+ "model" => "kling-v2.5-turbo-text-to-video-pro"
392
+ },
393
+ "forbidden" => ["mode"]
394
+ }, {
395
+ "when" => {
396
+ "model" => "kling-v2.6"
397
+ },
398
+ "forbidden" => ["output_resolution", "negative_prompt", "cfg_scale", "multi_shots", "multi_prompt", "first_frame_image_url", "last_frame_image_url", "kling_elements"]
399
+ }, {
400
+ "when" => {
401
+ "model" => "kling-v3-omni"
402
+ },
403
+ "forbidden" => ["negative_prompt", "cfg_scale", "multi_shots", "multi_prompt", "first_frame_image_url", "last_frame_image_url", "kling_elements"]
404
+ }, {
269
405
  "when" => {
270
406
  "model" => "kling-v3-turbo-text-to-video"
271
407
  },
@@ -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
@@ -12,6 +12,8 @@ module RunApi
12
12
 
13
13
  RESPONSE_CLASS = Types::ImageToVideoResponse
14
14
  COMPLETED_RESPONSE_CLASS = Types::CompletedImageToVideoResponse
15
+ V26_MODEL = "kling-v2.6"
16
+ V3_OMNI_MODEL = "kling-v3-omni"
15
17
  V3_TURBO_MODEL = "kling-v3-turbo-image-to-video"
16
18
  V3_TURBO_UNSUPPORTED_FIELDS = %i[
17
19
  aspect_ratio
@@ -57,15 +59,36 @@ module RunApi
57
59
  reject_unsupported_v3_turbo_fields!(params)
58
60
  validate_contract!(CONTRACT["image-to-video"], params)
59
61
 
60
- # Bespoke: last_frame_image_url is only allowed for select models
61
- # (model-gating, not expressible as a contract enum/required rule).
62
+ # Bespoke last-frame rules that the generated contract cannot express.
62
63
  model = param(params, :model)
63
64
  last_frame_image_url = param(params, :last_frame_image_url)
64
- if last_frame_image_url && !%w[kling-v2.5-turbo-image-to-video-pro kling-v2.1-pro].include?(model)
65
+ if model == V26_MODEL
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}"
72
+ elsif last_frame_image_url && !%w[kling-v2.5-turbo-image-to-video-pro kling-v2.1-pro].include?(model)
65
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"
66
74
  end
67
75
  end
68
76
 
77
+ def validate_v26_params!(params, last_frame_image_url)
78
+ mode = param(params, :mode) || "std"
79
+ if param(params, :enable_sound) == true && mode != "pro"
80
+ raise Core::ValidationError, "enable_sound requires mode pro for #{V26_MODEL}"
81
+ end
82
+ return unless last_frame_image_url
83
+
84
+ raise Core::ValidationError, "last_frame_image_url requires mode pro for #{V26_MODEL}" unless mode == "pro"
85
+
86
+ duration_seconds = param(params, :duration_seconds) || 5
87
+ return if duration_seconds.to_i == 5
88
+
89
+ raise Core::ValidationError, "last_frame_image_url requires duration_seconds 5 for #{V26_MODEL}"
90
+ end
91
+
69
92
  def reject_unsupported_v3_turbo_fields!(params)
70
93
  return unless param(params, :model) == V3_TURBO_MODEL
71
94
 
@@ -12,6 +12,7 @@ module RunApi
12
12
 
13
13
  RESPONSE_CLASS = Types::TextToVideoResponse
14
14
  COMPLETED_RESPONSE_CLASS = Types::CompletedTextToVideoResponse
15
+ V26_MODEL = "kling-v2.6"
15
16
  V3_TURBO_MODEL = "kling-v3-turbo-text-to-video"
16
17
  V3_TURBO_UNSUPPORTED_FIELDS = %i[
17
18
  enable_sound
@@ -60,6 +61,7 @@ module RunApi
60
61
  def validate_params!(params)
61
62
  reject_unsupported_v3_turbo_fields!(params)
62
63
  validate_contract!(CONTRACT["text-to-video"], params)
64
+ validate_v26_params!(params)
63
65
 
64
66
  # Bespoke cross-field rules the contract cannot express.
65
67
  multi_shots = param(params, :multi_shots) == true
@@ -75,6 +77,13 @@ module RunApi
75
77
  end
76
78
  end
77
79
 
80
+ def validate_v26_params!(params)
81
+ return unless param(params, :model) == V26_MODEL
82
+ return unless param(params, :enable_sound) == true && param(params, :mode) != "pro"
83
+
84
+ raise Core::ValidationError, "enable_sound requires mode pro for #{V26_MODEL}"
85
+ end
86
+
78
87
  def reject_unsupported_v3_turbo_fields!(params)
79
88
  return unless param(params, :model) == V3_TURBO_MODEL
80
89
 
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.9
4
+ version: 0.2.11
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.11
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.11
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: []