runapi-seedance 0.2.1 → 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: a62ab3f8ec773b2d95c2cf868431bff5070499ac9c6f5a42e2dd857c451e714f
4
- data.tar.gz: 8fb685bf5b79b3c365aa1393c1bc340506b5cde9a20455b200bd21b06fe746cc
3
+ metadata.gz: 4118e285fccee6a45c55c4a823d935bb75d7cca1cfe5dfc4e82973214575c183
4
+ data.tar.gz: 6ca91fe558e2a4e53890b21d573b4809dc2af0335cce7f35baabde7797c54fec
5
5
  SHA512:
6
- metadata.gz: be49f1ab6768dc67ecc21aba313099c0bec5a4ec2f426a277adc838e6e59c334c72f0954da267e4c3b4a3bc55d8cc1f26c5ce328fc4c7a14ae375b39971f6680
7
- data.tar.gz: '0258d37436ca3252f60004433252340182799f8f285d9d5f6ee6c251fa9f3cd2d24c56a2f3af959ddd41e44a7e32e64b7a9dd21019496221bb1ac3343aff7044'
6
+ metadata.gz: 0074a40fc6a32db226f372d2575aa2db218d3c0ec5b7abe2d3a6ffc1a9f962e5a137e7d03ab8ee714f80c6377180d88aed4899d513f84b008991452bc888c1b5
7
+ data.tar.gz: '06799aaa55a72f75efdef4e17311297e96c7a73b53bbfa1856157be770066adb09edc70128b9db546fe301359b8fd6eae7f84ec34d3251de19447568b340593d'
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Seedance API Ruby SDK for RunAPI
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.
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.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ gem install runapi-seedance
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```ruby
16
+ require "runapi-seedance"
17
+
18
+ client = RunApi::Seedance::Client.new
19
+ task = client.generations.create(
20
+ # Pass the Seedance JSON request body from https://runapi.ai/docs#seedance.
21
+ )
22
+ status = client.generations.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
+ ## Language notes
28
+
29
+ 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.
30
+
31
+ ## Links
32
+
33
+ - Model page: https://runapi.ai/models/seedance
34
+ - SDK docs: https://runapi.ai/docs#sdk-seedance
35
+ - Product docs: https://runapi.ai/docs#seedance
36
+ - Pricing and rate limits: https://runapi.ai/models/seedance/v1-lite
37
+ - Provider comparison: https://runapi.ai/providers/bytedance
38
+ - Full catalog: https://runapi.ai/models
39
+ - Repository: https://github.com/runapi-ai/seedance-sdk
40
+
41
+ ## License
42
+
43
+ Licensed under the Apache License, Version 2.0.
@@ -7,7 +7,7 @@ module RunApi
7
7
  # @example
8
8
  # client = RunApi::Seedance::Client.new(api_key: "your-api-key")
9
9
  # result = client.text_to_video.run(
10
- # model: "seedance-2", prompt: "A cat walking through a garden"
10
+ # model: "seedance-2.0", prompt: "A cat walking through a garden"
11
11
  # )
12
12
  class Client
13
13
  # @return [Resources::TextToVideo] Video generation operations.
@@ -74,35 +74,29 @@ module RunApi
74
74
 
75
75
  def validate_v1!(params)
76
76
  model = param(params, :model)
77
- has_image = field_present?(params, :input_urls)
77
+ has_image = field_present?(params, :first_frame_image_url)
78
78
 
79
79
  if model == "seedance-v1-pro-fast" && !has_image
80
- raise Core::ValidationError, "seedance-v1-pro-fast requires input_urls (image-to-video only)"
81
- end
82
-
83
- if (value = param(params, :input_urls)).is_a?(Array) && value.size > 1
84
- raise Core::ValidationError, "input_urls accepts at most 1 image for Seedance V1"
80
+ raise Core::ValidationError, "seedance-v1-pro-fast requires first_frame_image_url"
85
81
  end
86
82
 
87
83
  if has_image && field_present?(params, :aspect_ratio)
88
84
  raise Core::ValidationError, "aspect_ratio is not accepted in image-to-video mode; it is derived from the image"
89
85
  end
90
86
 
91
- if field_present?(params, :last_frame_url) && !(model == "seedance-v1-lite" && has_image)
92
- raise Core::ValidationError, "last_frame_url is only supported by seedance-v1-lite in image-to-video mode"
87
+ if field_present?(params, :last_frame_image_url) && !(model == "seedance-v1-lite" && has_image)
88
+ raise Core::ValidationError, "last_frame_image_url is only supported by seedance-v1-lite in image-to-video mode"
93
89
  end
94
90
 
95
- unsupported = %i[first_frame_url reference_image_urls reference_video_urls reference_audio_urls web_search generate_audio]
91
+ unsupported = %i[source_image_urls reference_image_urls reference_video_urls reference_audio_urls web_search generate_audio]
96
92
  reject_unsupported!(params, unsupported, model)
97
93
 
98
- if model == "seedance-v1-pro-fast"
99
- reject_unsupported!(params, %i[lock_camera seed enable_safety_checker], model)
100
- end
94
+ reject_unsupported!(params, %i[lock_camera seed], model) if model == "seedance-v1-pro-fast"
101
95
 
102
- duration = param(params, :duration)
103
- raise Core::ValidationError, "duration is required for Seedance V1; must be one of: #{Types::DURATIONS_V1.join(", ")}" unless duration
104
- unless Types::DURATIONS_V1.include?(duration.to_s)
105
- raise Core::ValidationError, "Invalid duration for #{model}: #{duration}. Must be one of: #{Types::DURATIONS_V1.join(", ")}"
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(", ")}"
106
100
  end
107
101
 
108
102
  unless has_image
@@ -111,7 +105,7 @@ module RunApi
111
105
  end
112
106
 
113
107
  resolutions = (model == "seedance-v1-pro-fast") ? Types::RESOLUTIONS_V1_PRO_FAST : Types::RESOLUTIONS_V1
114
- validate_optional!(params, :resolution, resolutions)
108
+ validate_optional!(params, :output_resolution, resolutions)
115
109
 
116
110
  seed = param(params, :seed)
117
111
  if seed
@@ -123,31 +117,39 @@ module RunApi
123
117
 
124
118
  def validate_1_5_pro!(params)
125
119
  validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS_1_5)
126
- validate_optional!(params, :resolution, Types::RESOLUTIONS_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
127
130
 
128
- duration = param(params, :duration)
129
- if duration && !Types::DURATIONS_1_5.include?(duration.to_s)
130
- raise Core::ValidationError, "Invalid duration for seedance-1.5-pro: #{duration}. Must be one of: #{Types::DURATIONS_1_5.join(", ")}"
131
+ if (value = param(params, :source_image_urls)).is_a?(Array) && value.size > 2
132
+ raise Core::ValidationError, "source_image_urls accepts at most 2 images for seedance-1.5-pro"
131
133
  end
132
134
 
133
- unsupported = %i[first_frame_url last_frame_url reference_image_urls reference_video_urls reference_audio_urls web_search]
135
+ unsupported = %i[first_frame_image_url last_frame_image_url reference_image_urls reference_video_urls reference_audio_urls web_search]
134
136
  reject_unsupported!(params, unsupported, "seedance-1.5-pro")
135
137
  end
136
138
 
137
139
  def validate_2!(params)
138
140
  validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS_2)
139
- resolutions = (param(params, :model) == "seedance-2") ? Types::RESOLUTIONS_SEEDANCE_2 : Types::RESOLUTIONS_SEEDANCE_2_FAST
140
- validate_optional!(params, :resolution, resolutions)
141
+ resolutions = (param(params, :model) == "seedance-2.0") ? Types::RESOLUTIONS_SEEDANCE_2 : Types::RESOLUTIONS_SEEDANCE_2_FAST
142
+ validate_optional!(params, :output_resolution, resolutions)
141
143
 
142
- duration = param(params, :duration)
143
- if duration
144
- dur_int = duration.to_i
144
+ duration_seconds = param(params, :duration_seconds)
145
+ if duration_seconds
146
+ dur_int = duration_seconds.to_i
145
147
  unless Types::DURATION_2_RANGE.cover?(dur_int)
146
- raise Core::ValidationError, "Invalid duration for seedance-2: #{duration}. Must be an integer between 4 and 15"
148
+ raise Core::ValidationError, "Invalid duration_seconds for seedance-2.0: #{duration_seconds}. Must be an integer between 4 and 15"
147
149
  end
148
150
  end
149
151
 
150
- unsupported = %i[input_urls lock_camera]
152
+ unsupported = %i[source_image_urls lock_camera]
151
153
  reject_unsupported!(params, unsupported, param(params, :model))
152
154
 
153
155
  validate_mode_conflicts!(params)
@@ -158,7 +160,7 @@ module RunApi
158
160
  has_reference = Types::REFERENCE_FIELDS.any? { |f| field_present?(params, f) }
159
161
 
160
162
  if has_frame && has_reference
161
- raise Core::ValidationError, "Cannot use frame mode (first_frame_url/last_frame_url) and reference mode (reference_image_urls/reference_video_urls/reference_audio_urls) at the same time"
163
+ raise Core::ValidationError, "Cannot use frame mode and reference mode at the same time"
162
164
  end
163
165
  end
164
166
 
@@ -4,10 +4,10 @@ module RunApi
4
4
  module Seedance
5
5
  module Types
6
6
  V1_MODELS = %w[seedance-v1-lite seedance-v1-pro seedance-v1-pro-fast].freeze
7
- MODELS = (%w[seedance-1.5-pro seedance-2 seedance-2-fast] + V1_MODELS).freeze
7
+ MODELS = (%w[seedance-1.5-pro seedance-2.0 seedance-2.0-fast] + V1_MODELS).freeze
8
8
 
9
9
  ASPECT_RATIOS_1_5 = %w[1:1 4:3 3:4 16:9 9:16 21:9].freeze
10
- ASPECT_RATIOS_2 = [ *ASPECT_RATIOS_1_5, "auto" ].freeze
10
+ ASPECT_RATIOS_2 = [*ASPECT_RATIOS_1_5, "auto"].freeze
11
11
  ASPECT_RATIOS_V1_LITE = %w[1:1 4:3 3:4 16:9 9:16 9:21].freeze
12
12
  ASPECT_RATIOS_V1_PRO = %w[1:1 4:3 3:4 16:9 9:16 21:9].freeze
13
13
 
@@ -17,9 +17,9 @@ module RunApi
17
17
  RESOLUTIONS_V1 = %w[480p 720p 1080p].freeze
18
18
  RESOLUTIONS_V1_PRO_FAST = %w[720p 1080p].freeze
19
19
 
20
- DURATIONS_1_5 = %w[4 8 12].freeze
20
+ DURATIONS_1_5 = [4, 8, 12].freeze
21
21
  DURATION_2_RANGE = (4..15)
22
- DURATIONS_V1 = %w[5 10].freeze
22
+ DURATIONS_V1 = [5, 10].freeze
23
23
  SEED_RANGE = (-1..2_147_483_647)
24
24
 
25
25
  PROMPT_MIN_LENGTH = 3
@@ -27,7 +27,7 @@ module RunApi
27
27
  PROMPT_MAX_LENGTH_2 = 20000
28
28
  PROMPT_MAX_LENGTH_V1 = 10000
29
29
 
30
- FRAME_FIELDS = %i[first_frame_url last_frame_url].freeze
30
+ FRAME_FIELDS = %i[first_frame_image_url last_frame_image_url].freeze
31
31
  REFERENCE_FIELDS = %i[reference_image_urls reference_video_urls reference_audio_urls].freeze
32
32
 
33
33
  class Video < RunApi::Core::BaseModel
@@ -40,17 +40,17 @@ module RunApi
40
40
  end
41
41
 
42
42
  class TextToVideoResponse < AsyncTaskResponse
43
- optional :videos, [ -> { Video } ]
44
- optional :last_frame_url, String
43
+ optional :videos, [-> { Video }]
44
+ optional :last_frame_image_url, String
45
45
  optional :error, String
46
46
  end
47
47
 
48
48
  # Narrowed response returned by `text_to_video.run()` once polling observes
49
49
  # `status: "completed"`. `videos` is required so consumers never have to
50
- # null-check it on a successful task. `last_frame_url` stays optional
50
+ # null-check it on a successful task. `last_frame_image_url` stays optional
51
51
  # because it may be absent.
52
52
  class CompletedTextToVideoResponse < TextToVideoResponse
53
- required :videos, [ -> { Video } ]
53
+ required :videos, [-> { Video }]
54
54
  end
55
55
  end
56
56
  end
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.1
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.1'
18
+ version: 0.2.5
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.1'
26
- description: RunAPI Seedance SDK for JavaScript, Ruby, and Go
25
+ version: 0.2.5
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.
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-seedance.rb
35
40
  - lib/runapi/seedance.rb
36
41
  - lib/runapi/seedance/client.rb
@@ -41,7 +46,7 @@ licenses:
41
46
  - Apache-2.0
42
47
  metadata:
43
48
  homepage_uri: https://runapi.ai/models/seedance
44
- documentation_uri: https://runapi.ai/models/seedance
49
+ documentation_uri: https://github.com/runapi-ai/seedance-sdk/blob/main/ruby/README.md
45
50
  source_code_uri: https://github.com/runapi-ai/seedance-sdk
46
51
  changelog_uri: https://github.com/runapi-ai/seedance-sdk/blob/main/CHANGELOG.md
47
52
  rdoc_options: []
@@ -58,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
63
  - !ruby/object:Gem::Version
59
64
  version: '0'
60
65
  requirements: []
61
- rubygems_version: 4.0.6
66
+ rubygems_version: 4.0.10
62
67
  specification_version: 4
63
- summary: Seedance API SDKs for JavaScript, Ruby, and Go on RunAPI.
68
+ summary: Seedance API Ruby SDK for RunAPI
64
69
  test_files: []