runapi-wan 0.2.4 → 0.2.7
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 +45 -0
- data/lib/runapi/wan/client.rb +25 -9
- data/lib/runapi/wan/resources/animate.rb +17 -2
- data/lib/runapi/wan/resources/edit_video.rb +23 -1
- data/lib/runapi/wan/resources/image_to_video.rb +14 -0
- data/lib/runapi/wan/resources/speech_to_video.rb +16 -2
- data/lib/runapi/wan/resources/text_to_image.rb +15 -0
- data/lib/runapi/wan/resources/text_to_video.rb +15 -0
- data/lib/runapi/wan/types.rb +23 -11
- data/lib/runapi/wan.rb +0 -2
- metadata +12 -9
- 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: f6a0a9c2970e6074e228f6d471414471703a9f255de8e157f0d222350f7c73f8
|
|
4
|
+
data.tar.gz: 5262e5103736aeb346183823f755e6e65e373e2d4da177e24609a8fcf0ad23a1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f1eed621ce410ac7962200c6930ed100c010f9348dd5b3a06e276918ad5d56ab5c3dae56ca52667b7f2184573d3cbc0a58a5b6c8193d5e2a97db077b61be7b0a
|
|
7
|
+
data.tar.gz: fbe4cff342e7da3c49bcfd27a334235f89f3838f4e5440de27c513d89a4db186f9bb8d03cc27123e892e2df055fac865fbd181861aa4392c43023bad96544338
|
data/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
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.
|
|
28
|
+
|
|
29
|
+
## Language notes
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
## Links
|
|
34
|
+
|
|
35
|
+
- Model page: https://runapi.ai/models/wan
|
|
36
|
+
- SDK docs: https://runapi.ai/docs#sdk-wan
|
|
37
|
+
- Product docs: https://runapi.ai/docs#wan
|
|
38
|
+
- Pricing and rate limits: https://runapi.ai/models/wan/2.2-a14b-text-to-video-turbo
|
|
39
|
+
- Provider comparison: https://runapi.ai/providers/alibaba
|
|
40
|
+
- Full catalog: https://runapi.ai/models
|
|
41
|
+
- Repository: https://github.com/runapi-ai/wan-sdk
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
Licensed under the Apache License, Version 2.0.
|
data/lib/runapi/wan/client.rb
CHANGED
|
@@ -2,23 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Wan
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
# Wan video and image generation API client.
|
|
6
|
+
#
|
|
7
|
+
# Spans multiple generation families (2.2 through 2.7) with progressive
|
|
8
|
+
# capability upgrades. Feature availability varies by model variant.
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# client = RunApi::Wan::Client.new(api_key: "your-api-key")
|
|
12
|
+
# result = client.text_to_video.run(
|
|
13
|
+
# model: "wan-2.6-text-to-video",
|
|
14
|
+
# prompt: "A scenic mountain landscape with flowing rivers"
|
|
15
|
+
# )
|
|
16
|
+
class Client < RunApi::Core::Client
|
|
17
|
+
# @return [Resources::TextToVideo] Generate videos from text prompts. Supports turbo (2.2) through 2.7 with progressive features.
|
|
18
|
+
attr_reader :text_to_video
|
|
19
|
+
# @return [Resources::ImageToVideo] Generate videos driven by a source image. Flash variants trade fidelity for speed.
|
|
20
|
+
attr_reader :image_to_video
|
|
21
|
+
# @return [Resources::SpeechToVideo] Generate lip-synced talking-head videos from a portrait image and speech audio.
|
|
22
|
+
attr_reader :speech_to_video
|
|
23
|
+
# @return [Resources::Animate] Transfer motion from a reference video onto a subject image (move or replace).
|
|
24
|
+
attr_reader :animate
|
|
25
|
+
# @return [Resources::TextToImage] Generate images with optional color palette, bounding box, and thinking mode.
|
|
26
|
+
attr_reader :text_to_image
|
|
27
|
+
# @return [Resources::EditVideo] Modify existing videos guided by text prompts and optional reference images.
|
|
28
|
+
attr_reader :edit_video
|
|
8
29
|
|
|
9
30
|
def initialize(api_key: nil, **options)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
client_options = Core::ClientOptions.new(api_key: @api_key, **options)
|
|
13
|
-
http = client_options.http_client || Core::HttpClient.new(client_options)
|
|
31
|
+
super
|
|
14
32
|
|
|
15
33
|
@text_to_video = Resources::TextToVideo.new(http)
|
|
16
34
|
@image_to_video = Resources::ImageToVideo.new(http)
|
|
17
|
-
@video_to_video = Resources::VideoToVideo.new(http)
|
|
18
35
|
@speech_to_video = Resources::SpeechToVideo.new(http)
|
|
19
36
|
@animate = Resources::Animate.new(http)
|
|
20
37
|
@text_to_image = Resources::TextToImage.new(http)
|
|
21
|
-
@reference_to_video = Resources::ReferenceToVideo.new(http)
|
|
22
38
|
@edit_video = Resources::EditVideo.new(http)
|
|
23
39
|
end
|
|
24
40
|
end
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Wan
|
|
5
5
|
module Resources
|
|
6
|
+
# Transfers motion from a reference video onto a subject in the source image.
|
|
7
|
+
# Use wan-2.2-animate-move to preserve the subject and animate its motion,
|
|
8
|
+
# or wan-2.2-animate-replace to swap the subject with the reference video's subject.
|
|
6
9
|
class Animate
|
|
7
10
|
include RunApi::Core::ResourceHelpers
|
|
8
11
|
|
|
@@ -14,17 +17,29 @@ module RunApi
|
|
|
14
17
|
@http = http
|
|
15
18
|
end
|
|
16
19
|
|
|
20
|
+
# Transfer motion and wait until complete.
|
|
21
|
+
#
|
|
22
|
+
# @param params [Hash] animation parameters
|
|
23
|
+
# @return [RunApi::Wan::Types::CompletedVideoTaskResponse] completed animation result
|
|
17
24
|
def run(**params)
|
|
18
25
|
task = create(**params)
|
|
19
26
|
poll_until_complete { get(task.id) }
|
|
20
27
|
end
|
|
21
28
|
|
|
29
|
+
# Create an animation task.
|
|
30
|
+
#
|
|
31
|
+
# @param params [Hash] animation parameters
|
|
32
|
+
# @return [RunApi::Wan::Types::VideoTaskResponse] task creation result with id
|
|
22
33
|
def create(**params)
|
|
23
34
|
params = compact_params(params)
|
|
24
35
|
validate_params!(params)
|
|
25
36
|
request(:post, ENDPOINT, body: params)
|
|
26
37
|
end
|
|
27
38
|
|
|
39
|
+
# Get animation status by task ID.
|
|
40
|
+
#
|
|
41
|
+
# @param id [String] task ID
|
|
42
|
+
# @return [RunApi::Wan::Types::VideoTaskResponse] current task status
|
|
28
43
|
def get(id)
|
|
29
44
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
45
|
end
|
|
@@ -33,8 +48,8 @@ module RunApi
|
|
|
33
48
|
|
|
34
49
|
def validate_params!(params)
|
|
35
50
|
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
36
|
-
raise Core::ValidationError, "
|
|
37
|
-
raise Core::ValidationError, "
|
|
51
|
+
raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
|
|
52
|
+
raise Core::ValidationError, "reference_video_url is required" unless param(params, :reference_video_url)
|
|
38
53
|
|
|
39
54
|
model = param(params, :model)
|
|
40
55
|
unless Types::ANIMATE_MODELS.include?(model)
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Wan
|
|
5
5
|
module Resources
|
|
6
|
+
# Modifies existing videos guided by a text prompt and optional reference image.
|
|
7
|
+
# The 2.6 models use source_video_urls (plural, required) while 2.7 uses
|
|
8
|
+
# source_video_url (singular, required). Flash variants support audio and multi-shot.
|
|
6
9
|
class EditVideo
|
|
7
10
|
include RunApi::Core::ResourceHelpers
|
|
8
11
|
|
|
@@ -14,17 +17,29 @@ module RunApi
|
|
|
14
17
|
@http = http
|
|
15
18
|
end
|
|
16
19
|
|
|
20
|
+
# Edit a video and wait until complete.
|
|
21
|
+
#
|
|
22
|
+
# @param params [Hash] video editing parameters
|
|
23
|
+
# @return [RunApi::Wan::Types::CompletedVideoTaskResponse] completed video edit
|
|
17
24
|
def run(**params)
|
|
18
25
|
task = create(**params)
|
|
19
26
|
poll_until_complete { get(task.id) }
|
|
20
27
|
end
|
|
21
28
|
|
|
29
|
+
# Create a video editing task.
|
|
30
|
+
#
|
|
31
|
+
# @param params [Hash] video editing parameters
|
|
32
|
+
# @return [RunApi::Wan::Types::VideoTaskResponse] task creation result with id
|
|
22
33
|
def create(**params)
|
|
23
34
|
params = compact_params(params)
|
|
24
35
|
validate_params!(params)
|
|
25
36
|
request(:post, ENDPOINT, body: params)
|
|
26
37
|
end
|
|
27
38
|
|
|
39
|
+
# Get video editing status by task ID.
|
|
40
|
+
#
|
|
41
|
+
# @param id [String] task ID
|
|
42
|
+
# @return [RunApi::Wan::Types::VideoTaskResponse] current task status
|
|
28
43
|
def get(id)
|
|
29
44
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
45
|
end
|
|
@@ -33,12 +48,19 @@ module RunApi
|
|
|
33
48
|
|
|
34
49
|
def validate_params!(params)
|
|
35
50
|
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
36
|
-
raise Core::ValidationError, "video_url is required" unless param(params, :video_url)
|
|
37
51
|
|
|
38
52
|
model = param(params, :model)
|
|
39
53
|
unless Types::EDIT_VIDEO_MODELS.include?(model)
|
|
40
54
|
raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::EDIT_VIDEO_MODELS.join(", ")}"
|
|
41
55
|
end
|
|
56
|
+
|
|
57
|
+
if model.include?("2.6")
|
|
58
|
+
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
59
|
+
urls = param(params, :source_video_urls)
|
|
60
|
+
raise Core::ValidationError, "source_video_urls is required" if urls.nil? || urls.empty?
|
|
61
|
+
else
|
|
62
|
+
raise Core::ValidationError, "source_video_url is required" unless param(params, :source_video_url)
|
|
63
|
+
end
|
|
42
64
|
end
|
|
43
65
|
end
|
|
44
66
|
end
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Wan
|
|
5
5
|
module Resources
|
|
6
|
+
# Generates videos driven by a source image. Flash variants trade fidelity
|
|
7
|
+
# for speed; 2.7 adds last-frame control, video continuation, and audio features.
|
|
6
8
|
class ImageToVideo
|
|
7
9
|
include RunApi::Core::ResourceHelpers
|
|
8
10
|
|
|
@@ -14,17 +16,29 @@ module RunApi
|
|
|
14
16
|
@http = http
|
|
15
17
|
end
|
|
16
18
|
|
|
19
|
+
# Generate a video from an image and wait until complete.
|
|
20
|
+
#
|
|
21
|
+
# @param params [Hash] image-to-video parameters
|
|
22
|
+
# @return [RunApi::Wan::Types::CompletedVideoTaskResponse] completed video generation
|
|
17
23
|
def run(**params)
|
|
18
24
|
task = create(**params)
|
|
19
25
|
poll_until_complete { get(task.id) }
|
|
20
26
|
end
|
|
21
27
|
|
|
28
|
+
# Create an image-to-video generation task.
|
|
29
|
+
#
|
|
30
|
+
# @param params [Hash] image-to-video parameters
|
|
31
|
+
# @return [RunApi::Wan::Types::VideoTaskResponse] task creation result with id
|
|
22
32
|
def create(**params)
|
|
23
33
|
params = compact_params(params)
|
|
24
34
|
validate_params!(params)
|
|
25
35
|
request(:post, ENDPOINT, body: params)
|
|
26
36
|
end
|
|
27
37
|
|
|
38
|
+
# Get image-to-video status by task ID.
|
|
39
|
+
#
|
|
40
|
+
# @param id [String] task ID
|
|
41
|
+
# @return [RunApi::Wan::Types::VideoTaskResponse] current task status
|
|
28
42
|
def get(id)
|
|
29
43
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
44
|
end
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Wan
|
|
5
5
|
module Resources
|
|
6
|
+
# Generates lip-synced talking-head videos from a portrait image and
|
|
7
|
+
# driving speech audio. Both source_image_url and source_audio_url are required.
|
|
6
8
|
class SpeechToVideo
|
|
7
9
|
include RunApi::Core::ResourceHelpers
|
|
8
10
|
|
|
@@ -14,17 +16,29 @@ module RunApi
|
|
|
14
16
|
@http = http
|
|
15
17
|
end
|
|
16
18
|
|
|
19
|
+
# Generate a lip-synced video and wait until complete.
|
|
20
|
+
#
|
|
21
|
+
# @param params [Hash] speech-to-video parameters
|
|
22
|
+
# @return [RunApi::Wan::Types::CompletedVideoTaskResponse] completed video generation
|
|
17
23
|
def run(**params)
|
|
18
24
|
task = create(**params)
|
|
19
25
|
poll_until_complete { get(task.id) }
|
|
20
26
|
end
|
|
21
27
|
|
|
28
|
+
# Create a speech-to-video generation task.
|
|
29
|
+
#
|
|
30
|
+
# @param params [Hash] speech-to-video parameters
|
|
31
|
+
# @return [RunApi::Wan::Types::VideoTaskResponse] task creation result with id
|
|
22
32
|
def create(**params)
|
|
23
33
|
params = compact_params(params)
|
|
24
34
|
validate_params!(params)
|
|
25
35
|
request(:post, ENDPOINT, body: params)
|
|
26
36
|
end
|
|
27
37
|
|
|
38
|
+
# Get speech-to-video status by task ID.
|
|
39
|
+
#
|
|
40
|
+
# @param id [String] task ID
|
|
41
|
+
# @return [RunApi::Wan::Types::VideoTaskResponse] current task status
|
|
28
42
|
def get(id)
|
|
29
43
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
44
|
end
|
|
@@ -33,8 +47,8 @@ module RunApi
|
|
|
33
47
|
|
|
34
48
|
def validate_params!(params)
|
|
35
49
|
raise Core::ValidationError, "model is required" unless param(params, :model)
|
|
36
|
-
raise Core::ValidationError, "
|
|
37
|
-
raise Core::ValidationError, "
|
|
50
|
+
raise Core::ValidationError, "source_image_url is required" unless param(params, :source_image_url)
|
|
51
|
+
raise Core::ValidationError, "source_audio_url is required" unless param(params, :source_audio_url)
|
|
38
52
|
|
|
39
53
|
model = param(params, :model)
|
|
40
54
|
unless Types::SPEECH_TO_VIDEO_MODELS.include?(model)
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Wan
|
|
5
5
|
module Resources
|
|
6
|
+
# Generates images from text prompts with optional color palette and bounding
|
|
7
|
+
# box constraints. Supports batch generation via output_count. Pro model
|
|
8
|
+
# supports thinking_mode for enhanced prompt reasoning.
|
|
6
9
|
class TextToImage
|
|
7
10
|
include RunApi::Core::ResourceHelpers
|
|
8
11
|
|
|
@@ -14,17 +17,29 @@ module RunApi
|
|
|
14
17
|
@http = http
|
|
15
18
|
end
|
|
16
19
|
|
|
20
|
+
# Generate an image and wait until complete.
|
|
21
|
+
#
|
|
22
|
+
# @param params [Hash] text-to-image parameters
|
|
23
|
+
# @return [RunApi::Wan::Types::CompletedImageTaskResponse] completed image generation
|
|
17
24
|
def run(**params)
|
|
18
25
|
task = create(**params)
|
|
19
26
|
poll_until_complete { get(task.id) }
|
|
20
27
|
end
|
|
21
28
|
|
|
29
|
+
# Create a text-to-image generation task.
|
|
30
|
+
#
|
|
31
|
+
# @param params [Hash] text-to-image parameters
|
|
32
|
+
# @return [RunApi::Wan::Types::ImageTaskResponse] task creation result with id
|
|
22
33
|
def create(**params)
|
|
23
34
|
params = compact_params(params)
|
|
24
35
|
validate_params!(params)
|
|
25
36
|
request(:post, ENDPOINT, body: params)
|
|
26
37
|
end
|
|
27
38
|
|
|
39
|
+
# Get text-to-image status by task ID.
|
|
40
|
+
#
|
|
41
|
+
# @param id [String] task ID
|
|
42
|
+
# @return [RunApi::Wan::Types::ImageTaskResponse] current task status
|
|
28
43
|
def get(id)
|
|
29
44
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
45
|
end
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Wan
|
|
5
5
|
module Resources
|
|
6
|
+
# Generates videos from text prompts. Supports turbo (2.2) through 2.7
|
|
7
|
+
# with progressive feature upgrades including negative prompts, watermark
|
|
8
|
+
# control, background audio, and R2V multi-reference inputs.
|
|
6
9
|
class TextToVideo
|
|
7
10
|
include RunApi::Core::ResourceHelpers
|
|
8
11
|
|
|
@@ -14,17 +17,29 @@ module RunApi
|
|
|
14
17
|
@http = http
|
|
15
18
|
end
|
|
16
19
|
|
|
20
|
+
# Generate a video and wait until complete.
|
|
21
|
+
#
|
|
22
|
+
# @param params [Hash] text-to-video parameters
|
|
23
|
+
# @return [RunApi::Wan::Types::CompletedVideoTaskResponse] completed video generation
|
|
17
24
|
def run(**params)
|
|
18
25
|
task = create(**params)
|
|
19
26
|
poll_until_complete { get(task.id) }
|
|
20
27
|
end
|
|
21
28
|
|
|
29
|
+
# Create a text-to-video generation task.
|
|
30
|
+
#
|
|
31
|
+
# @param params [Hash] text-to-video parameters
|
|
32
|
+
# @return [RunApi::Wan::Types::VideoTaskResponse] task creation result with id
|
|
22
33
|
def create(**params)
|
|
23
34
|
params = compact_params(params)
|
|
24
35
|
validate_params!(params)
|
|
25
36
|
request(:post, ENDPOINT, body: params)
|
|
26
37
|
end
|
|
27
38
|
|
|
39
|
+
# Get text-to-video status by task ID.
|
|
40
|
+
#
|
|
41
|
+
# @param id [String] task ID
|
|
42
|
+
# @return [RunApi::Wan::Types::VideoTaskResponse] current task status
|
|
28
43
|
def get(id)
|
|
29
44
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
45
|
end
|
data/lib/runapi/wan/types.rb
CHANGED
|
@@ -3,13 +3,18 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Wan
|
|
5
5
|
module Types
|
|
6
|
+
# Text-to-video variants: 2.2 turbo (fast, lower res) through 2.7 (highest quality)
|
|
7
|
+
# and R2V (accepts reference images, videos, first-frame, and audio).
|
|
6
8
|
TEXT_TO_VIDEO_MODELS = %w[
|
|
7
9
|
wan-2.2-a14b-text-to-video-turbo
|
|
8
10
|
wan-2.5-text-to-video
|
|
9
11
|
wan-2.6-text-to-video
|
|
10
12
|
wan-2.7-text-to-video
|
|
13
|
+
wan-2.7-r2v
|
|
11
14
|
].freeze
|
|
12
15
|
|
|
16
|
+
# Image-to-video variants. Flash trades fidelity for speed; 2.7 adds last-frame
|
|
17
|
+
# control, video continuation, driving/background audio, and watermark.
|
|
13
18
|
IMAGE_TO_VIDEO_MODELS = %w[
|
|
14
19
|
wan-2.2-a14b-image-to-video-turbo
|
|
15
20
|
wan-2.5-image-to-video
|
|
@@ -18,36 +23,43 @@ module RunApi
|
|
|
18
23
|
wan-2.7-image-to-video
|
|
19
24
|
].freeze
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
wan-2.6-video-to-video
|
|
23
|
-
wan-2.6-flash-video-to-video
|
|
24
|
-
].freeze
|
|
25
|
-
|
|
26
|
+
# Speech-driven lip-sync model for talking-head video generation.
|
|
26
27
|
SPEECH_TO_VIDEO_MODELS = %w[wan-2.2-a14b-speech-to-video-turbo].freeze
|
|
28
|
+
# Motion transfer: move (preserves subject) and replace (swaps subject).
|
|
27
29
|
ANIMATE_MODELS = %w[wan-2.2-animate-move wan-2.2-animate-replace].freeze
|
|
30
|
+
# Image generation: standard and pro. Pro model supports thinking_mode for enhanced reasoning.
|
|
28
31
|
TEXT_TO_IMAGE_MODELS = %w[wan-2.7-image wan-2.7-image-pro].freeze
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
# Video editing: 2.6 uses source_video_urls (plural), 2.7 uses source_video_url (singular).
|
|
33
|
+
# Flash variants support audio generation and multi-shot mode.
|
|
34
|
+
EDIT_VIDEO_MODELS = %w[
|
|
35
|
+
wan-2.6-edit-video
|
|
36
|
+
wan-2.6-flash-edit-video
|
|
37
|
+
wan-2.7-edit-video
|
|
38
|
+
].freeze
|
|
31
39
|
|
|
40
|
+
# A single generated video result.
|
|
32
41
|
class Video < RunApi::Core::BaseModel
|
|
33
42
|
optional :url, String
|
|
34
43
|
end
|
|
35
44
|
|
|
45
|
+
# A single generated image result.
|
|
36
46
|
class Image < RunApi::Core::BaseModel
|
|
37
47
|
optional :url, String
|
|
38
48
|
end
|
|
39
49
|
|
|
50
|
+
# Task result for video generation and editing operations.
|
|
40
51
|
class VideoTaskResponse < RunApi::Core::TaskResponse
|
|
41
52
|
required :id, String
|
|
42
53
|
optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
|
|
43
|
-
optional :videos, [
|
|
54
|
+
optional :videos, [-> { Video }]
|
|
44
55
|
optional :error, String
|
|
45
56
|
end
|
|
46
57
|
|
|
58
|
+
# Task result for text-to-image operations.
|
|
47
59
|
class ImageTaskResponse < RunApi::Core::TaskResponse
|
|
48
60
|
required :id, String
|
|
49
61
|
optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
|
|
50
|
-
optional :images, [
|
|
62
|
+
optional :images, [-> { Image }]
|
|
51
63
|
optional :error, String
|
|
52
64
|
end
|
|
53
65
|
|
|
@@ -55,11 +67,11 @@ module RunApi
|
|
|
55
67
|
# `status: "completed"`. Result arrays are required so consumers never
|
|
56
68
|
# have to null-check them on a successful task.
|
|
57
69
|
class CompletedVideoTaskResponse < VideoTaskResponse
|
|
58
|
-
required :videos, [
|
|
70
|
+
required :videos, [-> { Video }]
|
|
59
71
|
end
|
|
60
72
|
|
|
61
73
|
class CompletedImageTaskResponse < ImageTaskResponse
|
|
62
|
-
required :images, [
|
|
74
|
+
required :images, [-> { Image }]
|
|
63
75
|
end
|
|
64
76
|
end
|
|
65
77
|
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.7
|
|
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: 0.2.
|
|
18
|
+
version: 0.2.6
|
|
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.
|
|
26
|
-
description:
|
|
25
|
+
version: 0.2.6
|
|
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://github.com/runapi-ai/wan-sdk/blob/main/README.md
|
|
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: []
|
|
@@ -66,5 +69,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
66
69
|
requirements: []
|
|
67
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
|