runapi-kling 0.5.1 → 0.6.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 +4 -4
- data/README.md +4 -0
- data/lib/runapi/kling/client.rb +6 -0
- data/lib/runapi/kling/resources/keyframe_to_video.rb +31 -0
- data/lib/runapi/kling/resources/reference_to_video.rb +31 -0
- data/lib/runapi/kling/resources/text_to_image.rb +48 -0
- data/lib/runapi/kling/types.rb +15 -0
- data/lib/runapi/kling.rb +3 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3a3b78cdb6cff93a2d38e1ba908bb1035845b230194e8d02381363314d3c276f
|
|
4
|
+
data.tar.gz: 910d5c7cb38e160ef47b8d0d715cde94c19333dcf4f99b8fb267a341167bda07
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 156edbb9166109ec59ac14efa14b83a22653dc151e7fca2563ff7291dbf78f829a3f2382c5eec6831e9d736c688891db2d5deeeab25dfac10934ad29635161b1
|
|
7
|
+
data.tar.gz: 2d7d1a32024c76a5f74dd643a85544f40a7a0b44329fb22da6133ca151251a642598961c50b27da12134b1fff016ec1492a5fb741397bbf7fc4aa629940b8ccb
|
data/README.md
CHANGED
|
@@ -64,3 +64,7 @@ Use Ruby keyword arguments and the `RunApi::Kling` error classes when building v
|
|
|
64
64
|
## License
|
|
65
65
|
|
|
66
66
|
Licensed under the Apache License, Version 2.0.
|
|
67
|
+
|
|
68
|
+
## Kling 4.0 images
|
|
69
|
+
|
|
70
|
+
Use the `text_to_image` resource, named `textToImage` in JavaScript, PHP, and Java and `TextToImage` in Go. It supports `kling-v4-image` and `kling-v4-long-image` through create, get, and run. Completed tasks return ordered `images` with download URLs; 8k output is JPEG. Standard image references use `source_image_urls` and named `elements` with `name`, `image_urls`, optional `description`, and optional `tag`. Long images require `skill`: ecommerce uses product `source_image_urls` and optional `length`, while webpage uses optional `style_image_url` and `subject_image_url`. See the [image guide](https://runapi.ai/docs/guides/task-api/kling-images) for constraints and the [model catalog](https://runapi.ai/models/kling) for current pricing.
|
data/lib/runapi/kling/client.rb
CHANGED
|
@@ -11,6 +11,7 @@ module RunApi
|
|
|
11
11
|
# )
|
|
12
12
|
class Client < RunApi::Core::Client
|
|
13
13
|
# @return [Resources::TextToVideo] Text-to-video operations.
|
|
14
|
+
attr_reader :text_to_image
|
|
14
15
|
attr_reader :text_to_video
|
|
15
16
|
# @return [Resources::AiAvatar] AI avatar generation operations.
|
|
16
17
|
attr_reader :ai_avatar
|
|
@@ -21,15 +22,20 @@ module RunApi
|
|
|
21
22
|
attr_reader :extend_video
|
|
22
23
|
# @return [Resources::EditVideo] Source-video editing operations.
|
|
23
24
|
attr_reader :edit_video
|
|
25
|
+
attr_reader :keyframe_to_video
|
|
26
|
+
attr_reader :reference_to_video
|
|
24
27
|
|
|
25
28
|
def initialize(api_key: nil, **options)
|
|
26
29
|
super
|
|
30
|
+
@text_to_image = Resources::TextToImage.new(http)
|
|
27
31
|
@text_to_video = Resources::TextToVideo.new(http)
|
|
28
32
|
@ai_avatar = Resources::AiAvatar.new(http)
|
|
29
33
|
@image_to_video = Resources::ImageToVideo.new(http)
|
|
30
34
|
@motion_control = Resources::MotionControl.new(http)
|
|
31
35
|
@extend_video = Resources::ExtendVideo.new(http)
|
|
32
36
|
@edit_video = Resources::EditVideo.new(http)
|
|
37
|
+
@keyframe_to_video = Resources::KeyframeToVideo.new(http)
|
|
38
|
+
@reference_to_video = Resources::ReferenceToVideo.new(http)
|
|
33
39
|
end
|
|
34
40
|
end
|
|
35
41
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RunApi
|
|
4
|
+
module Kling
|
|
5
|
+
module Resources
|
|
6
|
+
# Kling 4.0 keyframe-to-video resource.
|
|
7
|
+
class KeyframeToVideo
|
|
8
|
+
include RunApi::Core::ResourceHelpers
|
|
9
|
+
|
|
10
|
+
ENDPOINT = "/api/v1/kling/keyframe_to_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
|
+
request(:post, ENDPOINT, body: compact_params(params), options: options)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def get(id, options: nil)
|
|
26
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RunApi
|
|
4
|
+
module Kling
|
|
5
|
+
module Resources
|
|
6
|
+
# Kling 4.0 reference-to-video resource.
|
|
7
|
+
class ReferenceToVideo
|
|
8
|
+
include RunApi::Core::ResourceHelpers
|
|
9
|
+
|
|
10
|
+
ENDPOINT = "/api/v1/kling/reference_to_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
|
+
request(:post, ENDPOINT, body: compact_params(params), options: options)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def get(id, options: nil)
|
|
26
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RunApi
|
|
4
|
+
module Kling
|
|
5
|
+
module Resources
|
|
6
|
+
# Kling text-to-image resource.
|
|
7
|
+
# Generate images from text prompts.
|
|
8
|
+
class TextToImage
|
|
9
|
+
include RunApi::Core::ResourceHelpers
|
|
10
|
+
|
|
11
|
+
ENDPOINT = "/api/v1/kling/text_to_image"
|
|
12
|
+
|
|
13
|
+
RESPONSE_CLASS = Types::TextToImageResponse
|
|
14
|
+
COMPLETED_RESPONSE_CLASS = Types::CompletedTextToImageResponse
|
|
15
|
+
|
|
16
|
+
def initialize(http)
|
|
17
|
+
@http = http
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Generate a text-to-image task and wait until complete.
|
|
21
|
+
#
|
|
22
|
+
# @param params [Hash] text-to-image parameters
|
|
23
|
+
# @return [RunApi::Kling::Types::CompletedTextToImageResponse] completed task with images
|
|
24
|
+
def run(options: nil, **params)
|
|
25
|
+
task = create(options: options, **params)
|
|
26
|
+
poll_until_complete { get(task.id, options: options) }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Create a text-to-image task.
|
|
30
|
+
#
|
|
31
|
+
# @param params [Hash] text-to-image parameters
|
|
32
|
+
# @return [RunApi::Kling::Types::TextToImageResponse] task creation result with id
|
|
33
|
+
def create(options: nil, **params)
|
|
34
|
+
params = compact_params(params)
|
|
35
|
+
request(:post, ENDPOINT, body: params, options: options)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Get text-to-image task status by task ID.
|
|
39
|
+
#
|
|
40
|
+
# @param id [String] task ID
|
|
41
|
+
# @return [RunApi::Kling::Types::TextToImageResponse] current task status
|
|
42
|
+
def get(id, options: nil)
|
|
43
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/runapi/kling/types.rb
CHANGED
|
@@ -4,6 +4,21 @@ module RunApi
|
|
|
4
4
|
module Kling
|
|
5
5
|
# Type definitions for Kling video generation.
|
|
6
6
|
module Types
|
|
7
|
+
class Image < RunApi::Core::BaseModel
|
|
8
|
+
optional :url, String
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class TextToImageResponse < RunApi::Core::TaskResponse
|
|
12
|
+
required :id, String
|
|
13
|
+
optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
|
|
14
|
+
optional :images, [-> { Image }]
|
|
15
|
+
optional :error, String
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class CompletedTextToImageResponse < TextToImageResponse
|
|
19
|
+
required :images, [-> { Image }]
|
|
20
|
+
end
|
|
21
|
+
|
|
7
22
|
# A generated video file with a download URL.
|
|
8
23
|
class Video < RunApi::Core::BaseModel
|
|
9
24
|
optional :url, String
|
data/lib/runapi/kling.rb
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
require "runapi/core"
|
|
4
4
|
require_relative "kling/types"
|
|
5
5
|
require_relative "kling/resources/text_to_video"
|
|
6
|
+
require_relative "kling/resources/text_to_image"
|
|
6
7
|
require_relative "kling/resources/ai_avatar"
|
|
7
8
|
require_relative "kling/resources/image_to_video"
|
|
8
9
|
require_relative "kling/resources/motion_control"
|
|
9
10
|
require_relative "kling/resources/extend_video"
|
|
10
11
|
require_relative "kling/resources/edit_video"
|
|
12
|
+
require_relative "kling/resources/keyframe_to_video"
|
|
13
|
+
require_relative "kling/resources/reference_to_video"
|
|
11
14
|
require_relative "kling/client"
|
|
12
15
|
|
|
13
16
|
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.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- RunAPI
|
|
@@ -43,7 +43,10 @@ files:
|
|
|
43
43
|
- lib/runapi/kling/resources/edit_video.rb
|
|
44
44
|
- lib/runapi/kling/resources/extend_video.rb
|
|
45
45
|
- lib/runapi/kling/resources/image_to_video.rb
|
|
46
|
+
- lib/runapi/kling/resources/keyframe_to_video.rb
|
|
46
47
|
- lib/runapi/kling/resources/motion_control.rb
|
|
48
|
+
- lib/runapi/kling/resources/reference_to_video.rb
|
|
49
|
+
- lib/runapi/kling/resources/text_to_image.rb
|
|
47
50
|
- lib/runapi/kling/resources/text_to_video.rb
|
|
48
51
|
- lib/runapi/kling/types.rb
|
|
49
52
|
homepage: https://runapi.ai/models/kling
|