runapi-hailuo 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: 9f95e54a3c54efd90d4dd44df70117de6da0b446167b2cf83c70640a1e7647a9
4
- data.tar.gz: 4965df466901387f44480016ae970437fa4e90b7a81c14dcb680bac6403ede69
3
+ metadata.gz: 50152f6fb9b5ca8acd27bf0fcd7054b1a72974fa2211362e24a74cf59d871106
4
+ data.tar.gz: cee31f624d2d980f71d7e3a6b1bbcca4f6e3c5c33e02605a9432317d2e2a70e8
5
5
  SHA512:
6
- metadata.gz: c22c7bdf46bcb6458b1f0753a8c542101fa05a5f56de8080fbbc8d298d4da8f985196b064fc1340d113e3cc71feb10ef868ed53a95fba158b350f6d1ee11a20f
7
- data.tar.gz: 9d94362787daf471cc98de37c2292bd93fee8836504c0d4e219b1d6d5a3d8e621a3c6b0d2fb5c6b285e21dd35b36f1a9eb8be5f599e44e7e100f143979dd8c60
6
+ metadata.gz: 34ca581e88fd2d260db1fe43e0149c90d53c7f33c9fe53e59b58908a2bf7166f98c2e0e6635fa641c7ebd05b22a216d824a9690a921146a3ba9956e8946e0fd9
7
+ data.tar.gz: 7f0ba801df266b32043dae6f43d2dfa7180c18807f03037c91ea65a9f49e731c1d718ce17269611e4c906c5c3e944af0507c311279a0e086e126cbb1aa1f7844
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Hailuo AI API Ruby SDK for RunAPI
1
+ # Hailuo API Ruby SDK for RunAPI
2
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.
3
+ The Hailuo Ruby SDK is the language-specific package for Hailuo on RunAPI. Use this package for video generation, animation, and video editing workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Ruby.
4
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.
5
+ This 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
6
 
7
7
  ## Install
8
8
 
@@ -28,7 +28,7 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
28
28
 
29
29
  ## Language notes
30
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.
31
+ Use Ruby keyword arguments and the `RunApi::Hailuo` error classes when building video jobs, Rails workers, or scripts. The available resources are `text_to_video` and `image_to_video`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
32
32
 
33
33
  ## Links
