runapi-seedance 0.3.1 → 0.4.0

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: 9ff9ca5e55ad5d9c75fdf7b3a7944ad99f6e17c48b8554b50c15b7dd99c827b9
4
- data.tar.gz: 2fa5de60a405c6fa374ec5dfdd891feb6dd3b600dde47c9f57bd0ba2a6902835
3
+ metadata.gz: 5d05f8ae32cf037aee0d2587419c395e93cff87af78817070f5619fd0004da1e
4
+ data.tar.gz: c8e9303f942d84b45c0c667d110de091cdcd0e1bcca9ebadfc4d7bef93b97e32
5
5
  SHA512:
6
- metadata.gz: 8a4faa8ff85f4d54eb5ef64216ac4e89bec1c904236b2d977fac2d97ae9c13b5d03f2ff679b9d6158446fe761e84736937ea55a2e26163442e77d85e6395c5bb
7
- data.tar.gz: 07bb580abc187aa7bee55f704cdd33d1ed410654051b641054ebdd1389839e9e76761fc31d2e33ca3f61ad010ca59a09cffc774324bd45d121bc5e09d551cd28
6
+ metadata.gz: 7d726433aa609f57fe962ec7fa1e5ce16f5d909ced3b7c24b2ba30877d323dc525d61cec01bfec388d9b800566aba5f45344b4ae2c74b37d2fa338502b1290c0
7
+ data.tar.gz: 899ae3d232a1a295fd71fa607c4358136fe9ee430fe4a61d108b5e36a281dc3273f89708c2e55b0678f1b12dc0052d2ae1edb6ce3847f9f8e7eb2cbcef9bfeca
@@ -32,7 +32,6 @@ module RunApi
32
32
  # @return [RunApi::Seedance::Types::TextToVideoResponse] task creation result with id
33
33
  def create(options: nil, **params)
34
34
  params = compact_params(params)
35
- validate_params!(params)
36
35
  request(:post, ENDPOINT, body: params, options: options)
37
36
  end
38
37
 
@@ -43,99 +42,6 @@ module RunApi
43
42
  def get(id, options: nil)
44
43
  request(:get, "#{ENDPOINT}/#{id}", options: options)
45
44
  end
