runapi-kling 0.2.13 → 0.3.0

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: 3ee363d9aca47d12b9532fe37133181c95bc914e233c127ce86dc7ef9cde3000
4
- data.tar.gz: 06e2eea2612c5d2a6eaba6264a7c050d2d61b9cb80c26cfea581139a17baed20
3
+ metadata.gz: 140439beb109af76dad4b45b4e4f6f2ffb9ff6649b11fea5b7ed80b8a4000323
4
+ data.tar.gz: 4f4cfd9fa579b7c5c673243a24974529f0adee777666fec4c8da353cbf3a3711
5
5
  SHA512:
6
- metadata.gz: 6bc711db4985a209433276045dfb1174b4295f7256075287da212e98f4f443e8b2670a99f3344410b6441d507cd10465f691b46b97b129b9b22066a7d5a1a085
7
- data.tar.gz: b5e93c8807bacc42d3988ee2e1146011733ec0f0d5f9eda7d9fff97b7ad81ed72d6db39f7ee2ba1b2e334c69044026efde4c65fe2f7d250ad37762cb6d6552df
6
+ metadata.gz: af7e49904ef9611be7add201a6ca3abc5486bf5349a530201c252bfe551efb234879c55ebe70c0d04b44efc6dbfbe558d58a129e875515933191b6855da2ebe5
7
+ data.tar.gz: 52712ddf7503925a719b436867b4aa41191ab9931e0d56d18d5c9061f604b67f3dd782245df3bcdc5dd7f6561d057f5a21c8ba3382eeee6c651a8b34ef43325a
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The Kling Ruby SDK is the language-specific package for Kling on RunAPI. Use this package for video generation, animation, and video editing workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Ruby.
4
4
 
5
- This README is the Ruby package guide inside the public `kling-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/kling; for API reference, use https://runapi.ai/docs#kling; for SDK docs, use https://runapi.ai/docs#sdk-kling.
5
+ This README is the Ruby package guide inside the public `kling-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/kling; for API reference, use https://runapi.ai/docs/api/kling/text-to-video; for SDK docs, use https://runapi.ai/docs/resources/sdks.
6
6
 
7
7
  ## Install
8
8
 
@@ -17,7 +17,7 @@ require "runapi/kling"
17
17
 
18
18
  client = RunApi::Kling::Client.new
19
19
  task = client.text_to_video.create(
20
- # Pass the Kling JSON request body from https://runapi.ai/docs#kling.
20
+ # Pass the Kling JSON request body from https://runapi.ai/docs/api/kling/text-to-video.
21
21
  )
22
22
  status = client.text_to_video.get(task.id)
