runapi-veo-3.1 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c956acce113ea474bd15613081c7b4cdd3ffbb70959f78785a363c229f32886c
4
- data.tar.gz: 57321ad7e796c37e3da66b43621bc4ccc5fb3e9f30ee58fa60ce728d5fc9afba
3
+ metadata.gz: 5fa5bd7f269c8b608d55c11f90a388aa2df67624283c864c4f4a79c43e703b1c
4
+ data.tar.gz: 853aa5135a16d6ab5766a9057ac8e7417dd7a29f808a88a1ca21149d50552f67
5
5
  SHA512:
6
- metadata.gz: ca74a7c7b539f8e8fdf72471664641246e26e2bfd8c71299fc559dffe13603b2015e9da2117d9fe675ca378dce6469c85d3be3f00d464534561727e9f9397baa
7
- data.tar.gz: 74803c738d9042e439a6b7cea97719304231b6fd4cdb522117bbdc58b2ff6b932b9462a0a9706d97d152f35c547e3b7c7cbb4837f6ec63083d85f05fcbb72137
6
+ metadata.gz: ddb090ed8af4a5e887c50f7061e89e9bbe76ce5757e7d21e870f086eb9e5038aa39dceb9744cfec01b639c2b258a6fd8fa9a074ef551b3e2aee8f959293312bc
7
+ data.tar.gz: 4624572eea7ce421e622d7d852bf5f08e14d8af862835c6c5cdd5372b61f445f9cda40218125620633fe4c1f6213f77b2faf9dc2e6ffbaaf6c3a2bcc5ea7ce35
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Veo API Ruby SDK for RunAPI
2
+
3
+ The veo api Ruby SDK is the language-specific package for Veo 3 on RunAPI. Use this veo 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 veo api README is the Ruby package guide inside the public `veo3-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/veo-3.1; for API reference, use https://runapi.ai/docs#veo-3.1; for SDK docs, use https://runapi.ai/docs#sdk-veo-3.1.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ gem install runapi-veo3
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```ruby
16
+ require "runapi-veo3"
17
+
18
+ client = RunApi::Veo3::Client.new
19
+ task = client.generations.create(
20
+ # Pass the Veo 3 JSON request body from https://runapi.ai/docs#veo-3.1.
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::Veo3` error classes when building video jobs, Rails workers, or scripts. Text-to-video request bodies can include `duration` with `4`, `6`, or `8` seconds. The available resources include generations, extensions, hd1080p, and hd4k. 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/veo-3.1
36
+ - SDK docs: https://runapi.ai/docs#sdk-veo-3.1
37
+ - Product docs: https://runapi.ai/docs#veo-3.1
38
+ - Pricing and rate limits: https://runapi.ai/models/veo-3.1/veo-3.1
39
+ - Provider comparison: https://runapi.ai/providers/google
40
+ - Full catalog: https://runapi.ai/models
41
+ - Repository: https://github.com/runapi-ai/veo3-sdk
42
+
43
+ ## License
44
+
45
+ Licensed under the Apache License, Version 2.0.
@@ -9,17 +9,14 @@ module RunApi
9
9
  # result = client.text_to_video.run(
10
10
  # model: "veo-3.1-fast", prompt: "A drone shot over mountains at sunset"
11
11
  # )
12
- class Client
13
- # @return [Resources::TextToVideo] Text, image, and reference-to-video operations.
12
+ class Client < RunApi::Core::Client
13
+ # @return [Resources::TextToVideo] Text, image, and reference-image operations.
14
14
  # @return [Resources::ExtendVideo] Video extension operations.
15
15
  # @return [Resources::UpscaleVideo] Video upscaling operations.
16
16
  attr_reader :text_to_video, :extend_video, :upscale_video
17
17
 
18
18
  def initialize(api_key: nil, **options)
19
- @api_key = Core::Auth.resolve_api_key(api_key)
20
-
21
- client_options = Core::ClientOptions.new(api_key: @api_key, **options)
22
- http = client_options.http_client || Core::HttpClient.new(client_options)
19
+ super
23
20
  @text_to_video = Resources::TextToVideo.new(http)
24
21
  @extend_video = Resources::ExtendVideo.new(http)
25
22
  @upscale_video = Resources::UpscaleVideo.new(http)
@@ -4,6 +4,7 @@ module RunApi
4
4
  module Veo31
5
5
  module Resources
6
6
  # Veo 3.1 video extension resource.
7
+ # Append additional footage to a completed text-to-video or extend-video task.
7
8
  class ExtendVideo
8
9
  include RunApi::Core::ResourceHelpers
9
10
 
@@ -16,17 +17,29 @@ module RunApi
16
17
  @http = http
17
18
  end
18
19
 
20
+ # Extend a video and wait until complete.
21
+ #
22
+ # @param params [Hash] extend-video parameters (requires source_task_id and prompt)
23
+ # @return [RunApi::Veo31::Types::CompletedExtendVideoResponse] completed task with videos
19
24
  def run(**params)
20
25
  task = create(**params)
21
26
  poll_until_complete { get(task.id) }
22
27
  end
23
28
 
29
+ # Create a video extension task without waiting.
30
+ #
31
+ # @param params [Hash] extend-video parameters
32
+ # @return [RunApi::Veo31::Types::ExtendVideoResponse] task creation result with id
24
33
  def create(**params)
25
34
  params = compact_params(params)
26
35
  validate_params!(params)
27
36
  request(:post, ENDPOINT, body: params)
28
37
  end
29
38
 
39
+ # Get video extension task status by task ID.
40
+ #
41
+ # @param id [String] task ID
42
+ # @return [RunApi::Veo31::Types::ExtendVideoResponse] current task status
30
43
  def get(id)
31
44
  request(:get, "#{ENDPOINT}/#{id}")
32
45
  end
@@ -34,7 +47,7 @@ module RunApi
34
47
  private
35
48
 
36
49
  def validate_params!(params)
37
- raise Core::ValidationError, "task_id is required" unless params[:task_id] || params["task_id"]
50
+ raise Core::ValidationError, "source_task_id is required" unless params[:source_task_id] || params["source_task_id"]
38
51
  raise Core::ValidationError, "prompt is required" unless params[:prompt] || params["prompt"]
39
52
  end
40
53
  end
@@ -4,6 +4,7 @@ module RunApi
4
4
  module Veo31
5
5
  module Resources
6
6
  # Veo 3.1 text-to-video resource.
7
+ # Generate video from text, first/last frame images, or 1-3 reference images.
7
8
  class TextToVideo
8
9
  include RunApi::Core::ResourceHelpers
9
10
 
@@ -16,17 +17,29 @@ module RunApi
16
17
  @http = http
17
18
  end
18
19
 
20
+ # Generate a video and wait until complete.
21
+ #
22
+ # @param params [Hash] text-to-video parameters
23
+ # @return [RunApi::Veo31::Types::CompletedTextToVideoResponse] completed task with videos
19
24
  def run(**params)
20
25
  task = create(**params)
21
26
  poll_until_complete { get(task.id) }
22
27
  end
23
28
 
29
+ # Create a text-to-video task without waiting.
30
+ #
31
+ # @param params [Hash] text-to-video parameters
32
+ # @return [RunApi::Veo31::Types::TextToVideoResponse] task creation result with id
24
33
  def create(**params)
25
34
  params = compact_params(params)
26
35
  validate_params!(params)
27
36
  request(:post, ENDPOINT, body: params)
28
37
  end
29
38
 
39
+ # Get text-to-video task status by task ID.
40
+ #
41
+ # @param id [String] task ID
42
+ # @return [RunApi::Veo31::Types::TextToVideoResponse] current task status
30
43
  def get(id)
31
44
  request(:get, "#{ENDPOINT}/#{id}")
32
45
  end
@@ -43,38 +56,61 @@ module RunApi
43
56
  end
44
57
 
45
58
  validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
46
- validate_optional!(params, :generation_type, Types::GENERATION_TYPES)
59
+ validate_optional!(params, :input_mode, Types::INPUT_MODES)
60
+ validate_duration!(params)
47
61
 
48
- validate_generation_type!(params)
62
+ validate_input_mode!(params)
49
63
  end
50
64
 
51
- def validate_generation_type!(params)
52
- gen_type = param(params, :generation_type)
53
- return unless gen_type
65
+ def validate_duration!(params)
66
+ duration_seconds = param(params, :duration_seconds)
67
+ return unless duration_seconds
68
+ return if Types::DURATIONS.include?(duration_seconds)
54
69
 
55
- case gen_type
56
- when "FIRST_AND_LAST_FRAMES_2_VIDEO"
57
- urls = param(params, :image_urls)
58
- raise Core::ValidationError, "image_urls is required for FIRST_AND_LAST_FRAMES_2_VIDEO" unless urls
59
- unless urls.is_a?(Array) && urls.length.between?(1, 2)
60
- raise Core::ValidationError, "image_urls must contain 1-2 items for FIRST_AND_LAST_FRAMES_2_VIDEO"
70
+ raise Core::ValidationError, "Invalid duration_seconds: #{duration_seconds}. Must be one of: #{Types::DURATIONS.join(", ")}"
71
+ end
72
+
73
+ def validate_input_mode!(params)
74
+ input_mode = param(params, :input_mode)
75
+ return unless input_mode
76
+
77
+ case input_mode
78
+ when "first_and_last_frames"
79
+ raise Core::ValidationError, "first_frame_image_url is required for first_and_last_frames" unless field_present?(params, :first_frame_image_url)
80
+ if field_present?(params, :reference_image_urls)
81
+ raise Core::ValidationError, "reference_image_urls requires input_mode reference"
61
82
  end
62
- when "REFERENCE_2_VIDEO"
63
- urls = param(params, :image_urls)
64
- raise Core::ValidationError, "image_urls is required for REFERENCE_2_VIDEO" unless urls
83
+ when "reference"
84
+ urls = param(params, :reference_image_urls)
85
+ raise Core::ValidationError, "reference_image_urls is required for reference" unless urls
65
86
  unless urls.is_a?(Array) && urls.length.between?(1, 3)
66
- raise Core::ValidationError, "image_urls must contain 1-3 items for REFERENCE_2_VIDEO"
87
+ raise Core::ValidationError, "reference_image_urls must contain 1-3 items for reference"
67
88
  end
68
89
  model = param(params, :model)
69
90
  unless model == "veo-3.1-fast"
70
- raise Core::ValidationError, "REFERENCE_2_VIDEO requires model veo-3.1-fast"
91
+ raise Core::ValidationError, "reference requires model veo-3.1-fast"
71
92
  end
72
93
  ar = param(params, :aspect_ratio)
73
94
  if ar && ar != "16:9"
74
- raise Core::ValidationError, "REFERENCE_2_VIDEO requires aspect_ratio 16:9"
95
+ raise Core::ValidationError, "reference requires aspect_ratio 16:9"
96
+ end
97
+ if field_present?(params, :first_frame_image_url) || field_present?(params, :last_frame_image_url)
98
+ raise Core::ValidationError, "first_frame_image_url and last_frame_image_url require input_mode first_and_last_frames"
99
+ end
100
+ else
101
+ if field_present?(params, :first_frame_image_url) || field_present?(params, :last_frame_image_url)
102
+ raise Core::ValidationError, "first_frame_image_url and last_frame_image_url require input_mode first_and_last_frames"
103
+ end
104
+ if field_present?(params, :reference_image_urls)
105
+ raise Core::ValidationError, "reference_image_urls requires input_mode reference"
75
106
  end
76
107
  end
77
108
  end
109
+
110
+ def field_present?(params, key)
111
+ value = param(params, key)
112
+ value.is_a?(Array) ? value.any? : !value.nil? && !value.to_s.empty?
113
+ end
78
114
  end
79
115
  end
80
116
  end
@@ -4,6 +4,7 @@ module RunApi
4
4
  module Veo31
5
5
  module Resources
6
6
  # Veo 3.1 video upscaling resource.
7
+ # Increase resolution of a completed text-to-video or extend-video task to 1080p or 4K.
7
8
  class UpscaleVideo
8
9
  include RunApi::Core::ResourceHelpers
9
10
 
@@ -16,17 +17,29 @@ module RunApi
16
17
  @http = http
17
18
  end
18
19
 
20
+ # Upscale a video and wait until complete.
21
+ #
22
+ # @param params [Hash] upscale parameters (requires source_task_id and output_resolution)
23
+ # @return [RunApi::Veo31::Types::CompletedUpscaleVideoResponse] completed task with videos
19
24
  def run(**params)
20
25
  task = create(**params)
21
26
  poll_until_complete { get(task.id) }
22
27
  end
23
28
 
29
+ # Create a video upscale task without waiting.
30
+ #
31
+ # @param params [Hash] upscale parameters
32
+ # @return [RunApi::Veo31::Types::UpscaleVideoResponse] task creation result with id
24
33
  def create(**params)
25
34
  params = compact_params(params)
26
35
  validate_params!(params)
27
36
  request(:post, ENDPOINT, body: params)
28
37
  end
29
38
 
39
+ # Get video upscale task status by task ID.
40
+ #
41
+ # @param id [String] task ID
42
+ # @return [RunApi::Veo31::Types::UpscaleVideoResponse] current task status
30
43
  def get(id)
31
44
  request(:get, "#{ENDPOINT}/#{id}")
32
45
  end
@@ -34,10 +47,10 @@ module RunApi
34
47
  private
35
48
 
36
49
  def validate_params!(params)
37
- raise Core::ValidationError, "task_id is required" unless params[:task_id] || params["task_id"]
38
- resolution = params[:target_resolution] || params["target_resolution"]
39
- unless Types::TARGET_RESOLUTIONS.include?(resolution)
40
- raise Core::ValidationError, "target_resolution must be one of: #{Types::TARGET_RESOLUTIONS.join(", ")}"
50
+ raise Core::ValidationError, "source_task_id is required" unless params[:source_task_id] || params["source_task_id"]
51
+ output_resolution = params[:output_resolution] || params["output_resolution"]
52
+ unless Types::OUTPUT_RESOLUTIONS.include?(output_resolution)
53
+ raise Core::ValidationError, "output_resolution must be one of: #{Types::OUTPUT_RESOLUTIONS.join(", ")}"
41
54
  end
42
55
  end
43
56
  end
@@ -2,47 +2,72 @@
2
2
 
3
3
  module RunApi
4
4
  module Veo31
5
+ # Type definitions and constants for Veo 3.1 video generation.
5
6
  module Types
7
+ # Model variants: veo-3.1 (full quality, higher fidelity) and veo-3.1-fast (low latency).
6
8
  MODELS = %w[veo-3.1 veo-3.1-fast].freeze
7
- TARGET_RESOLUTIONS = %w[1080p 4k].freeze
8
- GENERATION_TYPES = %w[TEXT_2_VIDEO FIRST_AND_LAST_FRAMES_2_VIDEO REFERENCE_2_VIDEO].freeze
9
+
10
+ # Upscale target resolutions: 1080p (1920x1080) or 4k (3840x2160, higher detail and cost).
11
+ OUTPUT_RESOLUTIONS = %w[1080p 4k].freeze
12
+
13
+ # Generation input modes: text (default), first_and_last_frames (frame images),
14
+ # or reference (1-3 reference images, fast model only, 16:9 only).
15
+ INPUT_MODES = %w[text first_and_last_frames reference].freeze
16
+
17
+ # Video aspect ratios: 16:9 landscape, 9:16 portrait, auto (crop based on input dimensions).
9
18
  ASPECT_RATIOS = %w[16:9 9:16 auto].freeze
10
19
 
20
+ # Allowed video durations in seconds.
21
+ DURATIONS = [4, 6, 8].freeze
22
+
23
+ # A generated video with its download URL and metadata.
11
24
  class Video < RunApi::Core::BaseModel
12
25
  optional :url, String
13
26
  optional :resolution, String
14
27
  optional :has_audio
15
28
  end
16
29
 
30
+ # An input source (original image or video) referenced by the task.
31
+ class Source < RunApi::Core::BaseModel
32
+ optional :url, String
33
+ end
34
+
17
35
  class AsyncTaskResponse < RunApi::Core::TaskResponse
18
36
  required :id, String
19
37
  optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
20
38
  end
21
39
 
22
40
  class TextToVideoResponse < AsyncTaskResponse
23
- optional :videos, [ -> { Video } ]
24
- optional :video, -> { Video }
41
+ optional :videos, [-> { Video }]
42
+ optional :sources, [-> { Source }]
25
43
  end
26
44
 
27
45
  class ExtendVideoResponse < AsyncTaskResponse
28
- optional :videos, [ -> { Video } ]
29
- optional :video, -> { Video }
46
+ optional :videos, [-> { Video }]
47
+ optional :sources, [-> { Source }]
30
48
  end
31
49
 
50
+ # Upscale task response. Includes the source task reference and optional media identifiers.
32
51
  class UpscaleVideoResponse < AsyncTaskResponse
33
- optional :video, -> { Video }
52
+ optional :source_task_id, String
53
+ optional :videos, [-> { Video }]
54
+ optional :sources, [-> { Source }]
55
+ optional :media_ids, [String]
34
56
  end
35
57
 
58
+ # Narrowed responses returned by +run()+ methods once polling observes
59
+ # +status: "completed"+. +videos+ is required so consumers never have to
60
+ # null-check it on a successful task.
36
61
  class CompletedTextToVideoResponse < TextToVideoResponse
37
- required :videos, [ -> { Video } ]
62
+ required :videos, [-> { Video }]
38
63
  end
39
64
 
40
65
  class CompletedExtendVideoResponse < ExtendVideoResponse
41
- required :videos, [ -> { Video } ]
66
+ required :videos, [-> { Video }]
42
67
  end
43
68
 
44
69
  class CompletedUpscaleVideoResponse < UpscaleVideoResponse
45
- required :video, -> { Video }
70
+ required :videos, [-> { Video }]
46
71
  end
47
72
  end
48
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-veo-3.1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
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.4
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.4
26
- description: RunAPI Veo 3 SDK for JavaScript, Ruby, and Go
25
+ version: 0.2.6
26
+ description: The veo api Ruby SDK is the language-specific package for Veo 3 on RunAPI.
27
+ Use this veo api package for text-to-video, image-to-video, video editing, and animation
28
+ flows when your application needs JSON request bodies, task status lookup, and consistent
29
+ 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-veo_3_1.rb
35
40
  - lib/runapi/veo_3_1.rb
36
41
  - lib/runapi/veo_3_1/client.rb
@@ -43,7 +48,7 @@ licenses:
43
48
  - Apache-2.0
44
49
  metadata:
45
50
  homepage_uri: https://runapi.ai/models/veo-3.1
46
- documentation_uri: https://github.com/runapi-ai/veo-3.1-sdk/blob/main/README.md
51
+ documentation_uri: https://github.com/runapi-ai/veo-3.1-sdk/blob/main/ruby/README.md
47
52
  source_code_uri: https://github.com/runapi-ai/veo-3.1-sdk
48
53
  changelog_uri: https://github.com/runapi-ai/veo-3.1-sdk/blob/main/CHANGELOG.md
49
54
  rdoc_options: []
@@ -62,5 +67,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
67
  requirements: []
63
68
  rubygems_version: 4.0.10
64
69
  specification_version: 4
65
- summary: Veo 3 API SDKs for JavaScript, Ruby, and Go on RunAPI.
70
+ summary: Veo API Ruby SDK for RunAPI
66
71
  test_files: []