runapi-runway 0.2.6 → 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: 136d7bef7e251f84697d1faec9be01a6771a3948f4c2df29711f8c5d335c2e42
4
- data.tar.gz: 76c88350d5408ce93c05ddb25e49e90429c5e5e76f540d8993eb3738ab5c2c94
3
+ metadata.gz: ad79cfb3fe2fd25106c5b06257c8f4a204bc2f423fa033cf7fd7c37af6aaf5a0
4
+ data.tar.gz: 0ea01d23599ba93b73cca5b682fceeb2d40c27d258f0c2c245f937dfbd5d4fff
5
5
  SHA512:
6
- metadata.gz: c850f59712359438aa95bd65cebfcd3149f2f5b80d45378978f2b7a47b0190b308e12b220a4329ffd88535da128080e40d4eb43faa45a890e9431c43d6a782a0
7
- data.tar.gz: adba718ecc15852b75fef465d757c9e6e6b922f68b5a2c91c4f83cb4b3fbeb517aa7718d3e25067c4abff473e5e38241647a0568f50c9165a9fc9384d9fc7f0d
6
+ metadata.gz: 4d452b908a3800518ccc32c8d9a300b24f8e47afd51f597d3703e1da2af01f899195437ad8483807825253b0970f3d67acd8da850674fb0c43f927f7d5a0f780
7
+ data.tar.gz: c8d1792c8e980bfe52f58c9fac6cfc4f8ce397bdae4abb31eebcd2cc74100574ed30f1311e8fc3f054f3481ad0605b0ec7cbd1bc00782a503c893b601decb521
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Runway API Ruby SDK for RunAPI
1
+ # Runway Ruby SDK for RunAPI
2
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.
3
+ The Runway Ruby SDK is the language-specific package for Runway 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 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.
5
+ This 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
6
 
7
7
  ## Install
8
8
 
@@ -13,7 +13,7 @@ gem install runapi-runway
13
13
  ## Quick start
14
14
 
