runapi-seedance 0.2.7 → 0.2.8

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: 4a4129f28a6815e05d711bf3c21304a59cc6f9d5250ba3c4efec1126a72227b5
4
- data.tar.gz: 997e90de2aa928d79bbfe267a05d267d842137056f5beb470b1d2646254bec70
3
+ metadata.gz: 7e72a064a5fb6661041862b4e66aa714e384ec015a136f91ec6619b8ff4dbca2
4
+ data.tar.gz: '0080e2a4576940e9d58314f6aad79773443c444a0b10333cb2c4cdc346cafdf8'
5
5
  SHA512:
6
- metadata.gz: e2b7f49b273915dabdca3e14b02eac8ae58733f5f4cea8c53a2b6b2ce5dcbc58a3c3e961304eadbfb32dbe1d5358585c399ef0b029a1b47c062a35a7f06485e0
7
- data.tar.gz: b7c7f737b22359c3808c02bda601abcb2c7bc7155acf05b769813ba281d26dd242f3428ddc6a228b5983358c9bc0e2b26168328f5d1de8af414512ff64f636e3
6
+ metadata.gz: 684eb54c618b6895b89cd55adf3a877664d3f82460207ed62bf5cbb87f3e2dc97df11c5fb5c399a5bd5fcc87f4fb87d081b683bf94c412b3a0a1d61968d18528
7
+ data.tar.gz: 6f419078f87ebf32b01f335fe1059da64c214f6d8505bf6e7ec8f74a8d53cef1b9a421c31b9df956ab53cb99d5a91a189a6bad23fd8a6247c0c81e9e4bd63394
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Seedance API Ruby SDK for RunAPI
1
+ # Seedance Ruby SDK for RunAPI
2
2
 
3
- The seedance api Ruby SDK is the language-specific package for Seedance on RunAPI. Use this seedance 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 Seedance Ruby SDK is the language-specific package for Seedance 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 seedance api README is the Ruby package guide inside the public `seedance-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/seedance; for API reference, use https://runapi.ai/docs#seedance; for SDK docs, use https://runapi.ai/docs#sdk-seedance.
5
+ This README is the Ruby package guide inside the public `seedance-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/seedance; for API reference, use https://runapi.ai/docs#seedance; for SDK docs, use https://runapi.ai/docs#sdk-seedance.
6
6
 
7
7
  ## Install
8
8
 
@@ -13,13 +13,13 @@ gem install runapi-seedance
13
13
  ## Quick start
14
14
 
