runapi-hailuo 0.2.4 → 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 +45 -0
- data/lib/runapi/hailuo/client.rb +14 -6
- data/lib/runapi/hailuo/resources/image_to_video.rb +29 -15
- data/lib/runapi/hailuo/resources/text_to_video.rb +19 -5
- data/lib/runapi/hailuo/types.rb +21 -5
- metadata +12 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f95e54a3c54efd90d4dd44df70117de6da0b446167b2cf83c70640a1e7647a9
|
|
4
|
+
data.tar.gz: 4965df466901387f44480016ae970437fa4e90b7a81c14dcb680bac6403ede69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c22c7bdf46bcb6458b1f0753a8c542101fa05a5f56de8080fbbc8d298d4da8f985196b064fc1340d113e3cc71feb10ef868ed53a95fba158b350f6d1ee11a20f
|
|
7
|
+
data.tar.gz: 9d94362787daf471cc98de37c2292bd93fee8836504c0d4e219b1d6d5a3d8e621a3c6b0d2fb5c6b285e21dd35b36f1a9eb8be5f599e44e7e100f143979dd8c60
|
data/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Hailuo AI API Ruby SDK for RunAPI
|
|
2
|
+
|
|
3
|
+
The hailuo ai api Ruby SDK is the language-specific package for Hailuo on RunAPI. Use this hailuo ai api package for text-to-video, image-to-video, video editing, and animation flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in Ruby.
|
|
4
|
+
|
|
5
|
+
This hailuo ai api README is the Ruby package guide inside the public `hailuo-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/hailuo; for API reference, use https://runapi.ai/docs#hailuo; for SDK docs, use https://runapi.ai/docs#sdk-hailuo.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
gem install runapi-hailuo
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
require "runapi-hailuo"
|
|
17
|
+
|
|
18
|
+
client = RunApi::Hailuo::Client.new
|
|
19
|
+
task = client.text_to_video.create(
|
|
20
|
+
# Pass the Hailuo JSON request body from https://runapi.ai/docs#hailuo.
|
|
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::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.
|
|
32
|
+
|
|
33
|
+
## Links
|
|
34
|
+
|
|
35
|
+
- Model page: https://runapi.ai/models/hailuo
|
|
36
|
+
- SDK docs: https://runapi.ai/docs#sdk-hailuo
|
|
37
|
+
- Product docs: https://runapi.ai/docs#hailuo
|
|
38
|
+
- Pricing and rate limits: https://runapi.ai/models/hailuo/02-text-to-video-pro
|
|
39
|
+
- Provider comparison: https://runapi.ai/providers/minimax
|
|
40
|
+
- Full catalog: https://runapi.ai/models
|
|
41
|
+
- Repository: https://github.com/runapi-ai/hailuo-sdk
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
Licensed under the Apache License, Version 2.0.
|
data/lib/runapi/hailuo/client.rb
CHANGED
|
@@ -2,14 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Hailuo
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
|
@@ -36,35 +50,35 @@ module RunApi
|
|
|
36
50
|
model = param(params, :model)
|
|
37
51
|
raise Core::ValidationError, "model is required" unless Types::IMAGE_TO_VIDEO_MODELS.include?(model)
|
|
38
52
|
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
39
|
-
raise Core::ValidationError, "
|
|
53
|
+
raise Core::ValidationError, "first_frame_image_url is required" unless param(params, :first_frame_image_url)
|
|
40
54
|
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
duration_seconds = param(params, :duration_seconds)
|
|
56
|
+
output_resolution = param(params, :output_resolution)
|
|
43
57
|
|
|
44
|
-
if
|
|
45
|
-
raise Core::ValidationError, "
|
|
58
|
+
if duration_seconds && !Types::DURATIONS.include?(duration_seconds)
|
|
59
|
+
raise Core::ValidationError, "duration_seconds must be one of: #{Types::DURATIONS.join(", ")}"
|
|
46
60
|
end
|
|
47
61
|
|
|
48
62
|
case model
|
|
49
63
|
when "hailuo-02-image-to-video-pro"
|
|
50
|
-
raise Core::ValidationError, "
|
|
51
|
-
raise Core::ValidationError, "
|
|
64
|
+
raise Core::ValidationError, "duration_seconds is not supported for #{model}" if duration_seconds
|
|
65
|
+
raise Core::ValidationError, "output_resolution is not supported for #{model}" if output_resolution
|
|
52
66
|
when "hailuo-02-image-to-video-standard"
|
|
53
|
-
|
|
67
|
+
validate_output_resolution!(output_resolution, Types::IMAGE_02_RESOLUTIONS) if output_resolution
|
|
54
68
|
else
|
|
55
|
-
|
|
56
|
-
raise Core::ValidationError, "
|
|
69
|
+
validate_output_resolution!(output_resolution, Types::IMAGE_23_RESOLUTIONS) if output_resolution
|
|
70
|
+
raise Core::ValidationError, "last_frame_image_url is not supported for #{model}" if param(params, :last_frame_image_url)
|
|
57
71
|
raise Core::ValidationError, "prompt_optimizer is not supported for #{model}" if param(params, :prompt_optimizer)
|
|
58
|
-
if
|
|
59
|
-
raise Core::ValidationError, "
|
|
72
|
+
if duration_seconds == 10 && output_resolution.to_s == "1080p"
|
|
73
|
+
raise Core::ValidationError, "1080p does not support 10-second duration"
|
|
60
74
|
end
|
|
61
75
|
end
|
|
62
76
|
end
|
|
63
77
|
|
|
64
|
-
def
|
|
65
|
-
return if allowed.include?(
|
|
78
|
+
def validate_output_resolution!(output_resolution, allowed)
|
|
79
|
+
return if allowed.include?(output_resolution.to_s)
|
|
66
80
|
|
|
67
|
-
raise Core::ValidationError, "
|
|
81
|
+
raise Core::ValidationError, "output_resolution must be one of: #{allowed.join(", ")}"
|
|
68
82
|
end
|
|
69
83
|
end
|
|
70
84
|
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
|
|
@@ -37,14 +51,14 @@ module RunApi
|
|
|
37
51
|
raise Core::ValidationError, "model is required" unless Types::TEXT_TO_VIDEO_MODELS.include?(model)
|
|
38
52
|
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
39
53
|
|
|
40
|
-
|
|
41
|
-
return unless
|
|
54
|
+
duration_seconds = param(params, :duration_seconds)
|
|
55
|
+
return unless duration_seconds
|
|
42
56
|
|
|
43
|
-
unless Types::DURATIONS.include?(
|
|
44
|
-
raise Core::ValidationError, "
|
|
57
|
+
unless Types::DURATIONS.include?(duration_seconds)
|
|
58
|
+
raise Core::ValidationError, "duration_seconds must be one of: #{Types::DURATIONS.join(", ")}"
|
|
45
59
|
end
|
|
46
60
|
if model == "hailuo-02-text-to-video-pro"
|
|
47
|
-
raise Core::ValidationError, "
|
|
61
|
+
raise Core::ValidationError, "duration_seconds is not supported for #{model}"
|
|
48
62
|
end
|
|
49
63
|
end
|
|
50
64
|
end
|
data/lib/runapi/hailuo/types.rb
CHANGED
|
@@ -2,31 +2,47 @@
|
|
|
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
|
|
13
|
-
DURATIONS = %w[6 10].freeze
|
|
14
|
-
IMAGE_02_RESOLUTIONS = %w[512P 768P].freeze
|
|
15
|
-
IMAGE_23_RESOLUTIONS = %w[768P 1080P].freeze
|
|
16
20
|
|
|
21
|
+
# Video duration options in seconds.
|
|
22
|
+
DURATIONS = [6, 10].freeze
|
|
23
|
+
|
|
24
|
+
# Output resolutions for 02 generation image-to-video models.
|
|
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.
|
|
28
|
+
IMAGE_23_RESOLUTIONS = %w[768p 1080p].freeze
|
|
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 }
|
|
24
|
-
optional :videos, [
|
|
39
|
+
optional :videos, [-> { MediaUrl }]
|
|
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
|
-
required :videos, [
|
|
45
|
+
required :videos, [-> { MediaUrl }]
|
|
30
46
|
end
|
|
31
47
|
end
|
|
32
48
|
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.
|
|
4
|
+
version: 0.2.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- RunAPI
|
|
@@ -15,22 +15,27 @@ 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 hailuo ai api Ruby SDK is the language-specific package for Hailuo
|
|
27
|
+
on RunAPI. Use this hailuo ai api package for text-to-video, image-to-video, video
|
|
28
|
+
editing, and animation flows when your application needs JSON request bodies, task
|
|
29
|
+
status 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-hailuo.rb
|
|
35
40
|
- lib/runapi/hailuo.rb
|
|
36
41
|
- lib/runapi/hailuo/client.rb
|
|
@@ -42,7 +47,7 @@ licenses:
|
|
|
42
47
|
- Apache-2.0
|
|
43
48
|
metadata:
|
|
44
49
|
homepage_uri: https://runapi.ai/models/hailuo
|
|
45
|
-
documentation_uri: https://github.com/runapi-ai/hailuo-sdk/blob/main/README.md
|
|
50
|
+
documentation_uri: https://github.com/runapi-ai/hailuo-sdk/blob/main/ruby/README.md
|
|
46
51
|
source_code_uri: https://github.com/runapi-ai/hailuo-sdk
|
|
47
52
|
changelog_uri: https://github.com/runapi-ai/hailuo-sdk/blob/main/CHANGELOG.md
|
|
48
53
|
rdoc_options: []
|
|
@@ -61,5 +66,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
61
66
|
requirements: []
|
|
62
67
|
rubygems_version: 4.0.10
|
|
63
68
|
specification_version: 4
|
|
64
|
-
summary: Hailuo API
|
|
69
|
+
summary: Hailuo AI API Ruby SDK for RunAPI
|
|
65
70
|
test_files: []
|