runapi-gemini-omni 0.3.6 → 0.5.0

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: ab5cbb8ef2a16e8456e1144bcfb0e5fa8b0046d270b503de11d8986d588e5937
4
- data.tar.gz: 6e7fa7299744b50849e91931fa421ffd3d0c71e6f0e755be26cd2ba9df9bdfb6
3
+ metadata.gz: b05713bdf95910a00d248eac8bcc121c34bb94a00cbedc7246fc6277c09c2372
4
+ data.tar.gz: 1758ba10f4e165e2f7f2687cae0f8cbdbbfbe4eb1949100810c5425b49cc1b66
5
5
  SHA512:
6
- metadata.gz: 2685b0619dcac122d0b6a6eb987fbb924645b09d180d4810c7fd0fcd5a6aafc9e1487ab7dd93b66c20a12e928d858e320facbba24e5e21c1a67b7b259ad5680a
7
- data.tar.gz: 1f58bb3b0a5cd62e492cdbb4e652bee93848a79d74223b07fb402a1f6eedb32ce65b04d1d04007968c7fb841d3bc682a67f0902702c5e2249877e6c4292f8eb2
6
+ metadata.gz: c991128c2ee5f8bc738a354897524de6ce804149bf1b407a208d87d726af580897cc526478c5788d73d159b37fdfe273877de25805de24cb435cbacaece23e11
7
+ data.tar.gz: 144ac7e23e719a1de28afd8cdf14cca0f4c9882dd9095d759d0f330f7eb63891343f23be971e94f26eb0f50fc291ba4f135bbc3542c284312c0485b36c832354
data/README.md CHANGED
@@ -36,12 +36,30 @@ video = client.text_to_video.run(
36
36
  )