15
15
  ```ruby
16
- require "runapi-runway"
16
+ require "runapi/runway"
17
17
 
18
18
  client = RunApi::Runway::Client.new
19
19
  task = client.text_to_video.create(
@@ -24,6 +24,8 @@ status = client.text_to_video.get(task.id)
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.
26
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
+
27
29
  ## Language notes
28
30
 
29
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.
@@ -2,14 +2,23 @@
2
2
 
3
3
  module RunApi
4
4
  module Runway
5
- class Client
6
- attr_reader :text_to_video, :extend_video
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
- @api_key = Core::Auth.resolve_api_key(api_key)
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
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module Runway
5
+ CONTRACT = {
6
+ "extend-video" => {
7
+ "models" => ["runway"],
8
+ "fields_by_model" => {
9
+ "runway" => {
10
+ "output_resolution" => {
11
+ "enum" => ["720p", "1080p"],
12
+ "required" => true
13
+ },
14
+ "prompt" => {
15
+ "required" => true
16
+ },
17
+ "source_task_id" => {
18
+ "required" => true
19
+ }
20
+ }
21
+ }
22
+ },
23
+ "text-to-video" => {
24
+ "models" => ["runway"],
25
+ "fields_by_model" => {
26
+ "runway" => {
27
+ "aspect_ratio" => {
28
+ "enum" => ["16:9", "9:16", "1:1", "4:3", "3:4"]
29
+ },
30
+ "duration_seconds" => {
31
+ "enum" => [5, 10],
32
+ "required" => true,
33
+ "type" => "integer"
34
+ },
35
+ "output_resolution" => {
36
+ "enum" => ["720p", "1080p"],
37
+ "required" => true
38
+ },
39
+ "prompt" => {
40
+ "required" => true
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }.freeze
46
+ end
47
+ end
@@ -3,39 +3,49 @@
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
 
9
11
  ENDPOINT = "/api/v1/runway/extend_video"
10
12
  RESPONSE_CLASS = Types::TaskCreateResponse
11
13
  COMPLETED_RESPONSE_CLASS = Types::CompletedTaskResponse
14
+ MODEL = "runway"
12
15
 
13
16
  def initialize(http)
14
17
  @http = http
15
18
  end
16
19
 
17
- def run(**params)
18
- task = create(**params)
19
- poll_until_complete { get(task.id) }
20
+ # Extend a video and wait until complete.
21
+ #
22
+ # @param source_task_id [String] ID of the completed TextToVideo or ExtendVideo task to continue from
23
+ # @param prompt [String] prompt describing the continuation footage
24
+ # @param output_resolution [String] must match the resolution of the source task ("720p" or "1080p")
25
+ # @param watermark [String, nil] watermark text burned into the output
26
+ # @param callback_url [String, nil] webhook URL for completion notification
27
+ # @return [RunApi::Runway::Types::CompletedTaskResponse] completed task with videos
28
+ def run(options: nil, **params)
29
+ task = create(options: options, **params)
30
+ poll_until_complete { get(task.id, options: options) }
20
31
  end
21
32
 
22
- def create(**params)
33
+ # Create an extend-video task without waiting for completion.
34
+ #
35
+ # @param params [Hash] extend-video parameters (see {#run} for details)
36
+ # @return [RunApi::Runway::Types::TaskCreateResponse] task creation result with id
37
+ def create(options: nil, **params)
23
38
  params = compact_params(params)
24
- validate_params!(params)
25
- request(:post, ENDPOINT, body: params)
39
+ validate_contract!(CONTRACT["extend-video"], params.merge(model: MODEL))
40
+ request(:post, ENDPOINT, body: params, options: options)
26
41
  end
27
42
 
28
- def get(id)
29
- request(:get, "#{ENDPOINT}/#{id}")
30
- end
31
-
32
- private
33
-
34
- def validate_params!(params)
35
- raise Core::ValidationError, "source_task_id is required" unless param(params, :source_task_id)
36
- raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
37
- raise Core::ValidationError, "output_resolution is required" unless param(params, :output_resolution)
38
- validate_optional!(params, :output_resolution, Types::OUTPUT_RESOLUTIONS)
43
+ # Get extend-video task status by task ID.
44
+ #
45
+ # @param id [String] task ID
46
+ # @return [RunApi::Runway::Types::TaskResponse] current task status
47
+ def get(id, options: nil)
48
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
39
49
  end
40
50
  end
41
51
  end
@@ -3,40 +3,51 @@
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
 
9
11
  ENDPOINT = "/api/v1/runway/text_to_video"
10
12
  RESPONSE_CLASS = Types::TaskCreateResponse
11
13
  COMPLETED_RESPONSE_CLASS = Types::CompletedTaskResponse
14
+ MODEL = "runway"
12
15
 
13
16
  def initialize(http)
14
17
  @http = http
15
18
  end
16
19
 
17
- def run(**params)
18
- task = create(**params)
19
- poll_until_complete { get(task.id) }
20
+ # Create a text-to-video task and wait until complete.
21
+ #
22
+ # @param prompt [String] video description prompt
23
+ # @param duration_seconds [Integer] video length: 5 or 10
24
+ # @param output_resolution [String] "720p" or "1080p"
25
+ # @param first_frame_image_url [String, nil] opening frame image URL for image-to-video
26
+ # @param aspect_ratio [String, nil] only for pure text-to-video (no first-frame image)
27
+ # @param watermark [String, nil] watermark text burned into the output
28
+ # @param callback_url [String, nil] webhook URL for completion notification
29
+ # @return [RunApi::Runway::Types::CompletedTaskResponse] completed task with videos
30
+ def run(options: nil, **params)
31
+ task = create(options: options, **params)
32
+ poll_until_complete { get(task.id, options: options) }
20
33
  end
21
34
 
22
- def create(**params)
35
+ # Create a text-to-video task without waiting for completion.
36
+ #
37
+ # @param params [Hash] text-to-video parameters (see {#run} for details)
38
+ # @return [RunApi::Runway::Types::TaskCreateResponse] task creation result with id
39
+ def create(options: nil, **params)
23
40
  params = compact_params(params)
24
- validate_params!(params)
25
- request(:post, ENDPOINT, body: params)
41
+ validate_contract!(CONTRACT["text-to-video"], params.merge(model: MODEL))
42
+ request(:post, ENDPOINT, body: params, options: options)
26
43
  end
27
44
 
28
- def get(id)
29
- request(:get, "#{ENDPOINT}/#{id}")
30
- end
31
-
32
- private
33
-
34
- def validate_params!(params)
35
- raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
36
- raise Core::ValidationError, "duration_seconds is required" unless param(params, :duration_seconds)
37
- raise Core::ValidationError, "output_resolution is required" unless param(params, :output_resolution)
38
- validate_optional!(params, :output_resolution, Types::OUTPUT_RESOLUTIONS)
39
- validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
45
+ # Get text-to-video task status by task ID.
46
+ #
47
+ # @param id [String] task ID
48
+ # @return [RunApi::Runway::Types::TaskResponse] current task status
49
+ def get(id, options: nil)
50
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
40
51
  end
41
52
  end
42
53
  end
@@ -2,19 +2,20 @@
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
- OUTPUT_RESOLUTIONS = %w[720p 1080p].freeze
7
- ASPECT_RATIOS = %w[16:9 9:16 1:1 4:3 3:4].freeze
8
-
7
+ # A generated video file with a download URL.
9
8
  class Video < RunApi::Core::BaseModel
10
9
  optional :id, String
11
10
  required :url, String
12
11
  end
13
12
 
13
+ # A generated image file with a download URL.
14
14
  class Image < RunApi::Core::BaseModel
15
15
  required :url, String
16
16
  end
17
17
 
18
+ # Full task response returned by polling. Contains output media once the task completes.
18
19
  class TaskResponse < RunApi::Core::TaskResponse
19
20
  required :id, String
20
21
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
@@ -24,8 +25,11 @@ module RunApi
24
25
  optional :error, String
25
26
  end
26
27
 
28
+ # Response returned when a task is first created, before polling begins.
27
29
  class TaskCreateResponse < TaskResponse; end
28
30
 
31
+ # Narrowed response returned by +run()+ once polling observes completion.
32
+ # +videos+ is guaranteed present so consumers never need to null-check.
29
33
  class CompletedTaskResponse < TaskResponse
30
34
  required :videos, [-> { Video }]
31
35
  end
data/lib/runapi/runway.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "runway/types"
5
+ require_relative "runway/contract_gen"
5
6
  require_relative "runway/resources/text_to_video"
6
7
  require_relative "runway/resources/extend_video"
7
8
  require_relative "runway/client"
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.6
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.5
18
+ version: 0.3.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.2.5
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.
25
+ version: 0.3.0
26
+ description: The Runway Ruby SDK is the language-specific package for Runway on RunAPI.
27
+ Use this package for video generation, animation, and video editing workflows when
28
+ 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,6 +39,7 @@ files:
39
39
  - lib/runapi-runway.rb
40
40
  - lib/runapi/runway.rb
41
41
  - lib/runapi/runway/client.rb
42
+ - lib/runapi/runway/contract_gen.rb
42
43
  - lib/runapi/runway/resources/extend_video.rb
43
44
  - lib/runapi/runway/resources/text_to_video.rb
44
45
  - lib/runapi/runway/types.rb
@@ -46,9 +47,11 @@ homepage: https://runapi.ai/models/runway
46
47
  licenses:
47
48
  - Apache-2.0
48
49
  metadata:
50
+ runapi_slug: runway
49
51
  homepage_uri: https://runapi.ai/models/runway
50
52
  documentation_uri: https://github.com/runapi-ai/runway-sdk/blob/main/ruby/README.md
51
53
  source_code_uri: https://github.com/runapi-ai/runway-sdk
54
+ bug_tracker_uri: https://github.com/runapi-ai/runway-sdk/issues
52
55
  changelog_uri: https://github.com/runapi-ai/runway-sdk/blob/main/CHANGELOG.md
53
56
  rdoc_options: []
54
57
  require_paths:
@@ -64,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
67
  - !ruby/object:Gem::Version
65
68
  version: '0'
66
69
  requirements: []
67
- rubygems_version: 4.0.10
70
+ rubygems_version: 4.0.17
68
71
  specification_version: 4
69
- summary: Runway API Ruby SDK for RunAPI
72
+ summary: Runway Ruby SDK for RunAPI
70
73
  test_files: []