runapi-kling 0.2.14 → 0.3.1

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: 4e9cf3bd778f4eb399c79e7a1fc81b24c6783d56ed625b6102e2e6c90cb066b5
4
- data.tar.gz: 1932a3abf1e67949639c2ff9a75173bedd76d09a71fac883102985dab80c13de
3
+ metadata.gz: '0269091ee94453b4c888142dfb079ff1e99d53a8c87b66ff86f21528df00b3be'
4
+ data.tar.gz: 1565cea700b0e7f7b4cc727369d0e84da79d3169876a99da4a5ca5ef83ef49b4
5
5
  SHA512:
6
- metadata.gz: 22f39494c76057427e7ffc927991bf52a980fce4330226103cb71fe0063e0f4f634edcba7b78764f3023e188e7bc91725ad8e503dfc5c28ba5102d4f59d7be75
7
- data.tar.gz: 00e6370f82e94cad79e7f8c873818241f7df2e876060c054819fd86b9f737c30b66471fc44025ee778d0c3f7f82e2d95d8372f0e8bfb565b6310baeab9715e8c
6
+ metadata.gz: dc24654eb39970b2a52f11c8ff2286b43f4650035c8ac8948d6a89ea902c65fde4994479ac83c5e8fe6bddd17e8f37efa1993e3b4117083b2168ce3fddae8dca
7
+ data.tar.gz: aeb91932f9be4aeca9169098f7301fc677d80402c9c0748b2443c035f542da21f69b648a1c80ab34c29ea5ccba5bd8379eaf89d9818086af2b35ea0cbbad8a8b
data/README.md CHANGED
@@ -39,13 +39,17 @@ result = client.text_to_video.run(
39
39
 
40
40
  Number reference images in prompt order as `<<<image_1>>>`, `<<<image_2>>>`, and so on; the optional video is `<<<video_1>>>`. With a video, send at most four images. Do not combine `last_frame_image_url` with reference images or a reference video. A `feature` reference video may be used with the required first frame; `base` cannot be combined with frame inputs. O1 requests are five seconds and keep sound disabled. Pricing and limits: https://runapi.ai/models/kling/o1.
41
41
 
42
+ ## Kling V3 Omni source-video editing
43
+
44
+ Use `kling-v3-omni-reference` with `text_to_video` for image-only reference inputs. For a source video, use `edit_video` with either `kling-v3-omni-reference` or `kling-v3-omni-edit`. The reference model keeps sound disabled for source-video requests.
45
+
42
46
  Use `create` when you want to submit a task and return quickly, `get` when you need the latest task state, and `run` when a script should create and poll until completion. In web request handlers, prefer `create` plus webhook or later `get` polling so a worker is not held open.
43
47
 
44
48
  RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
45
49
 
46
50
  ## Language notes
47
51
 
48
- Use Ruby keyword arguments and the `RunApi::Kling` error classes when building video jobs, Rails workers, or scripts. The available resources are `text_to_video`, `ai_avatar`, `image_to_video`, and `motion_control`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
52
+ Use Ruby keyword arguments and the `RunApi::Kling` error classes when building video jobs, Rails workers, or scripts. The available resources are `text_to_video`, `edit_video`, `ai_avatar`, `image_to_video`, and `motion_control`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
49
53
 
50
54
  ## Links
51
55
 
@@ -19,6 +19,8 @@ module RunApi
19
19
  # @return [Resources::MotionControl] Motion control operations.
20
20
  attr_reader :motion_control
21
21
  attr_reader :extend_video
22
+ # @return [Resources::EditVideo] Source-video editing operations.
23
+ attr_reader :edit_video
22
24
 
23
25
  def initialize(api_key: nil, **options)
24
26
  super
@@ -27,6 +29,7 @@ module RunApi
27
29
  @image_to_video = Resources::ImageToVideo.new(http)
28
30
  @motion_control = Resources::MotionControl.new(http)
29
31
  @extend_video = Resources::ExtendVideo.new(http)
32
+ @edit_video = Resources::EditVideo.new(http)
30
33
  end
31
34
  end
32
35
  end
@@ -64,6 +64,236 @@ module RunApi
64
64
  }
65
65
  }
66
66
  },
