runapi-wan 0.2.6 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbc05521adf750d4146cf35031cc55dad92fd762f83048f56cb5083e702e0d4f
4
- data.tar.gz: b717b95a9b712d242de851922717953f0b6ef8dd7a77b70ccce17c169343287e
3
+ metadata.gz: f6a0a9c2970e6074e228f6d471414471703a9f255de8e157f0d222350f7c73f8
4
+ data.tar.gz: 5262e5103736aeb346183823f755e6e65e373e2d4da177e24609a8fcf0ad23a1
5
5
  SHA512:
6
- metadata.gz: c4b5da04973ec6bde472f9ea0fd9cb746b749855a6292e69edeb0b08b303d8a7056d058a019e4de209d3a56f60091e756b9e6d566ffc68ae942273acf4063c55
7
- data.tar.gz: b94bac6024b1adb20f4c8500b1e0e14f15f09344bb55a81285cbca87d1cb8feef4c35c9e6653d1f58cd904a1662550b753732f166d7e54a47e0dc141b5d90e94
6
+ metadata.gz: f1eed621ce410ac7962200c6930ed100c010f9348dd5b3a06e276918ad5d56ab5c3dae56ca52667b7f2184573d3cbc0a58a5b6c8193d5e2a97db077b61be7b0a
7
+ data.tar.gz: fbe4cff342e7da3c49bcfd27a334235f89f3838f4e5440de27c513d89a4db186f9bb8d03cc27123e892e2df055fac865fbd181861aa4392c43023bad96544338
data/README.md CHANGED
@@ -24,6 +24,8 @@ status = client.text_to_video.get(task.id)
24
24
 
25
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
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
+
27
29
  ## Language notes
28
30
 
29
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.
@@ -2,15 +2,33 @@
2
2
 
3
3
  module RunApi
4
4
  module Wan
5
- class Client
6
- attr_reader :text_to_video, :image_to_video,
7
- :speech_to_video, :animate, :text_to_image, :edit_video
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
- @api_key = Core::Auth.resolve_api_key(api_key)
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)
@@ -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
@@ -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
@@ -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
@@ -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
@@ -3,6 +3,8 @@
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
@@ -11,6 +13,8 @@ module RunApi
11
13
  wan-2.7-r2v
12
14
  ].freeze
13
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.
14
18
  IMAGE_TO_VIDEO_MODELS = %w[
15
19
  wan-2.2-a14b-image-to-video-turbo
16
20
  wan-2.5-image-to-video
@@ -19,23 +23,31 @@ module RunApi
19
23
  wan-2.7-image-to-video
20
24
  ].freeze
21
25
 
26
+ # Speech-driven lip-sync model for talking-head video generation.
22
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).
23
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.
24
31
  TEXT_TO_IMAGE_MODELS = %w[wan-2.7-image wan-2.7-image-pro].freeze
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.
25
34
  EDIT_VIDEO_MODELS = %w[
26
35
  wan-2.6-edit-video
27
36
  wan-2.6-flash-edit-video
28
37
  wan-2.7-edit-video
29
38
  ].freeze
30
39
 
40
+ # A single generated video result.
31
41
  class Video < RunApi::Core::BaseModel
32
42
  optional :url, String
33
43
  end
34
44
 
45
+ # A single generated image result.
35
46
  class Image < RunApi::Core::BaseModel
36
47
  optional :url, String
37
48
  end
38
49
 
50
+ # Task result for video generation and editing operations.
39
51
  class VideoTaskResponse < RunApi::Core::TaskResponse
40
52
  required :id, String
41
53
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
@@ -43,6 +55,7 @@ module RunApi
43
55
  optional :error, String
44
56
  end
45
57
 
58
+ # Task result for text-to-image operations.
46
59
  class ImageTaskResponse < RunApi::Core::TaskResponse
47
60
  required :id, String
48
61
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
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.6
4
+ version: 0.2.7
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.2.5
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.5
25
+ version: 0.2.6
26
26
  description: The wan video api Ruby SDK is the language-specific package for Wan on
27
27
  RunAPI. Use this wan video api package for text-to-video, image-to-video, animation,
28
28
  and video editing flows when your application needs JSON request bodies, task status