46
-
47
- private
48
-
49
- def validate_params!(params)
50
- prompt = param(params, :prompt)
51
- raise Core::ValidationError, "prompt is required" unless prompt
52
-
53
- validate_contract!(CONTRACT["text-to-video"], params)
54
-
55
- model = param(params, :model)
56
- unless model == "seedance-2.5"
57
- max_prompt = case model
58
- when "seedance-1.5-pro" then Types::PROMPT_MAX_LENGTH_1_5
59
- when *Types::V1_MODELS then Types::PROMPT_MAX_LENGTH_V1
60
- else Types::PROMPT_MAX_LENGTH_2
61
- end
62
- unless prompt.length.between?(Types::PROMPT_MIN_LENGTH, max_prompt)
63
- raise Core::ValidationError, "prompt length must be between #{Types::PROMPT_MIN_LENGTH} and #{max_prompt} characters"
64
- end
65
- end
66
-
67
- case model
68
- when "seedance-1.5-pro" then validate_1_5_pro!(params)
69
- when *Types::V1_MODELS then validate_v1!(params)
70
- else validate_2!(params)
71
- end
72
- end
73
-
74
- def validate_v1!(params)
75
- model = param(params, :model)
76
- has_image = field_present?(params, :first_frame_image_url)
77
-
78
- if has_image && field_present?(params, :aspect_ratio)
79
- raise Core::ValidationError, "aspect_ratio is not accepted in image-to-video mode; it is derived from the image"
80
- end
81
-
82
- if field_present?(params, :last_frame_image_url)
83
- raise Core::ValidationError, "last_frame_image_url is not supported by #{model}"
84
- end
85
-
86
- unsupported = %i[source_image_urls reference_image_urls reference_video_urls reference_audio_urls web_search generate_audio]
87
- reject_unsupported!(params, unsupported, model)
88
-
89
- reject_unsupported!(params, %i[lock_camera], model) if model == "seedance-v1-pro-fast"
90
-
91
- seed = param(params, :seed)
92
- if seed
93
- unless seed.is_a?(Integer) && Types::SEED_RANGE.cover?(seed)
94
- raise Core::ValidationError, "seed must be an integer between #{Types::SEED_RANGE.first} and #{Types::SEED_RANGE.last}"
95
- end
96
- end
97
- end
98
-
99
- def validate_1_5_pro!(params)
100
- unsupported = %i[first_frame_image_url last_frame_image_url reference_image_urls reference_video_urls reference_audio_urls web_search]
101
- reject_unsupported!(params, unsupported, "seedance-1.5-pro")
102
- end
103
-
104
- def validate_2!(params)
105
- unsupported = %i[source_image_urls lock_camera]
106
- reject_unsupported!(params, unsupported, param(params, :model))
107
-
108
- validate_mode_conflicts!(params)
109
- validate_seedance_2_4k_mode!(params)
110
- end
111
-
112
- def validate_mode_conflicts!(params)
113
- has_frame = Types::FRAME_FIELDS.any? { |f| field_present?(params, f) }
114
- has_reference = Types::REFERENCE_FIELDS.any? { |f| field_present?(params, f) }
115
-
116
- if has_frame && has_reference
117
- raise Core::ValidationError, "Cannot use frame mode and reference mode at the same time"
118
- end
119
- end
120
-
121
- def validate_seedance_2_4k_mode!(params)
122
- return unless param(params, :model) == "seedance-2.0"
123
- return unless param(params, :output_resolution) == "4k"
124
-
125
- unsupported = Types::FRAME_FIELDS + Types::REFERENCE_FIELDS
126
- field = unsupported.find { |candidate| field_present?(params, candidate) }
127
- return unless field
128
-
129
- raise Core::ValidationError, "#{field} is not allowed when model is seedance-2.0 and output_resolution is 4k"
130
- end
131
-
132
- def reject_unsupported!(params, fields, model)
133
- fields.each do |field|
134
- if field_present?(params, field)
135
- raise Core::ValidationError, "#{field} is not supported for #{model}"
136
- end
137
- end
138
- end
139
45
  end
140
46
  end
141
47
  end
@@ -2,32 +2,8 @@
2
2
 
3
3
  module RunApi
4
4
  module Seedance
5
- # Type definitions and constants for Seedance video generation.
6
- #
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).
5
+ # Type definitions for Seedance video generation.
10
6
  module Types
11
- # V1-generation model identifiers: pro (high-quality) and pro-fast (speed-optimized).
12
- V1_MODELS = %w[seedance-v1-pro seedance-v1-pro-fast].freeze
13
-
14
- # Valid seed range; -1 requests a random seed.
15
- SEED_RANGE = (-1..2_147_483_647)
16
-
17
- # Minimum prompt length in characters, enforced across all models.
18
- PROMPT_MIN_LENGTH = 3
19
- # Maximum prompt length for seedance-1.5-pro.
20
- PROMPT_MAX_LENGTH_1_5 = 2500
21
- # Maximum prompt length for 2.0/2.0-fast (up to 20 000 characters).
22
- PROMPT_MAX_LENGTH_2 = 20000
23
- # Maximum prompt length for V1 models (up to 10 000 characters).
24
- PROMPT_MAX_LENGTH_V1 = 10000
25
-
26
- # Fields that specify first/last frame images for frame-conditioned generation.
27
- FRAME_FIELDS = %i[first_frame_image_url last_frame_image_url].freeze
28
- # Fields for reference-conditioned generation (images, videos, and audio).
29
- REFERENCE_FIELDS = %i[reference_image_urls reference_video_urls reference_audio_urls].freeze
30
-
31
7
  # A single generated video with its download URL.
