runapi-runway 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/runway/client.rb +15 -6
- data/lib/runapi/runway/resources/extend_video.rb +21 -4
- data/lib/runapi/runway/resources/text_to_video.rb +23 -3
- data/lib/runapi/runway/types.rb +20 -5
- 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: 59ad3e607d33dc4bb65bd09cbf86eaf3ff1de1c48c319db17a6ff01e28e506e1
|
|
4
|
+
data.tar.gz: bdb1f84d784e5edcb01566aafd8f82865c6b6cf2b2552464981c16d6e29745c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b0be7c1953ea69ff61be3c96c23fb5f615288da5d6e8f8b9f72e71eb748049c0eab3697dc9576c3549116ac9f1eae18fbc1662040c6097971b5289adb16efef
|
|
7
|
+
data.tar.gz: d88f0bf293488b0c5da4bd817578820525f8b7edb7a0ccffcb57044bb8f09030f6de5389fb2264108e1adcfd12d4f11d0ea9ae4e795dca7ea6f5a01cac75d91e
|
data/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Runway API Ruby SDK for RunAPI
|
|
2
|
+
|
|
3
|
+
The runway api Ruby SDK is the language-specific package for Runway on RunAPI. Use this runway 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 runway api README is the Ruby package guide inside the public `runway-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/runway; for API reference, use https://runapi.ai/docs#runway; for SDK docs, use https://runapi.ai/docs#sdk-runway.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
gem install runapi-runway
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
require "runapi-runway"
|
|
17
|
+
|
|
18
|
+
client = RunApi::Runway::Client.new
|
|
19
|
+
task = client.text_to_video.create(
|
|
20
|
+
# Pass the Runway JSON request body from https://runapi.ai/docs#runway.
|
|
21
|
+
)
|
|
22
|
+
status = client.text_to_video.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::Runway` error classes when building video jobs, Rails workers, or scripts. The available resources are `text_to_video` and `extend_video`. 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/runway
|
|
36
|
+
- SDK docs: https://runapi.ai/docs#sdk-runway
|
|
37
|
+
- Product docs: https://runapi.ai/docs#runway
|
|
38
|
+
- Pricing and rate limits: https://runapi.ai/models/runway
|
|
39
|
+
- Provider comparison: https://runapi.ai/providers/runway
|
|
40
|
+
- Full catalog: https://runapi.ai/models
|
|
41
|
+
- Repository: https://github.com/runapi-ai/runway-sdk
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
Licensed under the Apache License, Version 2.0.
|
data/lib/runapi/runway/client.rb
CHANGED
|
@@ -2,14 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Runway
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
# Runway Gen-4 video generation API client.
|
|
6
|
+
#
|
|
7
|
+
# @example
|
|
8
|
+
# client = RunApi::Runway::Client.new(api_key: "your-api-key")
|
|
9
|
+
# result = client.text_to_video.run(
|
|
10
|
+
# prompt: "A timelapse of a city skyline at sunset",
|
|
11
|
+
# duration_seconds: 10,
|
|
12
|
+
# output_resolution: "720p"
|
|
13
|
+
# )
|
|
14
|
+
class Client < RunApi::Core::Client
|
|
15
|
+
# @return [Resources::TextToVideo] Text-to-video and image-to-video operations.
|
|
16
|
+
attr_reader :text_to_video
|
|
17
|
+
# @return [Resources::ExtendVideo] Extend-video operations.
|
|
18
|
+
attr_reader :extend_video
|
|
7
19
|
|
|
8
20
|
def initialize(api_key: nil, **options)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
client_options = Core::ClientOptions.new(api_key: @api_key, **options)
|
|
12
|
-
http = client_options.http_client || Core::HttpClient.new(client_options)
|
|
21
|
+
super
|
|
13
22
|
@text_to_video = Resources::TextToVideo.new(http)
|
|
14
23
|
@extend_video = Resources::ExtendVideo.new(http)
|
|
15
24
|
end
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Runway
|
|
5
5
|
module Resources
|
|
6
|
+
# Runway extend-video resource.
|
|
7
|
+
# Append additional footage to a previously generated video, continuing from where the source task left off.
|
|
6
8
|
class ExtendVideo
|
|
7
9
|
include RunApi::Core::ResourceHelpers
|
|
8
10
|
|
|
@@ -14,17 +16,33 @@ module RunApi
|
|
|
14
16
|
@http = http
|
|
15
17
|
end
|
|
16
18
|
|
|
19
|
+
# Extend a video and wait until complete.
|
|
20
|
+
#
|
|
21
|
+
# @param source_task_id [String] ID of the completed TextToVideo or ExtendVideo task to continue from
|
|
22
|
+
# @param prompt [String] prompt describing the continuation footage
|
|
23
|
+
# @param output_resolution [String] must match the resolution of the source task ("720p" or "1080p")
|
|
24
|
+
# @param watermark [String, nil] watermark text burned into the output
|
|
25
|
+
# @param callback_url [String, nil] webhook URL for completion notification
|
|
26
|
+
# @return [RunApi::Runway::Types::CompletedTaskResponse] completed task with videos
|
|
17
27
|
def run(**params)
|
|
18
28
|
task = create(**params)
|
|
19
29
|
poll_until_complete { get(task.id) }
|
|
20
30
|
end
|
|
21
31
|
|
|
32
|
+
# Create an extend-video task without waiting for completion.
|
|
33
|
+
#
|
|
34
|
+
# @param params [Hash] extend-video parameters (see {#run} for details)
|
|
35
|
+
# @return [RunApi::Runway::Types::TaskCreateResponse] task creation result with id
|
|
22
36
|
def create(**params)
|
|
23
37
|
params = compact_params(params)
|
|
24
38
|
validate_params!(params)
|
|
25
39
|
request(:post, ENDPOINT, body: params)
|
|
26
40
|
end
|
|
27
41
|
|
|
42
|
+
# Get extend-video task status by task ID.
|
|
43
|
+
#
|
|
44
|
+
# @param id [String] task ID
|
|
45
|
+
# @return [RunApi::Runway::Types::TaskResponse] current task status
|
|
28
46
|
def get(id)
|
|
29
47
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
48
|
end
|
|
@@ -32,11 +50,10 @@ module RunApi
|
|
|
32
50
|
private
|
|
33
51
|
|
|
34
52
|
def validate_params!(params)
|
|
35
|
-
raise Core::ValidationError, "
|
|
53
|
+
raise Core::ValidationError, "source_task_id is required" unless param(params, :source_task_id)
|
|
36
54
|
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
37
|
-
raise Core::ValidationError, "
|
|
38
|
-
|
|
39
|
-
validate_optional!(params, :quality, Types::QUALITIES)
|
|
55
|
+
raise Core::ValidationError, "output_resolution is required" unless param(params, :output_resolution)
|
|
56
|
+
validate_optional!(params, :output_resolution, Types::OUTPUT_RESOLUTIONS)
|
|
40
57
|
end
|
|
41
58
|
end
|
|
42
59
|
end
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Runway
|
|
5
5
|
module Resources
|
|
6
|
+
# Runway text-to-video resource.
|
|
7
|
+
# Generate video from a text prompt, optionally using a first-frame image for image-to-video generation.
|
|
6
8
|
class TextToVideo
|
|
7
9
|
include RunApi::Core::ResourceHelpers
|
|
8
10
|
|
|
@@ -14,17 +16,35 @@ module RunApi
|
|
|
14
16
|
@http = http
|
|
15
17
|
end
|
|
16
18
|
|
|
19
|
+
# Create a text-to-video task and wait until complete.
|
|
20
|
+
#
|
|
21
|
+
# @param prompt [String] video description prompt
|
|
22
|
+
# @param duration_seconds [Integer] video length: 5 or 10
|
|
23
|
+
# @param output_resolution [String] "720p" or "1080p"
|
|
24
|
+
# @param first_frame_image_url [String, nil] opening frame image URL for image-to-video
|
|
25
|
+
# @param aspect_ratio [String, nil] only for pure text-to-video (no first-frame image)
|
|
26
|
+
# @param watermark [String, nil] watermark text burned into the output
|
|
27
|
+
# @param callback_url [String, nil] webhook URL for completion notification
|
|
28
|
+
# @return [RunApi::Runway::Types::CompletedTaskResponse] completed task with videos
|
|
17
29
|
def run(**params)
|
|
18
30
|
task = create(**params)
|
|
19
31
|
poll_until_complete { get(task.id) }
|
|
20
32
|
end
|
|
21
33
|
|
|
34
|
+
# Create a text-to-video task without waiting for completion.
|
|
35
|
+
#
|
|
36
|
+
# @param params [Hash] text-to-video parameters (see {#run} for details)
|
|
37
|
+
# @return [RunApi::Runway::Types::TaskCreateResponse] task creation result with id
|
|
22
38
|
def create(**params)
|
|
23
39
|
params = compact_params(params)
|
|
24
40
|
validate_params!(params)
|
|
25
41
|
request(:post, ENDPOINT, body: params)
|
|
26
42
|
end
|
|
27
43
|
|
|
44
|
+
# Get text-to-video task status by task ID.
|
|
45
|
+
#
|
|
46
|
+
# @param id [String] task ID
|
|
47
|
+
# @return [RunApi::Runway::Types::TaskResponse] current task status
|
|
28
48
|
def get(id)
|
|
29
49
|
request(:get, "#{ENDPOINT}/#{id}")
|
|
30
50
|
end
|
|
@@ -33,9 +53,9 @@ module RunApi
|
|
|
33
53
|
|
|
34
54
|
def validate_params!(params)
|
|
35
55
|
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
36
|
-
raise Core::ValidationError, "
|
|
37
|
-
raise Core::ValidationError, "
|
|
38
|
-
validate_optional!(params, :
|
|
56
|
+
raise Core::ValidationError, "duration_seconds is required" unless param(params, :duration_seconds)
|
|
57
|
+
raise Core::ValidationError, "output_resolution is required" unless param(params, :output_resolution)
|
|
58
|
+
validate_optional!(params, :output_resolution, Types::OUTPUT_RESOLUTIONS)
|
|
39
59
|
validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
|
|
40
60
|
end
|
|
41
61
|
end
|
data/lib/runapi/runway/types.rb
CHANGED
|
@@ -2,28 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module Runway
|
|
5
|
+
# Type definitions and constants for Runway Gen-4 video generation.
|
|
5
6
|
module Types
|
|
6
|
-
|
|
7
|
+
# Output resolution. 720p (1280x720) is faster and lower cost;
|
|
8
|
+
# 1080p (1920x1080) produces higher detail at higher cost.
|
|
9
|
+
OUTPUT_RESOLUTIONS = %w[720p 1080p].freeze
|
|
10
|
+
|
|
11
|
+
# Aspect ratio for pure text-to-video. Ignored when a first-frame image is provided.
|
|
7
12
|
ASPECT_RATIOS = %w[16:9 9:16 1:1 4:3 3:4].freeze
|
|
8
13
|
|
|
14
|
+
# A generated video file with a download URL.
|
|
9
15
|
class Video < RunApi::Core::BaseModel
|
|
10
16
|
optional :id, String
|
|
11
17
|
required :url, String
|
|
12
18
|
end
|
|
13
19
|
|
|
20
|
+
# A generated image file with a download URL.
|
|
21
|
+
class Image < RunApi::Core::BaseModel
|
|
22
|
+
required :url, String
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Full task response returned by polling. Contains output media once the task completes.
|
|
14
26
|
class TaskResponse < RunApi::Core::TaskResponse
|
|
15
27
|
required :id, String
|
|
16
28
|
optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
|
|
17
|
-
optional :videos, [
|
|
18
|
-
optional :
|
|
19
|
-
optional :
|
|
29
|
+
optional :videos, [-> { Video }]
|
|
30
|
+
optional :images, [-> { Image }]
|
|
31
|
+
optional :source_task_id, String
|
|
20
32
|
optional :error, String
|
|
21
33
|
end
|
|
22
34
|
|
|
35
|
+
# Response returned when a task is first created, before polling begins.
|
|
23
36
|
class TaskCreateResponse < TaskResponse; end
|
|
24
37
|
|
|
38
|
+
# Narrowed response returned by +run()+ once polling observes completion.
|
|
39
|
+
# +videos+ is guaranteed present so consumers never need to null-check.
|
|
25
40
|
class CompletedTaskResponse < TaskResponse
|
|
26
|
-
required :videos, [
|
|
41
|
+
required :videos, [-> { Video }]
|
|
27
42
|
end
|
|
28
43
|
end
|
|
29
44
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: runapi-runway
|
|
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 runway api Ruby SDK is the language-specific package for Runway on
|
|
27
|
+
RunAPI. Use this runway api package for text-to-video, image-to-video, video editing,
|
|
28
|
+
and animation flows when your application needs JSON request bodies, task status
|
|
29
|
+
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-runway.rb
|
|
35
40
|
- lib/runapi/runway.rb
|
|
36
41
|
- lib/runapi/runway/client.rb
|
|
@@ -42,7 +47,7 @@ licenses:
|
|
|
42
47
|
- Apache-2.0
|
|
43
48
|
metadata:
|
|
44
49
|
homepage_uri: https://runapi.ai/models/runway
|
|
45
|
-
documentation_uri: https://github.com/runapi-ai/runway-sdk/blob/main/README.md
|
|
50
|
+
documentation_uri: https://github.com/runapi-ai/runway-sdk/blob/main/ruby/README.md
|
|
46
51
|
source_code_uri: https://github.com/runapi-ai/runway-sdk
|
|
47
52
|
changelog_uri: https://github.com/runapi-ai/runway-sdk/blob/main/CHANGELOG.md
|
|
48
53
|
rdoc_options: []
|
|
@@ -61,5 +66,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
61
66
|
requirements: []
|
|
62
67
|
rubygems_version: 4.0.10
|
|
63
68
|
specification_version: 4
|
|
64
|
-
summary: Runway API
|
|
69
|
+
summary: Runway API Ruby SDK for RunAPI
|
|
65
70
|
test_files: []
|