34
34
 
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module Hailuo
5
+ CONTRACT = {
6
+ "image-to-video" => {
7
+ "models" => ["hailuo-02-image-to-video-pro", "hailuo-02-image-to-video-standard", "hailuo-2.3-image-to-video-pro", "hailuo-2.3-image-to-video-standard"],
8
+ "fields_by_model" => {
9
+ "hailuo-02-image-to-video-pro" => {
10
+ "duration_seconds" => {
11
+ "type" => "integer"
12
+ },
13
+ "first_frame_image_url" => {
14
+ "required" => true
15
+ }
16
+ },
17
+ "hailuo-02-image-to-video-standard" => {
18
+ "duration_seconds" => {
19
+ "enum" => [6, 10],
20
+ "type" => "integer"
21
+ },
22
+ "first_frame_image_url" => {
23
+ "required" => true
24
+ },
25
+ "output_resolution" => {
26
+ "enum" => ["512p", "768p"]
27
+ }
28
+ },
29
+ "hailuo-2.3-image-to-video-pro" => {
30
+ "duration_seconds" => {
31
+ "enum" => [6, 10],
32
+ "type" => "integer"
33
+ },
34
+ "first_frame_image_url" => {
35
+ "required" => true
36
+ },
37
+ "output_resolution" => {
38
+ "enum" => ["768p", "1080p"]
39
+ }
40
+ },
41
+ "hailuo-2.3-image-to-video-standard" => {
42
+ "duration_seconds" => {
43
+ "enum" => [6, 10],
44
+ "type" => "integer"
45
+ },
46
+ "first_frame_image_url" => {
47
+ "required" => true
48
+ },
49
+ "output_resolution" => {
50
+ "enum" => ["768p", "1080p"]
51
+ }
52
+ }
53
+ }
54
+ },
55
+ "text-to-video" => {
56
+ "models" => ["hailuo-02-text-to-video-pro", "hailuo-02-text-to-video-standard"],
57
+ "fields_by_model" => {
58
+ "hailuo-02-text-to-video-pro" => {
59
+ "duration_seconds" => {
60
+ "type" => "integer"
61
+ }
62
+ },
63
+ "hailuo-02-text-to-video-standard" => {
64
+ "duration_seconds" => {
65
+ "enum" => [6, 10],
66
+ "type" => "integer"
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }.freeze
72
+ end
73
+ end
@@ -47,26 +47,19 @@ module RunApi
47
47
  private
48
48
 
49
49
  def validate_params!(params)
50
- model = param(params, :model)
51
- raise Core::ValidationError, "model is required" unless Types::IMAGE_TO_VIDEO_MODELS.include?(model)
50
+ validate_contract!(CONTRACT["image-to-video"], params)
51
+
52
52
  raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
53
- raise Core::ValidationError, "first_frame_image_url is required" unless param(params, :first_frame_image_url)
54
53
 
54
+ model = param(params, :model)
55
55
  duration_seconds = param(params, :duration_seconds)
56
56
  output_resolution = param(params, :output_resolution)
57
57
 
58
- if duration_seconds && !Types::DURATIONS.include?(duration_seconds)
59
- raise Core::ValidationError, "duration_seconds must be one of: #{Types::DURATIONS.join(", ")}"
60
- end
61
-
62
58
  case model
63
59
  when "hailuo-02-image-to-video-pro"
64
60
  raise Core::ValidationError, "duration_seconds is not supported for #{model}" if duration_seconds
65
61
  raise Core::ValidationError, "output_resolution is not supported for #{model}" if output_resolution
66
- when "hailuo-02-image-to-video-standard"
67
- validate_output_resolution!(output_resolution, Types::IMAGE_02_RESOLUTIONS) if output_resolution
68
- else
69
- validate_output_resolution!(output_resolution, Types::IMAGE_23_RESOLUTIONS) if output_resolution
62
+ when "hailuo-2.3-image-to-video-pro", "hailuo-2.3-image-to-video-standard"
70
63
  raise Core::ValidationError, "last_frame_image_url is not supported for #{model}" if param(params, :last_frame_image_url)
71
64
  raise Core::ValidationError, "prompt_optimizer is not supported for #{model}" if param(params, :prompt_optimizer)
72
65
  if duration_seconds == 10 && output_resolution.to_s == "1080p"
@@ -74,12 +67,6 @@ module RunApi
74
67
  end
75
68
  end
76
69
  end
77
-
78
- def validate_output_resolution!(output_resolution, allowed)
79
- return if allowed.include?(output_resolution.to_s)
80
-
81
- raise Core::ValidationError, "output_resolution must be one of: #{allowed.join(", ")}"
82
- end
83
70
  end
84
71
  end
85
72
  end
@@ -47,17 +47,12 @@ module RunApi
47
47
  private
48
48
 
49
49
  def validate_params!(params)
50
- model = param(params, :model)
51
- raise Core::ValidationError, "model is required" unless Types::TEXT_TO_VIDEO_MODELS.include?(model)
52
- raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
50
+ validate_contract!(CONTRACT["text-to-video"], params)
53
51
 
54
- duration_seconds = param(params, :duration_seconds)
55
- return unless duration_seconds
52
+ raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
56
53
 
57
- unless Types::DURATIONS.include?(duration_seconds)
58
- raise Core::ValidationError, "duration_seconds must be one of: #{Types::DURATIONS.join(", ")}"
59
- end
60
- if model == "hailuo-02-text-to-video-pro"
54
+ model = param(params, :model)
55
+ if model == "hailuo-02-text-to-video-pro" && param(params, :duration_seconds)
61
56
  raise Core::ValidationError, "duration_seconds is not supported for #{model}"
62
57
  end
63
58
  end
@@ -4,29 +4,6 @@ module RunApi
4
4
  module Hailuo
5
5
  # Type definitions and constants for Hailuo video generation.
6
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.
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.
14
- IMAGE_TO_VIDEO_MODELS = %w[
15
- hailuo-02-image-to-video-pro
16
- hailuo-02-image-to-video-standard
17
- hailuo-2.3-image-to-video-pro
18
- hailuo-2.3-image-to-video-standard
19
- ].freeze
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
7
  # A generated video file with a download URL.
31
8
  class MediaUrl < RunApi::Core::BaseModel
32
9
  optional :url, String
data/lib/runapi/hailuo.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "hailuo/types"
5
+ require_relative "hailuo/contract_gen"
5
6
  require_relative "hailuo/resources/text_to_video"
6
7
  require_relative "hailuo/resources/image_to_video"
7
8
  require_relative "hailuo/client"
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.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,18 +15,18 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.6
18
+ version: 0.2.7
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.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.
25
+ version: 0.2.7
26
+ description: The Hailuo Ruby SDK is the language-specific package for Hailuo on RunAPI.
27
+ Use this package for video generation, animation, and video editing workflows when
28
+ your application needs request bodies, task status lookup, and consistent RunAPI
29
+ errors in Ruby.
30
30
  email:
31
31
  - contact@runapi.ai
32
32
  executables: []
@@ -39,6 +39,7 @@ files:
39
39
  - lib/runapi-hailuo.rb
40
40
  - lib/runapi/hailuo.rb
41
41
  - lib/runapi/hailuo/client.rb
42
+ - lib/runapi/hailuo/contract_gen.rb
42
43
  - lib/runapi/hailuo/resources/image_to_video.rb
43
44
  - lib/runapi/hailuo/resources/text_to_video.rb
44
45
  - lib/runapi/hailuo/types.rb
@@ -46,9 +47,11 @@ homepage: https://runapi.ai/models/hailuo
46
47
  licenses:
47
48
  - Apache-2.0
48
49
  metadata:
50
+ runapi_slug: hailuo
49
51
  homepage_uri: https://runapi.ai/models/hailuo
50
52
  documentation_uri: https://github.com/runapi-ai/hailuo-sdk/blob/main/ruby/README.md
51
53
  source_code_uri: https://github.com/runapi-ai/hailuo-sdk
54
+ bug_tracker_uri: https://github.com/runapi-ai/hailuo-sdk/issues
52
55
  changelog_uri: https://github.com/runapi-ai/hailuo-sdk/blob/main/CHANGELOG.md
53
56
  rdoc_options: []
54
57
  require_paths:
@@ -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: Hailuo AI API Ruby SDK for RunAPI
72
+ summary: Hailuo API Ruby SDK for RunAPI
70
73
  test_files: []