15
15
  ```ruby
16
- require "runapi-seedance"
16
+ require "runapi/seedance"
17
17
 
18
18
  client = RunApi::Seedance::Client.new
19
- task = client.generations.create(
19
+ task = client.text_to_video.create(
20
20
  # Pass the Seedance JSON request body from https://runapi.ai/docs#seedance.
21
21
  )
22
- status = client.generations.get(task.id)
22
+ status = client.text_to_video.get(task.id)
23
23
  ```
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.
@@ -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::Seedance` error classes when building video jobs, Rails workers, or scripts. The available resources include generations. 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::Seedance` error classes when building video jobs, Rails workers, or scripts. The available resources are `text_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,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module Seedance
5
+ CONTRACT = {
6
+ "text-to-video" => {
7
+ "models" => ["seedance-1.5-pro", "seedance-2-mini", "seedance-2.0", "seedance-2.0-fast", "seedance-v1-lite", "seedance-v1-pro", "seedance-v1-pro-fast"],
8
+ "fields_by_model" => {
9
+ "seedance-1.5-pro" => {
10
+ "aspect_ratio" => {
11
+ "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "21:9"]
12
+ },
13
+ "duration_seconds" => {
14
+ "required" => true,
15
+ "min" => 4,
16
+ "max" => 12,
17
+ "type" => "integer"
18
+ },
19
+ "output_resolution" => {
20
+ "enum" => ["480p", "720p", "1080p"]
21
+ }
22
+ },
23
+ "seedance-2-mini" => {
24
+ "aspect_ratio" => {
25
+ "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "21:9", "auto"]
26
+ },
27
+ "duration_seconds" => {
28
+ "min" => 4,
29
+ "max" => 15,
30
+ "type" => "integer"
31
+ },
32
+ "output_resolution" => {
33
+ "enum" => ["480p", "720p"]
34
+ }
35
+ },
36
+ "seedance-2.0" => {
37
+ "aspect_ratio" => {
38
+ "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "21:9", "auto"]
39
+ },
40
+ "duration_seconds" => {
41
+ "min" => 4,
42
+ "max" => 15,
43
+ "type" => "integer"
44
+ },
45
+ "output_resolution" => {
46
+ "enum" => ["480p", "720p", "1080p"]
47
+ }
48
+ },
49
+ "seedance-2.0-fast" => {
50
+ "aspect_ratio" => {
51
+ "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "21:9", "auto"]
52
+ },
53
+ "duration_seconds" => {
54
+ "min" => 4,
55
+ "max" => 15,
56
+ "type" => "integer"
57
+ },
58
+ "output_resolution" => {
59
+ "enum" => ["480p", "720p"]
60
+ }
61
+ },
62
+ "seedance-v1-lite" => {
63
+ "aspect_ratio" => {
64
+ "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "9:21"]
65
+ },
66
+ "duration_seconds" => {
67
+ "enum" => [5, 10],
68
+ "required" => true,
69
+ "type" => "integer"
70
+ },
71
+ "output_resolution" => {
72
+ "enum" => ["480p", "720p", "1080p"]
73
+ },
74
+ "seed" => {
75
+ "type" => "integer"
76
+ }
77
+ },
78
+ "seedance-v1-pro" => {
79
+ "aspect_ratio" => {
80
+ "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "21:9"]
81
+ },
82
+ "duration_seconds" => {
83
+ "enum" => [5, 10],
84
+ "required" => true,
85
+ "type" => "integer"
86
+ },
87
+ "output_resolution" => {
88
+ "enum" => ["480p", "720p", "1080p"]
89
+ },
90
+ "seed" => {
91
+ "type" => "integer"
92
+ }
93
+ },
94
+ "seedance-v1-pro-fast" => {
95
+ "duration_seconds" => {
96
+ "enum" => [5, 10],
97
+ "required" => true,
98
+ "type" => "integer"
99
+ },
100
+ "first_frame_image_url" => {
101
+ "required" => true
102
+ },
103
+ "output_resolution" => {
104
+ "enum" => ["720p", "1080p"]
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }.freeze
110
+ end
111
+ end
@@ -21,41 +21,38 @@ module RunApi
21
21
  #
22
22
  # @param params [Hash] generation parameters
23
23
  # @return [RunApi::Seedance::Types::CompletedTextToVideoResponse] completed generation with videos
24
- def run(**params)
25
- task = create(**params)
26
- poll_until_complete { get(task.id) }
24
+ def run(options: nil, **params)
25
+ task = create(options: options, **params)
26
+ poll_until_complete { get(task.id, options: options) }
27
27
  end
28
28
 
29
29
  # Create a video generation task.
30
30
  #
31
31
  # @param params [Hash] generation parameters
32
32
  # @return [RunApi::Seedance::Types::TextToVideoResponse] task creation result with id
33
- def create(**params)
33
+ def create(options: nil, **params)
34
34
  params = compact_params(params)
35
35
  validate_params!(params)
36
- request(:post, ENDPOINT, body: params)
36
+ request(:post, ENDPOINT, body: params, options: options)
37
37
  end
38
38
 
39
39
  # Get generation status by task ID.
40
40
  #
41
41
  # @param id [String] task ID
42
42
  # @return [RunApi::Seedance::Types::TextToVideoResponse] current generation status
43
- def get(id)
44
- request(:get, "#{ENDPOINT}/#{id}")
43
+ def get(id, options: nil)
44
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
45
45
  end
46
46
 
47
47
  private
48
48
 
49
49
  def validate_params!(params)
50
- model = param(params, :model)
51
- raise Core::ValidationError, "model is required" unless model
52
- unless Types::MODELS.include?(model)
53
- raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::MODELS.join(", ")}"
54
- end
55
-
56
50
  prompt = param(params, :prompt)
57
51
  raise Core::ValidationError, "prompt is required" unless prompt
58
52
 
53
+ validate_contract!(CONTRACT["text-to-video"], params)
54
+
55
+ model = param(params, :model)
59
56
  max_prompt = case model
60
57
  when "seedance-1.5-pro" then Types::PROMPT_MAX_LENGTH_1_5
61
58
  when *Types::V1_MODELS then Types::PROMPT_MAX_LENGTH_V1
@@ -76,10 +73,6 @@ module RunApi
76
73
  model = param(params, :model)
77
74
  has_image = field_present?(params, :first_frame_image_url)
78
75
 
79
- if model == "seedance-v1-pro-fast" && !has_image
80
- raise Core::ValidationError, "seedance-v1-pro-fast requires first_frame_image_url"
81
- end
82
-
83
76
  if has_image && field_present?(params, :aspect_ratio)
84
77
  raise Core::ValidationError, "aspect_ratio is not accepted in image-to-video mode; it is derived from the image"
85
78
  end
@@ -93,20 +86,6 @@ module RunApi
93
86
 
94
87
  reject_unsupported!(params, %i[lock_camera seed], model) if model == "seedance-v1-pro-fast"
95
88
 
96
- duration_seconds = param(params, :duration_seconds)
97
- raise Core::ValidationError, "duration_seconds is required for Seedance V1; must be one of: #{Types::DURATIONS_V1.join(", ")}" unless duration_seconds
98
- unless Types::DURATIONS_V1.include?(duration_seconds)
99
- raise Core::ValidationError, "Invalid duration_seconds for #{model}: #{duration_seconds}. Must be one of: #{Types::DURATIONS_V1.join(", ")}"
100
- end
101
-
102
- unless has_image
103
- aspect_ratios = (model == "seedance-v1-lite") ? Types::ASPECT_RATIOS_V1_LITE : Types::ASPECT_RATIOS_V1_PRO
104
- validate_optional!(params, :aspect_ratio, aspect_ratios)
105
- end
106
-
107
- resolutions = (model == "seedance-v1-pro-fast") ? Types::RESOLUTIONS_V1_PRO_FAST : Types::RESOLUTIONS_V1
108
- validate_optional!(params, :output_resolution, resolutions)
109
-
110
89
  seed = param(params, :seed)
111
90
  if seed
112
91
  unless seed.is_a?(Integer) && Types::SEED_RANGE.cover?(seed)
@@ -116,18 +95,6 @@ module RunApi
116
95
  end
117
96
 
118
97
  def validate_1_5_pro!(params)
119
- validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS_1_5)
120
- validate_optional!(params, :output_resolution, Types::RESOLUTIONS_1_5)
121
-
122
- duration_seconds = param(params, :duration_seconds)
123
- unless duration_seconds
124
- raise Core::ValidationError, "duration_seconds is required for seedance-1.5-pro; must be one of: #{Types::DURATIONS_1_5.join(", ")}"
125
- end
126
-
127
- if !Types::DURATIONS_1_5.include?(duration_seconds)
128
- raise Core::ValidationError, "Invalid duration_seconds for seedance-1.5-pro: #{duration_seconds}. Must be one of: #{Types::DURATIONS_1_5.join(", ")}"
129
- end
130
-
131
98
  if (value = param(params, :source_image_urls)).is_a?(Array) && value.size > 2
132
99
  raise Core::ValidationError, "source_image_urls accepts at most 2 images for seedance-1.5-pro"
133
100
  end
@@ -137,18 +104,6 @@ module RunApi
137
104
  end
138
105
 
139
106
  def validate_2!(params)
140
- validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS_2)
141
- resolutions = (param(params, :model) == "seedance-2.0") ? Types::RESOLUTIONS_SEEDANCE_2 : Types::RESOLUTIONS_SEEDANCE_2_FAST
142
- validate_optional!(params, :output_resolution, resolutions)
143
-
144
- duration_seconds = param(params, :duration_seconds)
145
- if duration_seconds
146
- dur_int = duration_seconds.to_i
147
- unless Types::DURATION_2_RANGE.cover?(dur_int)
148
- raise Core::ValidationError, "Invalid duration_seconds for seedance-2.0: #{duration_seconds}. Must be an integer between 4 and 15"
149
- end
150
- end
151
-
152
107
  unsupported = %i[source_image_urls lock_camera]
153
108
  reject_unsupported!(params, unsupported, param(params, :model))
154
109
 
@@ -171,15 +126,6 @@ module RunApi
171
126
  end
172
127
  end
173
128
  end
174
-
175
- def field_present?(params, key)
176
- value = param(params, key)
177
- return false if value.nil?
178
- return value.any? if value.is_a?(Array)
179
- return !value.empty? if value.respond_to?(:empty?)
180
-
181
- true
182
- end
183
129
  end
184
130
  end
185
131
  end
@@ -4,41 +4,13 @@ module RunApi
4
4
  module Seedance
5
5
  # Type definitions and constants for Seedance video generation.
6
6
  #
7
- # Constants are grouped by model generation: 1.5, 2.0/2.0-fast, and V1.
8
- # Each generation has its own aspect ratio, resolution, and duration
9
- # constraints reflecting different rendering capabilities.
7
+ # Per-model enum, range, and required constraints live in the generated
8
+ # contract; the constants here back the bespoke checks the contract cannot
9
+ # express (per-model prompt length and seed range).
10
10
  module Types
11
11
  # V1-generation model identifiers: lite (low-cost), pro (high-quality), and pro-fast (speed-optimized).
12
12
  V1_MODELS = %w[seedance-v1-lite seedance-v1-pro seedance-v1-pro-fast].freeze
13
- # All supported model variants spanning 1.5, 2.0, and V1 generations.
14
- MODELS = (%w[seedance-1.5-pro seedance-2.0 seedance-2.0-fast] + V1_MODELS).freeze
15
13
 
16
- # Aspect ratios for seedance-1.5-pro; required with every request.
17
- ASPECT_RATIOS_1_5 = %w[1:1 4:3 3:4 16:9 9:16 21:9].freeze
18
- # Aspect ratios for 2.0/2.0-fast; includes "auto" for automatic selection.
19
- ASPECT_RATIOS_2 = [*ASPECT_RATIOS_1_5, "auto"].freeze
20
- # Aspect ratios for seedance-v1-lite; uses 9:21 (not 21:9) for tall portrait.
21
- ASPECT_RATIOS_V1_LITE = %w[1:1 4:3 3:4 16:9 9:16 9:21].freeze
22
- # Aspect ratios for seedance-v1-pro and seedance-v1-pro-fast.
23
- ASPECT_RATIOS_V1_PRO = %w[1:1 4:3 3:4 16:9 9:16 21:9].freeze
24
-
25
- # Output resolutions for seedance-1.5-pro.
26
- RESOLUTIONS_1_5 = %w[480p 720p 1080p].freeze
27
- # Output resolutions for seedance-2.0.
28
- RESOLUTIONS_SEEDANCE_2 = %w[480p 720p 1080p].freeze
29
- # Output resolutions for seedance-2.0-fast; capped at 720p for faster rendering.
30
- RESOLUTIONS_SEEDANCE_2_FAST = %w[480p 720p].freeze
31
- # Output resolutions for seedance-v1-lite and seedance-v1-pro.
32
- RESOLUTIONS_V1 = %w[480p 720p 1080p].freeze
33
- # Output resolutions for seedance-v1-pro-fast; minimum 720p.
34
- RESOLUTIONS_V1_PRO_FAST = %w[720p 1080p].freeze
35
-
36
- # Allowed duration values (seconds) for seedance-1.5-pro; discrete choices only.
37
- DURATIONS_1_5 = [4, 8, 12].freeze
38
- # Continuous duration range (seconds) for 2.0/2.0-fast; any integer 4-15 is accepted.
39
- DURATION_2_RANGE = (4..15)
40
- # Allowed duration values (seconds) for V1 models; 5 or 10.
41
- DURATIONS_V1 = [5, 10].freeze
42
14
  # Valid seed range; -1 requests a random seed.
43
15
  SEED_RANGE = (-1..2_147_483_647)
44
16
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "seedance/types"
5
+ require_relative "seedance/contract_gen"
5
6
  require_relative "seedance/resources/text_to_video"
6
7
  require_relative "seedance/client"
7
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-seedance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
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.9
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 seedance api Ruby SDK is the language-specific package for Seedance
27
- on RunAPI. Use this seedance 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.9
26
+ description: The Seedance Ruby SDK is the language-specific package for Seedance on
27
+ RunAPI. Use this package for video generation, animation, and video editing workflows
28
+ when 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,15 +39,18 @@ files:
39
39
  - lib/runapi-seedance.rb
40
40
  - lib/runapi/seedance.rb
41
41
  - lib/runapi/seedance/client.rb
42
+ - lib/runapi/seedance/contract_gen.rb
42
43
  - lib/runapi/seedance/resources/text_to_video.rb
43
44
  - lib/runapi/seedance/types.rb
44
45
  homepage: https://runapi.ai/models/seedance
45
46
  licenses:
46
47
  - Apache-2.0
47
48
  metadata:
49
+ runapi_slug: seedance
48
50
  homepage_uri: https://runapi.ai/models/seedance
49
51
  documentation_uri: https://github.com/runapi-ai/seedance-sdk/blob/main/ruby/README.md
50
52
  source_code_uri: https://github.com/runapi-ai/seedance-sdk
53
+ bug_tracker_uri: https://github.com/runapi-ai/seedance-sdk/issues
51
54
  changelog_uri: https://github.com/runapi-ai/seedance-sdk/blob/main/CHANGELOG.md
52
55
  rdoc_options: []
53
56
  require_paths:
@@ -65,5 +68,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
68
  requirements: []
66
69
  rubygems_version: 4.0.10
67
70
  specification_version: 4
68
- summary: Seedance API Ruby SDK for RunAPI
71
+ summary: Seedance Ruby SDK for RunAPI
69
72
  test_files: []