37
37
  ```
38
38
 
39
- `character.images` returns the portrait first and the optional full-body image second. A character created with both references consumes two of the seven reference units in a multimodal video request.
39
+ `character.images` returns the portrait first and the optional full-body image second. For Flash 1.1 and the original text-to-video model, a character created with both references consumes two of the seven reference units.
40
40
 
41
41
  For `gemini-omni-flash-1-1`, `first_frame_image_url` cannot be combined with reference images, audio IDs, video clips, or character IDs. `last_frame_image_url` requires `first_frame_image_url`.
42
42
 
43
43
  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.
44
44
 
45
+ ## Flash 1.2 generation and continuation
46
+
47
+ Flash 1.2 uses `model=gemini-omni-flash-1-2` and an integer `duration_seconds` from 3 through 15 for generation. Omit `duration_seconds` when editing with `reference_video_urls`; output duration follows the source video. When supplying both first and last frames, generation accepts 3 through 10 seconds. It accepts `reference_image_urls` with up to 6 images and `reference_video_urls` with up to 1 video. Images count as one reference slot and a video counts as two, with at most 7 slots total. Up to 2 account-owned `character_ids` consume no reference slots. Frame inputs cannot accompany reference inputs or characters. `aspect_ratio` also accepts `auto`, and `seed` is an integer from 10000 through 99999.
48
+
49
+ Continuation uses a completed Flash 1.2 generation or continuation task owned by your account. The source must be at most 15 seconds long at 360p or 720p. `duration_seconds` adds 3 through 10 seconds, and `reference_image_urls` accepts up to 3 images. The result contains the full original video plus the added segment. Retrieve its status with the continuation resource's `get` method.
50
+
51
+ ```ruby
52
+ source = client.text_to_video.run(
53
+ model: "gemini-omni-flash-1-2", prompt: "A paper airplane glides across a studio",
54
+ duration_seconds: 7, output_resolution: "720p"
55
+ )
56
+ continued = client.extend_video.run(
57
+ model: "gemini-omni-flash-1-2", source_task_id: source.id,
58
+ prompt: "Follow the airplane to the window", duration_seconds: 3
59
+ )
60
+ ```
61
+
62
+
45
63
  ## Links
46
64
 
47
65
  - Model page: https://runapi.ai/models/gemini-omni
@@ -21,12 +21,13 @@ module RunApi
21
21
  # @return [Resources::CreateCharacter] Builds reusable characters and follows accepted Tasks to completion.
22
22
  attr_reader :create_character
23
23
  # @return [Resources::TextToVideo] Generates video from prompts with optional characters and voices (async).
24
- attr_reader :text_to_video
24
+ attr_reader :text_to_video, :extend_video
25
25
 
26
26
  def initialize(api_key: nil, **options)
27
27
  super
28
28
  @create_audio = Resources::CreateAudio.new(http)
29
29
  @create_character = Resources::CreateCharacter.new(http)
30
+ @extend_video = Resources::ExtendVideo.new(http)
30
31
  @text_to_video = Resources::TextToVideo.new(http)
31
32
  end
32
33
  end
@@ -11,9 +11,6 @@ module RunApi
11
11
  ENDPOINT = "/api/v1/gemini_omni/create_audio"
12
12
  RESPONSE_CLASS = Types::CreateAudioResponse
13
13
  MODEL = "gemini-omni-audio"
14
- NAME_MAX_LENGTH = 210
15
- VOICE_DESCRIPTION_MAX_LENGTH = 20_000
16
- EXAMPLE_DIALOGUE_MAX_LENGTH = 120
17
14
 
18
15
  def initialize(http)
19
16
  @http = http
@@ -21,25 +18,8 @@ module RunApi
21
18
 
22
19
  def run(options: nil, **params)
23
20
  params = compact_params(params)
24
- validate_params!(params)
25
21
  request(:post, ENDPOINT, body: params, options: options)
26
22
  end
27
-
28
- private
29
-
30
- def validate_params!(params)
31
- validate_contract!(CONTRACT["create-audio"], params.merge(model: MODEL))
32
- validate_length!(params, :name, NAME_MAX_LENGTH)
33
- validate_length!(params, :voice_description, VOICE_DESCRIPTION_MAX_LENGTH)
34
- validate_length!(params, :example_dialogue, EXAMPLE_DIALOGUE_MAX_LENGTH)
35
- end
36
-
37
- def validate_length!(params, key, max_length)
38
- value = param(params, key)
39
- return if value.nil? || value.to_s.length <= max_length
40
-
41
- raise Core::ValidationError, "#{key} must be at most #{max_length} characters"
42
- end
43
23
  end
44
24
  end
45
25
  end
@@ -12,8 +12,6 @@ module RunApi
12
12
  ENDPOINT = "/api/v1/gemini_omni/create_character"
13
13
  RESPONSE_CLASS = Types::CreateCharacterResponse
14
14
  MODEL = "gemini-omni-character"
15
- DESCRIPTIONS_MAX_LENGTH = 20_000
16
- CHARACTER_NAME_MAX_LENGTH = 210
17
15
 
18
16
  def initialize(http)
19
17
  @http = http
@@ -21,31 +19,8 @@ module RunApi
21
19
 
22
20
  def run(options: nil, **params)
23
21
  params = compact_params(params)
24
- validate_params!(params)
25
22
  run_hybrid(ENDPOINT, body: params, options: options, response_class: RESPONSE_CLASS)
26
23
  end
27
-
28
- private
29
-
30
- def validate_params!(params)
31
- validate_contract!(CONTRACT["create-character"], params.merge(model: MODEL))
32
- validate_array!(params, :audio_ids) if param(params, :audio_ids)
33
- validate_length!(params, :descriptions, DESCRIPTIONS_MAX_LENGTH)
34
- validate_length!(params, :character_name, CHARACTER_NAME_MAX_LENGTH)
35
- end
36
-
37
- def validate_array!(params, key)
38
- return if param(params, key).is_a?(Array)
39
-
40
- raise Core::ValidationError, "#{key} must be an array"
41
- end
42
-
43
- def validate_length!(params, key, max_length)
44
- value = param(params, key)
45
- return if value.nil? || value.to_s.length <= max_length
46
-
47
- raise Core::ValidationError, "#{key} must be at most #{max_length} characters"
48
- end
49
24
  end
50
25
  end
51
26
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module GeminiOmni
5
+ module Resources
6
+ # Continues a completed Flash 1.2 task and returns the full combined video.
7
+ # Async -- use +run+ for automatic polling or +create+/+get+ for manual control.
8
+ class ExtendVideo
9
+ include RunApi::Core::ResourceHelpers
10
+
11
+ ENDPOINT = "/api/v1/gemini_omni/extend_video"
12
+ RESPONSE_CLASS = Types::TextToVideoResponse
13
+ COMPLETED_RESPONSE_CLASS = Types::CompletedTextToVideoResponse
14
+
15
+ def initialize(http)
16
+ @http = http
17
+ end
18
+
19
+ def run(options: nil, **params)
20
+ task = create(options: options, **params)
21
+ poll_until_complete { get(task.id, options: options) }
22
+ end
23
+
24
+ def create(options: nil, **params)
25
+ params = compact_params(params)
26
+ request(:post, ENDPOINT, body: params, options: options)
27
+ end
28
+
29
+ def get(id, options: nil)
30
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -13,10 +13,6 @@ module RunApi
13
13
  RESPONSE_CLASS = Types::TextToVideoResponse
14
14
  COMPLETED_RESPONSE_CLASS = Types::CompletedTextToVideoResponse
15
15
  DEFAULT_MODEL = "gemini-omni-text-to-video"
16
- PROMPT_MAX_LENGTH = 20_000
17
- REFERENCE_UNITS_MAX = 7
18
- VIDEO_REFERENCE_UNITS = 2
19
- MAX_TRIM_SECONDS = 10
20
16
 
21
17
  def initialize(http)
22
18
  @http = http
@@ -29,71 +25,12 @@ module RunApi
29
25
 
30
26
  def create(options: nil, **params)
31
27
  params = compact_params(params)
32
- validate_params!(params)
33
28
  request(:post, ENDPOINT, body: params, options: options)
34
29
  end
35
30
 
36
31
  def get(id, options: nil)
37
32
  request(:get, "#{ENDPOINT}/#{id}", options: options)
38
33
  end
39
-
40
- private
41
-
42
- def validate_params!(params)
43
- selected_model = param(params, :model)
44
- selected_model = DEFAULT_MODEL if selected_model.nil? || selected_model.to_s.empty?
45
- validate_contract!(CONTRACT["text-to-video"], params.merge(model: selected_model))
46
- validate_length!(params, :prompt, PROMPT_MAX_LENGTH)
47
- validate_video_list!(param(params, :video_list)) if param(params, :video_list)
48
- validate_reference_units!(params)
49
- validate_seed!(params)
50
- end
51
-
52
- def validate_length!(params, key, max_length)
53
- value = param(params, key)
54
- return if value.nil? || value.to_s.length <= max_length
55
-
56
- raise Core::ValidationError, "#{key} must be at most #{max_length} characters"
57
- end
58
-
59
- def validate_video_list!(items)
60
- items.each_with_index do |item, index|
61
- url = param(item, :url)
62
- raise Core::ValidationError, "video_list[#{index}].url is required" if url.nil? || url.to_s.empty?
63
-
64
- start_time = numeric_param(item, :start)
65
- end_time = numeric_param(item, :ends)
66
- raise Core::ValidationError, "video_list[#{index}] start and ends must be numbers" unless start_time && end_time
67
- raise Core::ValidationError, "video_list[#{index}].start must be 0 or greater" if start_time.negative?
68
- raise Core::ValidationError, "video_list[#{index}].ends must be greater than start" unless end_time > start_time
69
- if (end_time - start_time) > MAX_TRIM_SECONDS
70
- raise Core::ValidationError, "video_list[#{index}] trim range must be #{MAX_TRIM_SECONDS} seconds or less"
71
- end
72
- end
73
- end
74
-
75
- def validate_reference_units!(params)
76
- units = Array(param(params, :reference_image_urls)).count +
77
- (Array(param(params, :video_list)).count * VIDEO_REFERENCE_UNITS) +
78
- Array(param(params, :character_ids)).count
79
- return if units <= REFERENCE_UNITS_MAX
80
-
81
- raise Core::ValidationError, "reference_image_urls + video_list*2 + character_ids must use #{REFERENCE_UNITS_MAX} reference units or fewer"
82
- end
83
-
84
- def validate_seed!(params)
85
- value = param(params, :seed)
86
- return if value.nil?
87
-
88
- seed = Integer(value, exception: false)
89
- return if seed && Types::SEED_RANGE.cover?(seed)
90
-
91
- raise Core::ValidationError, "seed must be an integer between #{Types::SEED_RANGE.min} and #{Types::SEED_RANGE.max}"
92
- end
93
-
94
- def numeric_param(params, key)
95
- Float(param(params, key), exception: false)
96
- end
97
34
  end
98
35
  end
99
36
  end
@@ -44,9 +44,6 @@ module RunApi
44
44
  optional :error, String
45
45
  end
46
46
 
47
- # Valid seed range for reproducible generation.
48
- SEED_RANGE = (0..2_147_483_647)
49
-
50
47
  # URL to a generated video file.
51
48
  class Video < RunApi::Core::BaseModel
52
49
  optional :url, String
@@ -2,10 +2,10 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "gemini_omni/types"
5
- require_relative "gemini_omni/contract_gen"
6
5
  require_relative "gemini_omni/resources/create_audio"
7
6
  require_relative "gemini_omni/resources/create_character"
8
7
  require_relative "gemini_omni/resources/text_to_video"
8
+ require_relative "gemini_omni/resources/extend_video"
9
9
  require_relative "gemini_omni/client"
10
10
 
11
11
  module RunApi
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-gemini-omni
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.5.0
18
+ version: 0.6.1
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.5.0
25
+ version: 0.6.1
26
26
  description: The Gemini Omni Ruby SDK is the language-specific package for Gemini
27
27
  Omni on RunAPI. Use this package for voice resources, character resources, and multimodal
28
28
  video generation workflows when your application needs request bodies, task status
@@ -39,9 +39,9 @@ files:
39
39
  - lib/runapi-gemini_omni.rb
40
40
  - lib/runapi/gemini_omni.rb
41
41
  - lib/runapi/gemini_omni/client.rb
42
- - lib/runapi/gemini_omni/contract_gen.rb
43
42
  - lib/runapi/gemini_omni/resources/create_audio.rb
44
43
  - lib/runapi/gemini_omni/resources/create_character.rb
44
+ - lib/runapi/gemini_omni/resources/extend_video.rb
45
45
  - lib/runapi/gemini_omni/resources/text_to_video.rb
46
46
  - lib/runapi/gemini_omni/types.rb
47
47
  homepage: https://runapi.ai/models/gemini-omni
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  requirements: []
71
- rubygems_version: 4.0.17
71
+ rubygems_version: 4.0.10
72
72
  specification_version: 4
73
73
  summary: Gemini Omni Ruby SDK for RunAPI
74
74
  test_files: []
@@ -1,171 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RunApi
4
- module GeminiOmni
5
- CONTRACT = {
6
- "create-audio" => {
7
- "models" => ["gemini-omni-audio"],
8
- "fields_by_model" => {
9
- "gemini-omni-audio" => {
10
- "audio_id" => {
11
- "required" => true
12
- },
13
- "example_dialogue" => {
14
- "max" => 120,
15
- "length" => true
16
- },
17
- "name" => {
18
- "required" => true,
19
- "max" => 210,
20
- "length" => true
21
- },
22
- "voice_description" => {
23
- "max" => 20000,
24
- "length" => true
25
- }
26
- }
27
- }
28
- },
29
- "create-character" => {
30
- "models" => ["gemini-omni-character"],
31
- "fields_by_model" => {
32
- "gemini-omni-character" => {
33
- "character_name" => {
34
- "max" => 210,
35
- "length" => true
36
- },
37
- "descriptions" => {
38
- "required" => true,
39
- "max" => 20000,
40
- "length" => true
41
- },
42
- "reference_image_url" => {
43
- "required" => true
44
- }
45
- }
46
- }
47
- },
48
- "text-to-video" => {
49
- "models" => ["gemini-omni-flash-1-1", "gemini-omni-flash-preview", "gemini-omni-text-to-video"],
50
- "fields_by_model" => {
51
- "gemini-omni-flash-1-1" => {
52
- "aspect_ratio" => {
53
- "enum" => ["16:9", "9:16"]
54
- },
55
- "audio_ids" => {
56
- "max_items" => 3
57
- },
58
- "character_ids" => {
59
- "max_items" => 3
60
- },
61
- "duration_seconds" => {
62
- "enum" => [4, 6, 8, 10],
63
- "required" => true,
64
- "type" => "integer"
65
- },
66
- "output_resolution" => {
67
- "enum" => ["360p", "720p", "1080p", "4k"]
68
- },
69
- "prompt" => {
70
- "required" => true,
71
- "max" => 20000,
72
- "length" => true
73
- },
74
- "reference_image_urls" => {
75
- "max_items" => 7
76
- },
77
- "seed" => {
78
- "min" => 0,
79
- "max" => 2147483647,
80
- "type" => "integer"
81
- },
82
- "video_list" => {
83
- "max_items" => 1
84
- }
85
- },
86
- "gemini-omni-flash-preview" => {
87
- "aspect_ratio" => {
88
- "enum" => ["16:9", "9:16"]
89
- },
90
- "duration_seconds" => {
91
- "type" => "integer"
92
- },
93
- "output_resolution" => {
94
- "enum" => ["720p"]
95
- },
96
- "prompt" => {
97
- "required" => true,
98
- "max" => 20000,
99
- "length" => true
100
- },
101
- "seed" => {
102
- "type" => "integer"
103
- }
104
- },
105
- "gemini-omni-text-to-video" => {
106
- "aspect_ratio" => {
107
- "enum" => ["16:9", "9:16"]
108
- },
109
- "audio_ids" => {
110
- "max_items" => 3
111
- },
112
- "character_ids" => {
113
- "max_items" => 3
114
- },
115
- "duration_seconds" => {
116
- "enum" => [4, 6, 8, 10],
117
- "required" => true,
118
- "type" => "integer"
119
- },
120
- "output_resolution" => {
121
- "enum" => ["720p", "1080p", "4k"]
122
- },
123
- "prompt" => {
124
- "required" => true,
125
- "max" => 20000,
126
- "length" => true
127
- },
128
- "reference_image_urls" => {
129
- "max_items" => 7
130
- },
131
- "seed" => {
132
- "min" => 0,
133
- "max" => 2147483647,
134
- "type" => "integer"
135
- },
136
- "video_list" => {
137
- "max_items" => 1
138
- }
139
- }
140
- },
141
- "rules" => [{
142
- "when" => {
143
- "model" => "gemini-omni-flash-1-1",
144
- "first_frame_image_url" => {
145
- "present" => true
146
- }
147
- },
148
- "forbidden" => ["reference_image_urls", "audio_ids", "video_list", "character_ids"]
149
- }, {
150
- "when" => {
151
- "model" => "gemini-omni-flash-1-1",
152
- "last_frame_image_url" => {
153
- "present" => true
154
- }
155
- },
156
- "required" => ["first_frame_image_url"]
157
- }, {
158
- "when" => {
159
- "model" => "gemini-omni-flash-preview"
160
- },
161
- "forbidden" => ["reference_image_urls", "audio_ids", "video_list", "character_ids", "first_frame_image_url", "last_frame_image_url", "duration_seconds", "seed"]
162
- }, {
163
- "when" => {
164
- "model" => "gemini-omni-text-to-video"
165
- },
166
- "forbidden" => ["first_frame_image_url", "last_frame_image_url"]
167
- }]
168
- }
169
- }.freeze
170
- end
171
- end