32
8
  class Video < RunApi::Core::BaseModel
33
9
  optional :url, String
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "seedance/types"
5
- require_relative "seedance/contract_gen"
6
5
  require_relative "seedance/resources/text_to_video"
7
6
  require_relative "seedance/client"
8
7
 
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.3.1
4
+ version: 0.4.0
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.5.0
18
+ version: 0.6.0
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.5.0
25
+ version: 0.6.0
26
26
  description: The Seedance Ruby SDK is the language-specific package for Seedance on
27
27
  RunAPI. Use this package for video generation, animation, and video editing workflows
28
28
  when your application needs request bodies, task status lookup, and consistent RunAPI
@@ -39,7 +39,6 @@ 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
43
42
  - lib/runapi/seedance/resources/text_to_video.rb
44
43
  - lib/runapi/seedance/types.rb
45
44
  homepage: https://runapi.ai/models/seedance
@@ -66,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
65
  - !ruby/object:Gem::Version
67
66
  version: '0'
68
67
  requirements: []
69
- rubygems_version: 4.0.17
68
+ rubygems_version: 4.0.10
70
69
  specification_version: 4
71
70
  summary: Seedance Ruby SDK for RunAPI
72
71
  test_files: []
@@ -1,221 +0,0 @@
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-2.5", "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
- "seed" => {
23
- "min" => -1,
24
- "max" => 2147483647,
25
- "type" => "integer"
26
- },
27
- "source_image_urls" => {
28
- "max_items" => 2
29
- }
30
- },
31
- "seedance-2-mini" => {
32
- "aspect_ratio" => {
33
- "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "21:9", "auto"]
34
- },
35
- "duration_seconds" => {
36
- "min" => 4,
37
- "max" => 15,
38
- "type" => "integer"
39
- },
40
- "output_resolution" => {
41
- "enum" => ["480p", "720p"]
42
- },
43
- "reference_audio_urls" => {
44
- "max_items" => 3
45
- },
46
- "reference_image_urls" => {
47
- "max_items" => 9
48
- },
49
- "reference_video_urls" => {
50
- "max_items" => 3
51
- }
52
- },
53
- "seedance-2.0" => {
54
- "aspect_ratio" => {
55
- "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "21:9", "auto"]
56
- },
57
- "duration_seconds" => {
58
- "min" => 4,
59
- "max" => 15,
60
- "type" => "integer"
61
- },
62
- "output_resolution" => {
63
- "enum" => ["480p", "720p", "1080p", "4k"]
64
- },
65
- "reference_audio_urls" => {
66
- "max_items" => 3
67
- },
68
- "reference_image_urls" => {
69
- "max_items" => 9
70
- },
71
- "reference_video_urls" => {
72
- "max_items" => 3
73
- }
74
- },
75
- "seedance-2.0-fast" => {
76
- "aspect_ratio" => {
77
- "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "21:9", "auto"]
78
- },
79
- "duration_seconds" => {
80
- "min" => 4,
81
- "max" => 15,
82
- "type" => "integer"
83
- },
84
- "output_resolution" => {
85
- "enum" => ["480p", "720p"]
86
- },
87
- "reference_audio_urls" => {
88
- "max_items" => 3
89
- },
90
- "reference_image_urls" => {
91
- "max_items" => 9
92
- },
93
- "reference_video_urls" => {
94
- "max_items" => 3
95
- }
96
- },
97
- "seedance-2.5" => {
98
- "aspect_ratio" => {
99
- "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "21:9", "auto"]
100
- },
101
- "duration_seconds" => {
102
- "enum" => [-1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
103
- "type" => "integer"
104
- },
105
- "model" => {
106
- "required" => true
107
- },
108
- "output_format" => {
109
- "enum" => ["mp4", "mov"]
110
- },
111
- "output_resolution" => {
112
- "enum" => ["480p", "720p", "1080p"]
113
- },
114
- "prompt" => {
115
- "required" => true,
116
- "min" => 3,
117
- "max" => 30000,
118
- "length" => true
119
- },
120
- "reference_audio_urls" => {
121
- "max_items" => 10
122
- },
123
- "reference_image_urls" => {
124
- "max_items" => 30
125
- },
126
- "reference_video_urls" => {
127
- "max_items" => 10
128
- }
129
- },
130
- "seedance-v1-pro" => {
131
- "aspect_ratio" => {
132
- "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "21:9"]
133
- },
134
- "duration_seconds" => {
135
- "enum" => [5, 10],
136
- "required" => true,
137
- "type" => "integer"
138
- },
139
- "output_resolution" => {
140
- "enum" => ["480p", "720p", "1080p"]
141
- },
142
- "seed" => {
143
- "type" => "integer"
144
- }
145
- },
146
- "seedance-v1-pro-fast" => {
147
- "duration_seconds" => {
148
- "enum" => [5, 10],
149
- "required" => true,
150
- "type" => "integer"
151
- },
152
- "first_frame_image_url" => {
153
- "required" => true
154
- },
155
- "output_resolution" => {
156
- "enum" => ["720p", "1080p"]
157
- },
158
- "seed" => {
159
- "min" => -1,
160
- "max" => 2147483647,
161
- "type" => "integer"
162
- }
163
- }
164
- },
165
- "rules" => [{
166
- "when" => {
167
- "model" => "seedance-2.5",
168
- "first_frame_image_url" => {
169
- "present" => true
170
- }
171
- },
172
- "forbidden" => ["reference_image_urls", "reference_video_urls", "reference_audio_urls"]
173
- }, {
174
- "when" => {
175
- "model" => "seedance-2.5",
176
- "last_frame_image_url" => {
177
- "present" => true
178
- }
179
- },
180
- "required" => ["first_frame_image_url"],
181
- "forbidden" => ["reference_image_urls", "reference_video_urls", "reference_audio_urls"]
182
- }, {
183
- "when" => {
184
- "model" => "seedance-1.5-pro"
185
- },
186
- "forbidden" => ["first_frame_image_url", "last_frame_image_url", "reference_image_urls", "reference_video_urls", "reference_audio_urls", "web_search", "return_last_frame", "output_format"]
187
- }, {
188
- "when" => {
189
- "model" => "seedance-2-mini"
190
- },
191
- "forbidden" => ["source_image_urls", "lock_camera", "seed", "enable_safety_checker", "return_last_frame", "output_format"]
192
- }, {
193
- "when" => {
194
- "model" => "seedance-2.0"
195
- },
196
- "forbidden" => ["source_image_urls", "lock_camera", "seed", "return_last_frame", "output_format"]
197
- }, {
198
- "when" => {
199
- "model" => "seedance-2.0-fast"
200
- },
201
- "forbidden" => ["source_image_urls", "lock_camera", "seed", "return_last_frame", "output_format"]
202
- }, {
203
- "when" => {
204
- "model" => "seedance-2.5"
205
- },
206
- "forbidden" => ["source_image_urls", "lock_camera", "seed"]
207
- }, {
208
- "when" => {
209
- "model" => "seedance-v1-pro"
210
- },
211
- "forbidden" => ["source_image_urls", "last_frame_image_url", "reference_image_urls", "reference_video_urls", "reference_audio_urls", "web_search", "generate_audio", "return_last_frame", "output_format"]
212
- }, {
213
- "when" => {
214
- "model" => "seedance-v1-pro-fast"
215
- },
216
- "forbidden" => ["aspect_ratio", "source_image_urls", "lock_camera", "last_frame_image_url", "reference_image_urls", "reference_video_urls", "reference_audio_urls", "web_search", "generate_audio", "return_last_frame", "output_format"]
217
- }]
218
- }
219
- }.freeze
220
- end
221
- end