23
23
  ```
@@ -39,19 +39,23 @@ 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
 
52
56
  - Model page: https://runapi.ai/models/kling
53
- - SDK docs: https://runapi.ai/docs#sdk-kling
54
- - Product docs: https://runapi.ai/docs#kling
57
+ - SDK docs: https://runapi.ai/docs/resources/sdks
58
+ - Product docs: https://runapi.ai/docs/api/kling/text-to-video
55
59
  - Pricing and rate limits: https://runapi.ai/models/kling/3.0
56
60
  - Provider comparison: https://runapi.ai/providers/kuaishou
57
61
  - Full catalog: https://runapi.ai/models
@@ -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_task_id" => {
125
+ "present" => false
126
+ },
127
+ "source_video_url" => {
128
+ "present" => false
129
+ }
130
+ },
131
+ "required_any" => ["source_video_url", "source_task_id"]
132
+ }, {
133
+ "when" => {
134
+ "model" => "kling-v3-omni-edit",
135
+ "source_video_url" => {
136
+ "present" => true
137
+ }
138
+ },
139
+ "forbidden" => ["source_task_id"]
140
+ }, {
141
+ "when" => {
142
+ "model" => "kling-v3-omni-edit",
143
+ "source_task_id" => {
144
+ "present" => true
145
+ }
146
+ },
147
+ "forbidden" => ["source_video_url"]
148
+ }, {
149
+ "enum" => {
150
+ "aspect_ratio" => ["auto"],
151
+ "duration_seconds" => [5]
152
+ },
153
+ "when" => {
154
+ "model" => "kling-v3-omni-edit",
155
+ "source_video_url" => {
156
+ "present" => true
157
+ },
158
+ "reference_image_urls" => {
159
+ "present" => false
160
+ }
161
+ },
162
+ "required" => ["aspect_ratio"]
163
+ }, {
164
+ "enum" => {
165
+ "aspect_ratio" => ["auto"],
166
+ "duration_seconds" => [5]
167
+ },
168
+ "when" => {
169
+ "model" => "kling-v3-omni-edit",
170
+ "source_task_id" => {
171
+ "present" => true
172
+ },
173
+ "reference_image_urls" => {
174
+ "present" => false
175
+ }
176
+ },
177
+ "required" => ["aspect_ratio"]
178
+ }, {
179
+ "enum" => {
180
+ "aspect_ratio" => ["16:9", "9:16", "1:1"]
181
+ },
182
+ "when" => {
183
+ "model" => "kling-v3-omni-edit",
184
+ "source_video_url" => {
185
+ "present" => true
186
+ },
187
+ "reference_image_urls" => {
188
+ "present" => true
189
+ }
190
+ },
191
+ "required" => ["aspect_ratio"]
192
+ }, {
193
+ "enum" => {
194
+ "aspect_ratio" => ["16:9", "9:16", "1:1"]
195
+ },
196
+ "when" => {
197
+ "model" => "kling-v3-omni-edit",
198
+ "source_task_id" => {
199
+ "present" => true
200
+ },
201
+ "reference_image_urls" => {
202
+ "present" => true
203
+ }
204
+ },
205
+ "required" => ["aspect_ratio"]
206
+ }, {
207
+ "when" => {
208
+ "model" => "kling-v3-omni-reference",
209
+ "source_task_id" => {
210
+ "present" => false
211
+ },
212
+ "source_video_url" => {
213
+ "present" => false
214
+ }
215
+ },
216
+ "required_any" => ["source_video_url", "source_task_id"]
217
+ }, {
218
+ "when" => {
219
+ "model" => "kling-v3-omni-reference",
220
+ "source_video_url" => {
221
+ "present" => true
222
+ }
223
+ },
224
+ "forbidden" => ["source_task_id"]
225
+ }, {
226
+ "when" => {
227
+ "model" => "kling-v3-omni-reference",
228
+ "source_task_id" => {
229
+ "present" => true
230
+ }
231
+ },
232
+ "forbidden" => ["source_video_url"]
233
+ }, {
234
+ "enum" => {
235
+ "aspect_ratio" => ["auto"],
236
+ "enable_sound" => [false],
237
+ "duration_seconds" => [5]
238
+ },
239
+ "when" => {
240
+ "model" => "kling-v3-omni-reference",
241
+ "source_video_url" => {
242
+ "present" => true
243
+ },
244
+ "reference_image_urls" => {
245
+ "present" => false
246
+ }
247
+ },
248
+ "required" => ["aspect_ratio"]
249
+ }, {
250
+ "enum" => {
251
+ "aspect_ratio" => ["auto"],
252
+ "enable_sound" => [false],
253
+ "duration_seconds" => [5]
254
+ },
255
+ "when" => {
256
+ "model" => "kling-v3-omni-reference",
257
+ "source_task_id" => {
258
+ "present" => true
259
+ },
260
+ "reference_image_urls" => {
261
+ "present" => false
262
+ }
263
+ },
264
+ "required" => ["aspect_ratio"]
265
+ }, {
266
+ "enum" => {
267
+ "aspect_ratio" => ["16:9", "9:16", "1:1"],
268
+ "enable_sound" => [false]
269
+ },
270
+ "when" => {
271
+ "model" => "kling-v3-omni-reference",
272
+ "source_video_url" => {
273
+ "present" => true
274
+ },
275
+ "reference_image_urls" => {
276
+ "present" => true
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_task_id" => {
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.13
4
+ version: 0.3.0
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.3.0
18
+ version: 0.4.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.3.0
25
+ version: 0.4.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