67
+ "edit-video" => {
68
+ "models" => ["kling-v3-omni-edit", "kling-v3-omni-reference"],
69
+ "fields_by_model" => {
70
+ "kling-v3-omni-edit" => {
71
+ "aspect_ratio" => {
72
+ "enum" => ["auto", "16:9", "9:16", "1:1"]
73
+ },
74
+ "duration_seconds" => {
75
+ "enum" => [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
76
+ "type" => "integer"
77
+ },
78
+ "model" => {
79
+ "required" => true
80
+ },
81
+ "output_resolution" => {
82
+ "enum" => ["720p", "1080p", "4k"]
83
+ },
84
+ "prompt" => {
85
+ "required" => true,
86
+ "min" => 1,
87
+ "max" => 2500,
88
+ "length" => true
89
+ },
90
+ "reference_image_urls" => {
91
+ "min_items" => 1,
92
+ "max_items" => 4
93
+ }
94
+ },
95
+ "kling-v3-omni-reference" => {
96
+ "aspect_ratio" => {
97
+ "enum" => ["auto", "16:9", "9:16", "1:1"]
98
+ },
99
+ "duration_seconds" => {
100
+ "enum" => [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
101
+ "type" => "integer"
102
+ },
103
+ "model" => {
104
+ "required" => true
105
+ },
106
+ "output_resolution" => {
107
+ "enum" => ["720p", "1080p", "4k"]
108
+ },
109
+ "prompt" => {
110
+ "required" => true,
111
+ "min" => 1,
112
+ "max" => 2500,
113
+ "length" => true
114
+ },
115
+ "reference_image_urls" => {
116
+ "min_items" => 1,
117
+ "max_items" => 4
118
+ }
119
+ }
120
+ },
121
+ "rules" => [{
122
+ "when" => {
123
+ "model" => "kling-v3-omni-edit",
124
+ "source_video_url" => {
125
+ "present" => true
126
+ }
127
+ },
128
+ "forbidden" => ["source_task_id"]
129
+ }, {
130
+ "when" => {
131
+ "model" => "kling-v3-omni-edit",
132
+ "source_task_id" => {
133
+ "present" => true
134
+ }
135
+ },
136
+ "forbidden" => ["source_video_url"]
137
+ }, {
138
+ "enum" => {
139
+ "aspect_ratio" => ["auto"],
140
+ "duration_seconds" => [5]
141
+ },
142
+ "when" => {
143
+ "model" => "kling-v3-omni-edit",
144
+ "source_video_url" => {
145
+ "present" => true
146
+ },
147
+ "reference_image_urls" => {
148
+ "present" => false
149
+ }
150
+ },
151
+ "required" => ["aspect_ratio"]
152
+ }, {
153
+ "enum" => {
154
+ "aspect_ratio" => ["auto"],
155
+ "duration_seconds" => [5]
156
+ },
157
+ "when" => {
158
+ "model" => "kling-v3-omni-edit",
159
+ "source_task_id" => {
160
+ "present" => true
161
+ },
162
+ "reference_image_urls" => {
163
+ "present" => false
164
+ }
165
+ },
166
+ "required" => ["aspect_ratio"]
167
+ }, {
168
+ "enum" => {
169
+ "aspect_ratio" => ["16:9", "9:16", "1:1"]
170
+ },
171
+ "when" => {
172
+ "model" => "kling-v3-omni-edit",
173
+ "source_video_url" => {
174
+ "present" => true
175
+ },
176
+ "reference_image_urls" => {
177
+ "present" => true
178
+ }
179
+ },
180
+ "required" => ["aspect_ratio"]
181
+ }, {
182
+ "enum" => {
183
+ "aspect_ratio" => ["16:9", "9:16", "1:1"]
184
+ },
185
+ "when" => {
186
+ "model" => "kling-v3-omni-edit",
187
+ "source_task_id" => {
188
+ "present" => true
189
+ },
190
+ "reference_image_urls" => {
191
+ "present" => true
192
+ }
193
+ },
194
+ "required" => ["aspect_ratio"]
195
+ }, {
196
+ "when" => {
197
+ "model" => "kling-v3-omni-edit",
198
+ "source_task_id" => {
199
+ "present" => false
200
+ },
201
+ "source_video_url" => {
202
+ "present" => false
203
+ }
204
+ },
205
+ "required_any" => ["source_video_url", "source_task_id"]
206
+ }, {
207
+ "enum" => {
208
+ "aspect_ratio" => ["16:9", "9:16", "1:1"],
209
+ "enable_sound" => [false]
210
+ },
211
+ "when" => {
212
+ "model" => "kling-v3-omni-reference",
213
+ "source_task_id" => {
214
+ "present" => true
215
+ },
216
+ "reference_image_urls" => {
217
+ "present" => true
218
+ }
219
+ },
220
+ "required" => ["aspect_ratio"]
221
+ }, {
222
+ "when" => {
223
+ "model" => "kling-v3-omni-reference",
224
+ "source_task_id" => {
225
+ "present" => false
226
+ },
227
+ "source_video_url" => {
228
+ "present" => false
229
+ }
230
+ },
231
+ "required_any" => ["source_video_url", "source_task_id"]
232
+ }, {
233
+ "when" => {
234
+ "model" => "kling-v3-omni-reference",
235
+ "source_video_url" => {
236
+ "present" => true
237
+ }
238
+ },
239
+ "forbidden" => ["source_task_id"]
240
+ }, {
241
+ "when" => {
242
+ "model" => "kling-v3-omni-reference",
243
+ "source_task_id" => {
244
+ "present" => true
245
+ }
246
+ },
247
+ "forbidden" => ["source_video_url"]
248
+ }, {
249
+ "enum" => {
250
+ "aspect_ratio" => ["auto"],
251
+ "enable_sound" => [false],
252
+ "duration_seconds" => [5]
253
+ },
254
+ "when" => {
255
+ "model" => "kling-v3-omni-reference",
256
+ "source_video_url" => {
257
+ "present" => true
258
+ },
259
+ "reference_image_urls" => {
260
+ "present" => false
261
+ }
262
+ },
263
+ "required" => ["aspect_ratio"]
264
+ }, {
265
+ "enum" => {
266
+ "aspect_ratio" => ["auto"],
267
+ "enable_sound" => [false],
268
+ "duration_seconds" => [5]
269
+ },
270
+ "when" => {
271
+ "model" => "kling-v3-omni-reference",
272
+ "source_task_id" => {
273
+ "present" => true
274
+ },
275
+ "reference_image_urls" => {
276
+ "present" => false
277
+ }
278
+ },
279
+ "required" => ["aspect_ratio"]
280
+ }, {
281
+ "enum" => {
282
+ "aspect_ratio" => ["16:9", "9:16", "1:1"],
283
+ "enable_sound" => [false]
284
+ },
285
+ "when" => {
286
+ "model" => "kling-v3-omni-reference",
287
+ "source_video_url" => {
288
+ "present" => true
289
+ },
290
+ "reference_image_urls" => {
291
+ "present" => true
292
+ }
293
+ },
294
+ "required" => ["aspect_ratio"]
295
+ }]
296
+ },
67
297
  "extend-video" => {
68
298
  "models" => ["kling-v2.5-turbo-image-to-video-pro", "kling-v2.5-turbo-text-to-video-pro"],
69
299
  "fields_by_model" => {
@@ -346,7 +576,7 @@ module RunApi
346
576
  }]
347
577
  },
348
578
  "text-to-video" => {
349
- "models" => ["kling-3.0", "kling-o1", "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"],
579
+ "models" => ["kling-3.0", "kling-o1", "kling-v2.1-master-text-to-video", "kling-v2.5-turbo-text-to-video-pro", "kling-v2.6", "kling-v3-omni", "kling-v3-omni-reference", "kling-v3-turbo-text-to-video"],
350
580
  "fields_by_model" => {
351
581
  "kling-3.0" => {
352
582
  "aspect_ratio" => {
@@ -457,6 +687,33 @@ module RunApi
457
687
  "length" => true
458
688
  }
459
689
  },
690
+ "kling-v3-omni-reference" => {
691
+ "aspect_ratio" => {
692
+ "enum" => ["16:9", "9:16", "1:1"],
693
+ "required" => true
694
+ },
695
+ "duration_seconds" => {
696
+ "enum" => [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
697
+ "type" => "integer"
698
+ },
699
+ "model" => {
700
+ "required" => true
701
+ },
702
+ "output_resolution" => {
703
+ "enum" => ["720p", "1080p", "4k"]
704
+ },
705
+ "prompt" => {
706
+ "required" => true,
707
+ "min" => 1,
708
+ "max" => 2500,
709
+ "length" => true
710
+ },
711
+ "reference_image_urls" => {
712
+ "required" => true,
713
+ "min_items" => 1,
714
+ "max_items" => 7
715
+ }
716
+ },
460
717
  "kling-v3-turbo-text-to-video" => {
461
718
  "aspect_ratio" => {
462
719
  "enum" => ["16:9", "9:16", "1:1"]
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module Kling
5
+ module Resources
6
+ # Edit a source video with a selected Kling V3 Omni model.
7
+ class EditVideo
8
+ include RunApi::Core::ResourceHelpers
9
+
10
+ ENDPOINT = "/api/v1/kling/edit_video"
11
+ RESPONSE_CLASS = Types::TextToVideoResponse
12
+ COMPLETED_RESPONSE_CLASS = Types::CompletedTextToVideoResponse
13
+
14
+ def initialize(http)
15
+ @http = http
16
+ end
17
+
18
+ def run(options: nil, **params)
19
+ task = create(options: options, **params)
20
+ poll_until_complete { get(task.id, options: options) }
21
+ end
22
+
23
+ def create(options: nil, **params)
24
+ params = compact_params(params)
25
+ validate_contract!(CONTRACT["edit-video"], params)
26
+ request(:post, ENDPOINT, body: params, options: options)
27
+ end
28
+
29
+ def get(id, options: nil)
30
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
data/lib/runapi/kling.rb CHANGED
@@ -9,6 +9,7 @@ require_relative "kling/resources/ai_avatar"
9
9
  require_relative "kling/resources/image_to_video"
10
10
  require_relative "kling/resources/motion_control"
11
11
  require_relative "kling/resources/extend_video"
12
+ require_relative "kling/resources/edit_video"
12
13
  require_relative "kling/client"
13
14
 
14
15
  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.14
4
+ version: 0.3.1
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.4.0
18
+ version: 0.5.0
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.4.0
25
+ version: 0.5.0
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/edit_video.rb
44
45
  - lib/runapi/kling/resources/extend_video.rb
45
46
  - lib/runapi/kling/resources/image_to_video.rb
46
47
  - lib/runapi/kling/resources/motion_control.rb
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
72
  - !ruby/object:Gem::Version
72
73
  version: '0'
73
74
  requirements: []
74
- rubygems_version: 4.0.10
75
+ rubygems_version: 4.0.17
75
76
  specification_version: 4
76
77
  summary: Kling API Ruby SDK for RunAPI
77
78
  test_files: []