runapi-seedance 0.2.4 → 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 +4 -4
- data/README.md +45 -0
- data/lib/runapi/seedance/client.rb +2 -5
- data/lib/runapi/seedance/resources/text_to_video.rb +31 -29
- data/lib/runapi/seedance/types.rb +37 -8
- 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: 4a4129f28a6815e05d711bf3c21304a59cc6f9d5250ba3c4efec1126a72227b5
|
|
4
|
+
data.tar.gz: 997e90de2aa928d79bbfe267a05d267d842137056f5beb470b1d2646254bec70
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e2b7f49b273915dabdca3e14b02eac8ae58733f5f4cea8c53a2b6b2ce5dcbc58a3c3e961304eadbfb32dbe1d5358585c399ef0b029a1b47c062a35a7f06485e0
|
|
7
|
+
data.tar.gz: b7c7f737b22359c3808c02bda601abcb2c7bc7155acf05b769813ba281d26dd242f3428ddc6a228b5983358c9bc0e2b26168328f5d1de8af414512ff64f636e3
|
data/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
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::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.
|
|
32
|
+
|
|
33
|
+
## Links
|
|
34
|
+
|
|
35
|
+
- Model page: https://runapi.ai/models/seedance
|
|
36
|
+
- SDK docs: https://runapi.ai/docs#sdk-seedance
|
|
37
|
+
- Product docs: https://runapi.ai/docs#seedance
|
|
38
|
+
- Pricing and rate limits: https://runapi.ai/models/seedance/v1-lite
|
|
39
|
+
- Provider comparison: https://runapi.ai/providers/bytedance
|
|
40
|
+
- Full catalog: https://runapi.ai/models
|
|
41
|
+
- Repository: https://github.com/runapi-ai/seedance-sdk
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
Licensed under the Apache License, Version 2.0.
|
|
@@ -9,15 +9,12 @@ module RunApi
|
|
|
9
9
|
# result = client.text_to_video.run(
|
|
10
10
|
# model: "seedance-2.0", prompt: "A cat walking through a garden"
|
|
11
11
|
# )
|
|
12
|
-
class Client
|
|
12
|
+
class Client < RunApi::Core::Client
|
|
13
13
|
# @return [Resources::TextToVideo] Video generation operations.
|
|
14
14
|
attr_reader :text_to_video
|
|
15
15
|
|
|
16
16
|
def initialize(api_key: nil, **options)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
client_options = Core::ClientOptions.new(api_key: @api_key, **options)
|
|
20
|
-
http = client_options.http_client || Core::HttpClient.new(client_options)
|
|
17
|
+
super
|
|
21
18
|
@text_to_video = Resources::TextToVideo.new(http)
|
|
22
19
|
end
|
|
23
20
|
end
|
|
@@ -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, :
|
|
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
|
|
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, :
|
|
92
|
-
raise Core::ValidationError, "
|
|
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[
|
|
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
|
-
|
|
103
|
-
raise Core::ValidationError, "
|
|
104
|
-
unless Types::DURATIONS_V1.include?(
|
|
105
|
-
raise Core::ValidationError, "Invalid
|
|
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, :
|
|
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, :
|
|
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
|
-
|
|
129
|
-
|
|
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[
|
|
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
141
|
resolutions = (param(params, :model) == "seedance-2.0") ? Types::RESOLUTIONS_SEEDANCE_2 : Types::RESOLUTIONS_SEEDANCE_2_FAST
|
|
140
|
-
validate_optional!(params, :
|
|
142
|
+
validate_optional!(params, :output_resolution, resolutions)
|
|
141
143
|
|
|
142
|
-
|
|
143
|
-
if
|
|
144
|
-
dur_int =
|
|
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
|
|
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[
|
|
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
|
|
163
|
+
raise Core::ValidationError, "Cannot use frame mode and reference mode at the same time"
|
|
162
164
|
end
|
|
163
165
|
end
|
|
164
166
|
|
|
@@ -2,55 +2,84 @@
|
|
|
2
2
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Seedance
|
|
5
|
+
# Type definitions and constants for Seedance video generation.
|
|
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.
|
|
5
10
|
module Types
|
|
11
|
+
# V1-generation model identifiers: lite (low-cost), pro (high-quality), and pro-fast (speed-optimized).
|
|
6
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.
|
|
7
14
|
MODELS = (%w[seedance-1.5-pro seedance-2.0 seedance-2.0-fast] + V1_MODELS).freeze
|
|
8
15
|
|
|
16
|
+
# Aspect ratios for seedance-1.5-pro; required with every request.
|
|
9
17
|
ASPECT_RATIOS_1_5 = %w[1:1 4:3 3:4 16:9 9:16 21:9].freeze
|
|
10
|
-
|
|
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.
|
|
11
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.
|
|
12
23
|
ASPECT_RATIOS_V1_PRO = %w[1:1 4:3 3:4 16:9 9:16 21:9].freeze
|
|
13
24
|
|
|
25
|
+
# Output resolutions for seedance-1.5-pro.
|
|
14
26
|
RESOLUTIONS_1_5 = %w[480p 720p 1080p].freeze
|
|
27
|
+
# Output resolutions for seedance-2.0.
|
|
15
28
|
RESOLUTIONS_SEEDANCE_2 = %w[480p 720p 1080p].freeze
|
|
29
|
+
# Output resolutions for seedance-2.0-fast; capped at 720p for faster rendering.
|
|
16
30
|
RESOLUTIONS_SEEDANCE_2_FAST = %w[480p 720p].freeze
|
|
31
|
+
# Output resolutions for seedance-v1-lite and seedance-v1-pro.
|
|
17
32
|
RESOLUTIONS_V1 = %w[480p 720p 1080p].freeze
|
|
33
|
+
# Output resolutions for seedance-v1-pro-fast; minimum 720p.
|
|
18
34
|
RESOLUTIONS_V1_PRO_FAST = %w[720p 1080p].freeze
|
|
19
35
|
|
|
20
|
-
|
|
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.
|
|
21
39
|
DURATION_2_RANGE = (4..15)
|
|
22
|
-
|
|
40
|
+
# Allowed duration values (seconds) for V1 models; 5 or 10.
|
|
41
|
+
DURATIONS_V1 = [5, 10].freeze
|
|
42
|
+
# Valid seed range; -1 requests a random seed.
|
|
23
43
|
SEED_RANGE = (-1..2_147_483_647)
|
|
24
44
|
|
|
45
|
+
# Minimum prompt length in characters, enforced across all models.
|
|
25
46
|
PROMPT_MIN_LENGTH = 3
|
|
47
|
+
# Maximum prompt length for seedance-1.5-pro.
|
|
26
48
|
PROMPT_MAX_LENGTH_1_5 = 2500
|
|
49
|
+
# Maximum prompt length for 2.0/2.0-fast (up to 20 000 characters).
|
|
27
50
|
PROMPT_MAX_LENGTH_2 = 20000
|
|
51
|
+
# Maximum prompt length for V1 models (up to 10 000 characters).
|
|
28
52
|
PROMPT_MAX_LENGTH_V1 = 10000
|
|
29
53
|
|
|
30
|
-
|
|
54
|
+
# Fields that specify first/last frame images for frame-conditioned generation.
|
|
55
|
+
FRAME_FIELDS = %i[first_frame_image_url last_frame_image_url].freeze
|
|
56
|
+
# Fields for reference-conditioned generation (images, videos, and audio).
|
|
31
57
|
REFERENCE_FIELDS = %i[reference_image_urls reference_video_urls reference_audio_urls].freeze
|
|
32
58
|
|
|
59
|
+
# A single generated video with its download URL.
|
|
33
60
|
class Video < RunApi::Core::BaseModel
|
|
34
61
|
optional :url, String
|
|
35
62
|
end
|
|
36
63
|
|
|
64
|
+
# Base async response returned immediately after task creation and during polling.
|
|
37
65
|
class AsyncTaskResponse < RunApi::Core::TaskResponse
|
|
38
66
|
required :id, String
|
|
39
67
|
optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
|
|
40
68
|
end
|
|
41
69
|
|
|
70
|
+
# Full response for a text-to-video task, including generated videos on completion.
|
|
42
71
|
class TextToVideoResponse < AsyncTaskResponse
|
|
43
|
-
optional :videos, [
|
|
44
|
-
optional :
|
|
72
|
+
optional :videos, [-> { Video }]
|
|
73
|
+
optional :last_frame_image_url, String
|
|
45
74
|
optional :error, String
|
|
46
75
|
end
|
|
47
76
|
|
|
48
77
|
# Narrowed response returned by `text_to_video.run()` once polling observes
|
|
49
78
|
# `status: "completed"`. `videos` is required so consumers never have to
|
|
50
|
-
# null-check it on a successful task. `
|
|
79
|
+
# null-check it on a successful task. `last_frame_image_url` stays optional
|
|
51
80
|
# because it may be absent.
|
|
52
81
|
class CompletedTextToVideoResponse < TextToVideoResponse
|
|
53
|
-
required :videos, [
|
|
82
|
+
required :videos, [-> { Video }]
|
|
54
83
|
end
|
|
55
84
|
end
|
|
56
85
|
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.
|
|
4
|
+
version: 0.2.7
|
|
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 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://github.com/runapi-ai/seedance-sdk/blob/main/README.md
|
|
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: []
|
|
@@ -60,5 +65,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
60
65
|
requirements: []
|
|
61
66
|
rubygems_version: 4.0.10
|
|
62
67
|
specification_version: 4
|
|
63
|
-
summary: Seedance API
|
|
68
|
+
summary: Seedance API Ruby SDK for RunAPI
|
|
64
69
|
test_files: []
|