runapi-hailuo 0.2.5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1230de918ea20384c9e57ac5a3747ee7ba265e84e54e84db406fe2c8cf6d896
4
- data.tar.gz: ea5f47c1117700e8cb0fbf814a910557ac5b8b11e364efa7c991bcfe85eafdb9
3
+ metadata.gz: 9f95e54a3c54efd90d4dd44df70117de6da0b446167b2cf83c70640a1e7647a9
4
+ data.tar.gz: 4965df466901387f44480016ae970437fa4e90b7a81c14dcb680bac6403ede69
5
5
  SHA512:
6
- metadata.gz: c868db7a59aecdaabbb57b1b2e3278930062ee6a015fc2384e13287a9a8e9127a876e7401a3419aec5d5739053de220476e0287ed0bb42f068c6456f344acdf5
7
- data.tar.gz: d9752d9c75ebd3e679cfb119dc0aa7047dc5ff08631e97c135babed45b05f6f295f3b50422aa5a81fdf9782e697acce8b20b6602061db0562f3f8874c217c712
6
+ metadata.gz: c22c7bdf46bcb6458b1f0753a8c542101fa05a5f56de8080fbbc8d298d4da8f985196b064fc1340d113e3cc71feb10ef868ed53a95fba158b350f6d1ee11a20f
7
+ data.tar.gz: 9d94362787daf471cc98de37c2292bd93fee8836504c0d4e219b1d6d5a3d8e621a3c6b0d2fb5c6b285e21dd35b36f1a9eb8be5f599e44e7e100f143979dd8c60
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::Hailuo` error classes when building video jobs, Rails workers, or scripts. The available resources include text to videos, and image to videos. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
@@ -2,14 +2,22 @@
2
2
 
3
3
  module RunApi
4
4
  module Hailuo
5
- class Client
6
- attr_reader :text_to_video, :image_to_video
5
+ # Hailuo text-to-video and image-to-video generation API client.
6
+ #
7
+ # @example
8
+ # client = RunApi::Hailuo::Client.new(api_key: "your-api-key")
9
+ # result = client.text_to_video.run(
10
+ # model: "hailuo-02-text-to-video-standard",
11
+ # prompt: "A timelapse of cherry blossoms blooming in a Japanese garden"
12
+ # )
13
+ class Client < RunApi::Core::Client
14
+ # @return [Resources::TextToVideo] Text-to-video generation operations.
15
+ attr_reader :text_to_video
16
+ # @return [Resources::ImageToVideo] Image-to-video generation operations.
17
+ attr_reader :image_to_video
7
18
 
8
19
  def initialize(api_key: nil, **options)
9
- @api_key = Core::Auth.resolve_api_key(api_key)
10
-
11
- client_options = Core::ClientOptions.new(api_key: @api_key, **options)
12
- http = client_options.http_client || Core::HttpClient.new(client_options)
20
+ super
13
21
 
14
22
  @text_to_video = Resources::TextToVideo.new(http)
15
23
  @image_to_video = Resources::ImageToVideo.new(http)
@@ -3,6 +3,8 @@
3
3
  module RunApi
4
4
  module Hailuo
5
5
  module Resources
6
+ # Hailuo image-to-video resource.
7
+ # Animate a still image into video guided by a text prompt and first-frame image.
6
8
  class ImageToVideo
7
9
  include RunApi::Core::ResourceHelpers
8
10
 
@@ -15,17 +17,29 @@ module RunApi
15
17
  @http = http
16
18
  end
17
19
 
20
+ # Generate an image-to-video task and wait until complete.
21
+ #
22
+ # @param params [Hash] image-to-video parameters
23
+ # @return [RunApi::Hailuo::Types::CompletedVideoTaskResponse] completed task with videos
18
24
  def run(**params)
19
25
  task = create(**params)
20
26
  poll_until_complete { get(task.id) }
21
27
  end
22
28
 
29
+ # Create an image-to-video task.
30
+ #
31
+ # @param params [Hash] image-to-video parameters
32
+ # @return [RunApi::Hailuo::Types::VideoTaskResponse] task creation result with id
23
33
  def create(**params)
24
34
  params = compact_params(params)
25
35
  validate_params!(params)
26
36
  request(:post, ENDPOINT, body: params)
27
37
  end
28
38
 
39
+ # Get image-to-video task status by task ID.
40
+ #
41
+ # @param id [String] task ID
42
+ # @return [RunApi::Hailuo::Types::VideoTaskResponse] current task status
29
43
  def get(id)
30
44
  request(:get, "#{ENDPOINT}/#{id}")
31
45
  end
@@ -3,6 +3,8 @@
3
3
  module RunApi
4
4
  module Hailuo
5
5
  module Resources
6
+ # Hailuo text-to-video resource.
7
+ # Generate video from a text prompt.
6
8
  class TextToVideo
7
9
  include RunApi::Core::ResourceHelpers
8
10
 
@@ -15,17 +17,29 @@ module RunApi
15
17
  @http = http
16
18
  end
17
19
 
20
+ # Generate a text-to-video task and wait until complete.
21
+ #
22
+ # @param params [Hash] text-to-video parameters
23
+ # @return [RunApi::Hailuo::Types::CompletedVideoTaskResponse] completed task with videos
18
24
  def run(**params)
19
25
  task = create(**params)
20
26
  poll_until_complete { get(task.id) }
21
27
  end
22
28
 
29
+ # Create a text-to-video task.
30
+ #
31
+ # @param params [Hash] text-to-video parameters
32
+ # @return [RunApi::Hailuo::Types::VideoTaskResponse] task creation result with id
23
33
  def create(**params)
24
34
  params = compact_params(params)
25
35
  validate_params!(params)
26
36
  request(:post, ENDPOINT, body: params)
27
37
  end
28
38
 
39
+ # Get text-to-video task status by task ID.
40
+ #
41
+ # @param id [String] task ID
42
+ # @return [RunApi::Hailuo::Types::VideoTaskResponse] current task status
29
43
  def get(id)
30
44
  request(:get, "#{ENDPOINT}/#{id}")
31
45
  end
@@ -2,22 +2,37 @@
2
2
 
3
3
  module RunApi
4
4
  module Hailuo
5
+ # Type definitions and constants for Hailuo video generation.
5
6
  module Types
7
+ # Text-to-video model variants. Pro produces higher-fidelity output;
8
+ # Standard is faster with slightly lower quality. Prompts limited to 1500 characters.
6
9
  TEXT_TO_VIDEO_MODELS = %w[hailuo-02-text-to-video-pro hailuo-02-text-to-video-standard].freeze
10
+
11
+ # Image-to-video model variants spanning two generations.
12
+ # 02 models: last-frame image, prompt optimizer, 512p/768p, 1500-char prompts.
13
+ # 2.3 models: 768p/1080p output, 5000-char prompts, no last-frame or prompt optimizer.
7
14
  IMAGE_TO_VIDEO_MODELS = %w[
8
15
  hailuo-02-image-to-video-pro
9
16
  hailuo-02-image-to-video-standard
10
17
  hailuo-2.3-image-to-video-pro
11
18
  hailuo-2.3-image-to-video-standard
12
19
  ].freeze
20
+
21
+ # Video duration options in seconds.
13
22
  DURATIONS = [6, 10].freeze
23
+
24
+ # Output resolutions for 02 generation image-to-video models.
14
25
  IMAGE_02_RESOLUTIONS = %w[512p 768p].freeze
26
+
27
+ # Output resolutions for 2.3 generation image-to-video models. 1080p is not available with 10-second duration.
15
28
  IMAGE_23_RESOLUTIONS = %w[768p 1080p].freeze
16
29
 
30
+ # A generated video file with a download URL.
17
31
  class MediaUrl < RunApi::Core::BaseModel
18
32
  optional :url, String
19
33
  end
20
34
 
35
+ # Video generation task status and results. Poll until status reaches a terminal state.
21
36
  class VideoTaskResponse < RunApi::Core::TaskResponse
22
37
  required :id, String
23
38
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
@@ -25,6 +40,7 @@ module RunApi
25
40
  optional :error, String
26
41
  end
27
42
 
43
+ # Narrowed response returned after successful completion, guaranteeing videos is present.
28
44
  class CompletedVideoTaskResponse < VideoTaskResponse
29
45
  required :videos, [-> { MediaUrl }]
30
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-hailuo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
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 hailuo ai api Ruby SDK is the language-specific package for Hailuo
27
27
  on RunAPI. Use this hailuo ai api package for text-to-video, image-to-video, video
28
28
  editing, and animation flows when your application needs JSON request bodies, task