runapi-wan 0.2.1 → 0.2.6
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 +43 -0
- data/lib/runapi/wan/client.rb +2 -4
- data/lib/runapi/wan/resources/animate.rb +2 -2
- data/lib/runapi/wan/resources/edit_video.rb +8 -1
- data/lib/runapi/wan/resources/speech_to_video.rb +2 -2
- data/lib/runapi/wan/types.rb +21 -22
- data/lib/runapi/wan.rb +0 -2
- metadata +13 -10
- data/lib/runapi/wan/resources/reference_to_video.rb +0 -46
- data/lib/runapi/wan/resources/video_to_video.rb +0 -46
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dbc05521adf750d4146cf35031cc55dad92fd762f83048f56cb5083e702e0d4f
|
|
4
|
+
data.tar.gz: b717b95a9b712d242de851922717953f0b6ef8dd7a77b70ccce17c169343287e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4b5da04973ec6bde472f9ea0fd9cb746b749855a6292e69edeb0b08b303d8a7056d058a019e4de209d3a56f60091e756b9e6d566ffc68ae942273acf4063c55
|
|
7
|
+
data.tar.gz: b94bac6024b1adb20f4c8500b1e0e14f15f09344bb55a81285cbca87d1cb8feef4c35c9e6653d1f58cd904a1662550b753732f166d7e54a47e0dc141b5d90e94
|
data/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Wan Video API Ruby SDK for RunAPI
|
|
2
|
+
|
|
3
|
+
The wan video api Ruby SDK is the language-specific package for Wan on RunAPI. Use this wan video api package for text-to-video, image-to-video, animation, and video editing flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in Ruby.
|
|
4
|
+
|
|
5
|
+
This wan video api README is the Ruby package guide inside the public `wan-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/wan; for API reference, use https://runapi.ai/docs#wan; for SDK docs, use https://runapi.ai/docs#sdk-wan.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
gem install runapi-wan
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
require "runapi-wan"
|
|
17
|
+
|
|
18
|
+
client = RunApi::Wan::Client.new
|
|
19
|
+
task = client.text_to_video.create(
|
|
20
|
+
# Pass the Wan JSON request body from https://runapi.ai/docs#wan.
|
|
21
|
+
)
|
|
22
|
+
status = client.text_to_video.get(task.id)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
## Language notes
|
|
28
|
+
|
|
29
|
+
Use Ruby keyword arguments and the `RunApi::Wan` error classes when building video jobs, Rails workers, or scripts. The available resources include text to videos, image to videos, speech to videos, animations, images, and video edits. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
|
|
30
|
+
|
|
31
|
+
## Links
|
|
32
|
+
|
|
33
|
+
- Model page: https://runapi.ai/models/wan
|
|
34
|
+
- SDK docs: https://runapi.ai/docs#sdk-wan
|
|
35
|
+
- Product docs: https://runapi.ai/docs#wan
|
|
36
|
+
- Pricing and rate limits: https://runapi.ai/models/wan/2.2-a14b-text-to-video-turbo
|
|
37
|
+
- Provider comparison: https://runapi.ai/providers/alibaba
|
|
38
|
+
- Full catalog: https://runapi.ai/models
|
|
39
|
+
- Repository: https://github.com/runapi-ai/wan-sdk
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
Licensed under the Apache License, Version 2.0.
|
data/lib/runapi/wan/client.rb
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Wan
|
|
5
5
|
class Client
|
|
6
|
-
attr_reader :text_to_video, :image_to_video,
|
|
7
|
-
:speech_to_video, :animate, :text_to_image, :
|
|
6
|
+
attr_reader :text_to_video, :image_to_video,
|
|
7
|
+
:speech_to_video, :animate, :text_to_image, :edit_video
|
|
8
8
|
|
|
9
9
|
def initialize(api_key: nil, **options)
|
|
10
10
|
@api_key = Core::Auth.resolve_api_key(api_key)
|
|
@@ -14,11 +14,9 @@ module RunApi
|
|
|
14
14
|
|
|
15
15
|
@text_to_video = Resources::TextToVideo.new(http)
|
|
16
16
|
@image_to_video = Resources::ImageToVideo.new(http)
|
|
17
|
-
@video_to_video = Resources::VideoToVideo.new(http)
|
|
18
17
|
@speech_to_video = Resources::SpeechToVideo.new(http)
|
|
19
18
|
@animate = Resources::Animate.new(http)
|
|
20
19
|
@text_to_image = Resources::TextToImage.new(http)
|
|
21
|
-
@reference_to_video = Resources::ReferenceToVideo.new(http)
|
|
22
20
|
@edit_video = Resources::EditVideo.new(http)
|
|
23
21
|
end
|
|
24
22
|
end
|
|
@@ -33,8 +33,8 @@ module RunApi
|
|
|
33
33
|
|
|
34
34
|
def validate_params!(params)
|
|
35
35
|
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
36
|
-
raise Core::ValidationError, "
|
|
37
|
-
raise Core::ValidationError, "
|
|
36
|
+
raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
|
|
37
|
+
raise Core::ValidationError, "reference_video_url is required" unless param(params, :reference_video_url)
|
|
38
38
|
|
|
39
39
|
model = param(params, :model)
|
|
40
40
|
unless Types::ANIMATE_MODELS.include?(model)
|
|
@@ -33,12 +33,19 @@ module RunApi
|
|
|
33
33
|
|
|
34
34
|
def validate_params!(params)
|
|
35
35
|
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
36
|
-
raise Core::ValidationError, "video_url is required" unless param(params, :video_url)
|
|
37
36
|
|
|
38
37
|
model = param(params, :model)
|
|
39
38
|
unless Types::EDIT_VIDEO_MODELS.include?(model)
|
|
40
39
|
raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::EDIT_VIDEO_MODELS.join(", ")}"
|
|
41
40
|
end
|
|
41
|
+
|
|
42
|
+
if model.include?("2.6")
|
|
43
|
+
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
44
|
+
urls = param(params, :source_video_urls)
|
|
45
|
+
raise Core::ValidationError, "source_video_urls is required" if urls.nil? || urls.empty?
|
|
46
|
+
else
|
|
47
|
+
raise Core::ValidationError, "source_video_url is required" unless param(params, :source_video_url)
|
|
48
|
+
end
|
|
42
49
|
end
|
|
43
50
|
end
|
|
44
51
|
end
|
|
@@ -33,8 +33,8 @@ module RunApi
|
|
|
33
33
|
|
|
34
34
|
def validate_params!(params)
|
|
35
35
|
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
36
|
-
raise Core::ValidationError, "
|
|
37
|
-
raise Core::ValidationError, "
|
|
36
|
+
raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
|
|
37
|
+
raise Core::ValidationError, "source_audio_url is required" unless param(params, :source_audio_url)
|
|
38
38
|
|
|
39
39
|
model = param(params, :model)
|
|
40
40
|
unless Types::SPEECH_TO_VIDEO_MODELS.include?(model)
|
data/lib/runapi/wan/types.rb
CHANGED
|
@@ -4,31 +4,30 @@ module RunApi
|
|
|
4
4
|
module Wan
|
|
5
5
|
module Types
|
|
6
6
|
TEXT_TO_VIDEO_MODELS = %w[
|
|
7
|
-
wan-2
|
|
8
|
-
wan-2
|
|
9
|
-
wan-2
|
|
10
|
-
wan-2
|
|
7
|
+
wan-2.2-a14b-text-to-video-turbo
|
|
8
|
+
wan-2.5-text-to-video
|
|
9
|
+
wan-2.6-text-to-video
|
|
10
|
+
wan-2.7-text-to-video
|
|
11
|
+
wan-2.7-r2v
|
|
11
12
|
].freeze
|
|
12
13
|
|
|
13
14
|
IMAGE_TO_VIDEO_MODELS = %w[
|
|
14
|
-
wan-2
|
|
15
|
-
wan-2
|
|
16
|
-
wan-2
|
|
17
|
-
wan-2
|
|
18
|
-
wan-2
|
|
15
|
+
wan-2.2-a14b-image-to-video-turbo
|
|
16
|
+
wan-2.5-image-to-video
|
|
17
|
+
wan-2.6-image-to-video
|
|
18
|
+
wan-2.6-flash-image-to-video
|
|
19
|
+
wan-2.7-image-to-video
|
|
19
20
|
].freeze
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
SPEECH_TO_VIDEO_MODELS = %w[wan-2.2-a14b-speech-to-video-turbo].freeze
|
|
23
|
+
ANIMATE_MODELS = %w[wan-2.2-animate-move wan-2.2-animate-replace].freeze
|
|
24
|
+
TEXT_TO_IMAGE_MODELS = %w[wan-2.7-image wan-2.7-image-pro].freeze
|
|
25
|
+
EDIT_VIDEO_MODELS = %w[
|
|
26
|
+
wan-2.6-edit-video
|
|
27
|
+
wan-2.6-flash-edit-video
|
|
28
|
+
wan-2.7-edit-video
|
|
24
29
|
].freeze
|
|
25
30
|
|
|
26
|
-
SPEECH_TO_VIDEO_MODELS = %w[wan-2-2-a14b-speech-to-video-turbo].freeze
|
|
27
|
-
ANIMATE_MODELS = %w[wan-2-2-animate-move wan-2-2-animate-replace].freeze
|
|
28
|
-
TEXT_TO_IMAGE_MODELS = %w[wan-2-7-image wan-2-7-image-pro].freeze
|
|
29
|
-
REFERENCE_TO_VIDEO_MODELS = %w[wan-2-7-r2v].freeze
|
|
30
|
-
EDIT_VIDEO_MODELS = %w[wan-2-7-videoedit].freeze
|
|
31
|
-
|
|
32
31
|
class Video < RunApi::Core::BaseModel
|
|
33
32
|
optional :url, String
|
|
34
33
|
end
|
|
@@ -40,14 +39,14 @@ module RunApi
|
|
|
40
39
|
class VideoTaskResponse < RunApi::Core::TaskResponse
|
|
41
40
|
required :id, String
|
|
42
41
|
optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
|
|
43
|
-
optional :videos, [
|
|
42
|
+
optional :videos, [-> { Video }]
|
|
44
43
|
optional :error, String
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
class ImageTaskResponse < RunApi::Core::TaskResponse
|
|
48
47
|
required :id, String
|
|
49
48
|
optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
|
|
50
|
-
optional :images, [
|
|
49
|
+
optional :images, [-> { Image }]
|
|
51
50
|
optional :error, String
|
|
52
51
|
end
|
|
53
52
|
|
|
@@ -55,11 +54,11 @@ module RunApi
|
|
|
55
54
|
# `status: "completed"`. Result arrays are required so consumers never
|
|
56
55
|
# have to null-check them on a successful task.
|
|
57
56
|
class CompletedVideoTaskResponse < VideoTaskResponse
|
|
58
|
-
required :videos, [
|
|
57
|
+
required :videos, [-> { Video }]
|
|
59
58
|
end
|
|
60
59
|
|
|
61
60
|
class CompletedImageTaskResponse < ImageTaskResponse
|
|
62
|
-
required :images, [
|
|
61
|
+
required :images, [-> { Image }]
|
|
63
62
|
end
|
|
64
63
|
end
|
|
65
64
|
end
|
data/lib/runapi/wan.rb
CHANGED
|
@@ -4,11 +4,9 @@ require "runapi/core"
|
|
|
4
4
|
require_relative "wan/types"
|
|
5
5
|
require_relative "wan/resources/text_to_video"
|
|
6
6
|
require_relative "wan/resources/image_to_video"
|
|
7
|
-
require_relative "wan/resources/video_to_video"
|
|
8
7
|
require_relative "wan/resources/speech_to_video"
|
|
9
8
|
require_relative "wan/resources/animate"
|
|
10
9
|
require_relative "wan/resources/text_to_image"
|
|
11
|
-
require_relative "wan/resources/reference_to_video"
|
|
12
10
|
require_relative "wan/resources/edit_video"
|
|
13
11
|
require_relative "wan/client"
|
|
14
12
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: runapi-wan
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- RunAPI
|
|
@@ -15,39 +15,42 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
18
|
+
version: 0.2.5
|
|
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:
|
|
26
|
-
description:
|
|
25
|
+
version: 0.2.5
|
|
26
|
+
description: The wan video api Ruby SDK is the language-specific package for Wan on
|
|
27
|
+
RunAPI. Use this wan video api package for text-to-video, image-to-video, animation,
|
|
28
|
+
and video editing flows when your application needs JSON request bodies, task status
|
|
29
|
+
lookup, and consistent RunAPI errors in Ruby.
|
|
27
30
|
email:
|
|
28
31
|
- contact@runapi.ai
|
|
29
32
|
executables: []
|
|
30
33
|
extensions: []
|
|
31
|
-
extra_rdoc_files:
|
|
34
|
+
extra_rdoc_files:
|
|
35
|
+
- README.md
|
|
32
36
|
files:
|
|
33
37
|
- LICENSE
|
|
38
|
+
- README.md
|
|
34
39
|
- lib/runapi/wan.rb
|
|
35
40
|
- lib/runapi/wan/client.rb
|
|
36
41
|
- lib/runapi/wan/resources/animate.rb
|
|
37
42
|
- lib/runapi/wan/resources/edit_video.rb
|
|
38
43
|
- lib/runapi/wan/resources/image_to_video.rb
|
|
39
|
-
- lib/runapi/wan/resources/reference_to_video.rb
|
|
40
44
|
- lib/runapi/wan/resources/speech_to_video.rb
|
|
41
45
|
- lib/runapi/wan/resources/text_to_image.rb
|
|
42
46
|
- lib/runapi/wan/resources/text_to_video.rb
|
|
43
|
-
- lib/runapi/wan/resources/video_to_video.rb
|
|
44
47
|
- lib/runapi/wan/types.rb
|
|
45
48
|
homepage: https://runapi.ai/models/wan
|
|
46
49
|
licenses:
|
|
47
50
|
- Apache-2.0
|
|
48
51
|
metadata:
|
|
49
52
|
homepage_uri: https://runapi.ai/models/wan
|
|
50
|
-
documentation_uri: https://runapi
|
|
53
|
+
documentation_uri: https://github.com/runapi-ai/wan-sdk/blob/main/ruby/README.md
|
|
51
54
|
source_code_uri: https://github.com/runapi-ai/wan-sdk
|
|
52
55
|
changelog_uri: https://github.com/runapi-ai/wan-sdk/blob/main/CHANGELOG.md
|
|
53
56
|
rdoc_options: []
|
|
@@ -64,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
64
67
|
- !ruby/object:Gem::Version
|
|
65
68
|
version: '0'
|
|
66
69
|
requirements: []
|
|
67
|
-
rubygems_version: 4.0.
|
|
70
|
+
rubygems_version: 4.0.10
|
|
68
71
|
specification_version: 4
|
|
69
|
-
summary: Wan API
|
|
72
|
+
summary: Wan Video API Ruby SDK for RunAPI
|
|
70
73
|
test_files: []
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RunApi
|
|
4
|
-
module Wan
|
|
5
|
-
module Resources
|
|
6
|
-
class ReferenceToVideo
|
|
7
|
-
include RunApi::Core::ResourceHelpers
|
|
8
|
-
|
|
9
|
-
ENDPOINT = "/api/v1/wan/reference_to_video"
|
|
10
|
-
RESPONSE_CLASS = Types::VideoTaskResponse
|
|
11
|
-
COMPLETED_RESPONSE_CLASS = Types::CompletedVideoTaskResponse
|
|
12
|
-
|
|
13
|
-
def initialize(http)
|
|
14
|
-
@http = http
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def run(**params)
|
|
18
|
-
task = create(**params)
|
|
19
|
-
poll_until_complete { get(task.id) }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def create(**params)
|
|
23
|
-
params = compact_params(params)
|
|
24
|
-
validate_params!(params)
|
|
25
|
-
request(:post, ENDPOINT, body: params)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def get(id)
|
|
29
|
-
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
def validate_params!(params)
|
|
35
|
-
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
36
|
-
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
37
|
-
|
|
38
|
-
model = param(params, :model)
|
|
39
|
-
unless Types::REFERENCE_TO_VIDEO_MODELS.include?(model)
|
|
40
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::REFERENCE_TO_VIDEO_MODELS.join(", ")}"
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RunApi
|
|
4
|
-
module Wan
|
|
5
|
-
module Resources
|
|
6
|
-
class VideoToVideo
|
|
7
|
-
include RunApi::Core::ResourceHelpers
|
|
8
|
-
|
|
9
|
-
ENDPOINT = "/api/v1/wan/video_to_video"
|
|
10
|
-
RESPONSE_CLASS = Types::VideoTaskResponse
|
|
11
|
-
COMPLETED_RESPONSE_CLASS = Types::CompletedVideoTaskResponse
|
|
12
|
-
|
|
13
|
-
def initialize(http)
|
|
14
|
-
@http = http
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def run(**params)
|
|
18
|
-
task = create(**params)
|
|
19
|
-
poll_until_complete { get(task.id) }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def create(**params)
|
|
23
|
-
params = compact_params(params)
|
|
24
|
-
validate_params!(params)
|
|
25
|
-
request(:post, ENDPOINT, body: params)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def get(id)
|
|
29
|
-
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
def validate_params!(params)
|
|
35
|
-
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
36
|
-
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
37
|
-
|
|
38
|
-
model = param(params, :model)
|
|
39
|
-
unless Types::VIDEO_TO_VIDEO_MODELS.include?(model)
|
|
40
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::VIDEO_TO_VIDEO_MODELS.join(", ")}"
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|