runapi-gemini-omni 0.2.6 → 0.3.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: d7eeb20441c69a3760cb85713f6089a3945f0338f689977e4389e6cd61247536
4
- data.tar.gz: faeff081599dba899a2c097fa5ff24f9232abb6e36b93359f81e93c1ef5ad3d0
3
+ metadata.gz: 2ce28cbcd6a2e1ceeaa92132547c164196fc252f45991ef1806040d140637fc6
4
+ data.tar.gz: 19d8e45aa77191626e074d9aba1f93ac3e3749e9f257d850badcb221e648c803
5
5
  SHA512:
6
- metadata.gz: be6ba08cff48a8edbd3d7e5ec10e8363aca7c08f822798a4a6b1ed52bfba3f5a1fa4efc4c0854cf322c052a708c81f9bb4c233bd6df0e55598ca154a4dc25132
7
- data.tar.gz: c78fb526856111cd7b37206fcfdf324719b7375095ef1e2a47f79f668a6e7efc9048f8355aed37c01a1d729642603bc7d05d47dadba8fd755342c2960459e1c4
6
+ metadata.gz: ecb2027e247bbea97c967d597f9365451de272c8e571895e7abcec4f889130fc390c21f39021f5974672061279846d09c81b5c52d875afe8858bb7ff7b00ba31
7
+ data.tar.gz: 254fe608847cd99b86de64ee5dcc7ce83c1aba5101fac0cdb2fdfeaa836efa0b4f7bf9357224de0116e0303199ee25a86d1422d1cce6e923270cc2eb8cca5230
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Gemini Omni API Ruby SDK for RunAPI
1
+ # Gemini Omni Ruby SDK for RunAPI
2
2
 
3
- The gemini omni api Ruby SDK is the language-specific package for Gemini Omni on RunAPI. Use this package for voice resources, character resources, and multimodal video workflows that need JSON request bodies, task status lookup, and consistent RunAPI errors in Ruby.
3
+ The Gemini Omni Ruby SDK is the language-specific package for Gemini Omni on RunAPI. Use this package for voice resources, character resources, and multimodal video generation workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Ruby.
4
4
 
5
5
  ## Install
6
6
 
@@ -11,7 +11,7 @@ gem install runapi-gemini-omni
11
11
  ## Quick start
12
12
 
13
13
  ```ruby
14
- require "runapi-gemini_omni"
14
+ require "runapi/gemini_omni"
15
15
 
16
16
  client = RunApi::GeminiOmni::Client.new
17
17
  voice = client.create_audio.run(
@@ -21,23 +21,25 @@ voice = client.create_audio.run(
21
21
 
22
22
  character = client.create_character.run(
23
23
  descriptions: "A silver-haired cyberpunk guide",
24
- image_urls: ["https://file.runapi.ai/demo/character.png"]
24
+ reference_image_url: "https://cdn.runapi.ai/public/samples/reference-1.jpg"
25
25
  )
26
26
 
27
27
  video = client.text_to_video.run(
28
- prompt: "Create a neon city tracking shot with the character walking forward.",
29
- duration: "8",
30
- resolution: "1080p",
31
- character_ids: [character.id]
28
+ model: "gemini-omni-flash-preview",
29
+ prompt: "A paper airplane glides through a sunlit studio.",
30
+ aspect_ratio: "16:9",
31
+ output_resolution: "720p"
32
32
  )
33
33
  ```
34
34
 
35
+ 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.
36
+
35
37
  ## Links
36
38
 
37
39
  - Model page: https://runapi.ai/models/gemini-omni
38
40
  - SDK docs: https://runapi.ai/docs#sdk-gemini-omni
39
41
  - Product docs: https://runapi.ai/docs#gemini-omni
40
- - Pricing and rate limits: https://runapi.ai/models/gemini-omni
42
+ - Flash Preview pricing and rate limits: https://runapi.ai/models/gemini-omni/flash-preview
41
43
  - Provider comparison: https://runapi.ai/providers/google
42
44
  - Full catalog: https://runapi.ai/models
43
45
 
@@ -2,14 +2,29 @@
2
2
 
3
3
  module RunApi
4
4
  module GeminiOmni
5
- class Client
6
- attr_reader :create_audio, :create_character, :text_to_video
5
+ # Gemini Omni multimodal generation client for voice presets, character creation,
6
+ # and text-to-video with optional characters, audio voices, and reference media.
7
+ #
8
+ # @example
9
+ # client = RunApi::GeminiOmni::Client.new(api_key: "sk-...")
10
+ #
11
+ # audio = client.create_audio.run(audio_id: "zephyr", name: "Narrator")
12
+ # video = client.text_to_video.run(
13
+ # prompt: "A narrator walks through a futuristic city",
14
+ # duration_seconds: 6,
15
+ # audio_ids: [audio.audio.id]
16
+ # )
17
+ # puts video.videos.first.url
18
+ class Client < RunApi::Core::Client
19
+ # @return [Resources::CreateAudio] Registers reusable voice presets (synchronous).
20
+ attr_reader :create_audio
21
+ # @return [Resources::CreateCharacter] Builds reusable characters from reference images (synchronous).
22
+ attr_reader :create_character
23
+ # @return [Resources::TextToVideo] Generates video from prompts with optional characters and voices (async).
24
+ attr_reader :text_to_video
7
25
 
8
26
  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)
27
+ super
13
28
  @create_audio = Resources::CreateAudio.new(http)
14
29
  @create_character = Resources::CreateCharacter.new(http)
15
30
  @text_to_video = Resources::TextToVideo.new(http)
@@ -0,0 +1,81 @@
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
+ "name" => {
14
+ "required" => true
15
+ }
16
+ }
17
+ }
18
+ },
19
+ "create-character" => {
20
+ "models" => ["gemini-omni-character"],
21
+ "fields_by_model" => {
22
+ "gemini-omni-character" => {
23
+ "descriptions" => {
24
+ "required" => true
25
+ },
26
+ "reference_image_url" => {
27
+ "required" => true
28
+ }
29
+ }
30
+ }
31
+ },
32
+ "text-to-video" => {
33
+ "models" => ["gemini-omni-flash-preview", "gemini-omni-text-to-video"],
34
+ "fields_by_model" => {
35
+ "gemini-omni-flash-preview" => {
36
+ "aspect_ratio" => {
37
+ "enum" => ["16:9", "9:16"]
38
+ },
39
+ "duration_seconds" => {
40
+ "type" => "integer"
41
+ },
42
+ "output_resolution" => {
43
+ "enum" => ["720p"]
44
+ },
45
+ "prompt" => {
46
+ "required" => true
47
+ },
48
+ "seed" => {
49
+ "type" => "integer"
50
+ }
51
+ },
52
+ "gemini-omni-text-to-video" => {
53
+ "aspect_ratio" => {
54
+ "enum" => ["16:9", "9:16"]
55
+ },
56
+ "duration_seconds" => {
57
+ "enum" => [4, 6, 8, 10],
58
+ "required" => true,
59
+ "type" => "integer"
60
+ },
61
+ "output_resolution" => {
62
+ "enum" => ["720p", "1080p", "4k"]
63
+ },
64
+ "prompt" => {
65
+ "required" => true
66
+ },
67
+ "seed" => {
68
+ "type" => "integer"
69
+ }
70
+ }
71
+ },
72
+ "rules" => [{
73
+ "when" => {
74
+ "model" => "gemini-omni-flash-preview"
75
+ },
76
+ "forbidden" => ["reference_image_urls", "audio_ids", "video_list", "character_ids", "duration_seconds", "seed"]
77
+ }]
78
+ }
79
+ }.freeze
80
+ end
81
+ end
@@ -3,11 +3,14 @@
3
3
  module RunApi
4
4
  module GeminiOmni
5
5
  module Resources
6
+ # Registers a reusable voice preset from a built-in voice identity.
7
+ # Synchronous -- only +run+ is available (no create/get polling).
6
8
  class CreateAudio
7
9
  include RunApi::Core::ResourceHelpers
8
10
 
9
11
  ENDPOINT = "/api/v1/gemini_omni/create_audio"
10
12
  RESPONSE_CLASS = Types::CreateAudioResponse
13
+ MODEL = "gemini-omni-audio"
11
14
  NAME_MAX_LENGTH = 210
12
15
  VOICE_DESCRIPTION_MAX_LENGTH = 20_000
13
16
  EXAMPLE_DIALOGUE_MAX_LENGTH = 120
@@ -16,29 +19,21 @@ module RunApi
16
19
  @http = http
17
20
  end
18
21
 
19
- def run(**params)
22
+ def run(options: nil, **params)
20
23
  params = compact_params(params)
21
24
  validate_params!(params)
22
- request(:post, ENDPOINT, body: params)
25
+ request(:post, ENDPOINT, body: params, options: options)
23
26
  end
24
27
 
25
28
  private
26
29
 
27
30
  def validate_params!(params)
28
- validate_required!(params, :audio_id)
29
- validate_required!(params, :name)
31
+ validate_contract!(CONTRACT["create-audio"], params.merge(model: MODEL))
30
32
  validate_length!(params, :name, NAME_MAX_LENGTH)
31
33
  validate_length!(params, :voice_description, VOICE_DESCRIPTION_MAX_LENGTH)
32
34
  validate_length!(params, :example_dialogue, EXAMPLE_DIALOGUE_MAX_LENGTH)
33
35
  end
34
36
 
35
- def validate_required!(params, key)
36
- value = param(params, key)
37
- return if value.is_a?(String) ? !value.empty? : !value.nil?
38
-
39
- raise Core::ValidationError, "#{key} is required"
40
- end
41
-
42
37
  def validate_length!(params, key, max_length)
43
38
  value = param(params, key)
44
39
  return if value.nil? || value.to_s.length <= max_length
@@ -3,11 +3,15 @@
3
3
  module RunApi
4
4
  module GeminiOmni
5
5
  module Resources
6
+ # Builds a reusable character from a reference image and description.
7
+ # Attach audio IDs to give the character a specific voice.
8
+ # Synchronous -- only +run+ is available (no create/get polling).
6
9
  class CreateCharacter
7
10
  include RunApi::Core::ResourceHelpers
8
11
 
9
12
  ENDPOINT = "/api/v1/gemini_omni/create_character"
10
13
  RESPONSE_CLASS = Types::CreateCharacterResponse
14
+ MODEL = "gemini-omni-character"
11
15
  DESCRIPTIONS_MAX_LENGTH = 20_000
12
16
  CHARACTER_NAME_MAX_LENGTH = 210
13
17
 
@@ -15,34 +19,21 @@ module RunApi
15
19
  @http = http
16
20
  end
17
21
 
18
- def run(**params)
22
+ def run(options: nil, **params)
19
23
  params = compact_params(params)
20
24
  validate_params!(params)
21
- request(:post, ENDPOINT, body: params)
25
+ request(:post, ENDPOINT, body: params, options: options)
22
26
  end
23
27
 
24
28
  private
25
29
 
26
30
  def validate_params!(params)
27
- validate_required!(params, :descriptions)
28
- validate_required!(params, :reference_image_url)
31
+ validate_contract!(CONTRACT["create-character"], params.merge(model: MODEL))
29
32
  validate_array!(params, :audio_ids) if param(params, :audio_ids)
30
33
  validate_length!(params, :descriptions, DESCRIPTIONS_MAX_LENGTH)
31
34
  validate_length!(params, :character_name, CHARACTER_NAME_MAX_LENGTH)
32
35
  end
33
36
 
34
- def validate_required!(params, key)
35
- value = param(params, key)
36
- present = if value.is_a?(Array)
37
- value.any?
38
- else
39
- value.is_a?(String) ? !value.empty? : !value.nil?
40
- end
41
- return if present
42
-
43
- raise Core::ValidationError, "#{key} is required"
44
- end
45
-
46
37
  def validate_array!(params, key)
47
38
  return if param(params, key).is_a?(Array)
48
39
 
@@ -3,12 +3,16 @@
3
3
  module RunApi
4
4
  module GeminiOmni
5
5
  module Resources
6
+ # Generates video from a prompt with optional characters, audio voices,
7
+ # reference images, and source video clips.
8
+ # Async -- use +run+ for automatic polling or +create+/+get+ for manual control.
6
9
  class TextToVideo
7
10
  include RunApi::Core::ResourceHelpers
8
11
 
9
12
  ENDPOINT = "/api/v1/gemini_omni/text_to_video"
10
13
  RESPONSE_CLASS = Types::TextToVideoResponse
11
14
  COMPLETED_RESPONSE_CLASS = Types::CompletedTextToVideoResponse
15
+ DEFAULT_MODEL = "gemini-omni-text-to-video"
12
16
  PROMPT_MAX_LENGTH = 20_000
13
17
  REFERENCE_IMAGE_URLS_MAX = 7
14
18
  AUDIO_IDS_MAX = 3
@@ -22,30 +26,28 @@ module RunApi
22
26
  @http = http
23
27
  end
24
28
 
25
- def run(**params)
26
- task = create(**params)
27
- poll_until_complete { get(task.id) }
29
+ def run(options: nil, **params)
30
+ task = create(options: options, **params)
31
+ poll_until_complete { get(task.id, options: options) }
28
32
  end
29
33
 
30
- def create(**params)
34
+ def create(options: nil, **params)
31
35
  params = compact_params(params)
32
36
  validate_params!(params)
33
- request(:post, ENDPOINT, body: params)
37
+ request(:post, ENDPOINT, body: params, options: options)
34
38
  end
35
39
 
36
- def get(id)
37
- request(:get, "#{ENDPOINT}/#{id}")
40
+ def get(id, options: nil)
41
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
38
42
  end
39
43
 
40
44
  private
41
45
 
42
46
  def validate_params!(params)
43
- validate_required!(params, :prompt)
44
- validate_required!(params, :duration_seconds)
47
+ selected_model = param(params, :model)
48
+ selected_model = DEFAULT_MODEL if selected_model.nil? || selected_model.to_s.empty?
49
+ validate_contract!(CONTRACT["text-to-video"], params.merge(model: selected_model))
45
50
  validate_length!(params, :prompt, PROMPT_MAX_LENGTH)
46
- validate_optional!(params, :duration_seconds, Types::DURATIONS)
47
- validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
48
- validate_optional!(params, :output_resolution, Types::OUTPUT_RESOLUTIONS)
49
51
  validate_array!(params, :reference_image_urls, REFERENCE_IMAGE_URLS_MAX) if param(params, :reference_image_urls)
50
52
  validate_array!(params, :audio_ids, AUDIO_IDS_MAX) if param(params, :audio_ids)
51
53
  validate_array!(params, :video_list, VIDEO_LIST_MAX) if param(params, :video_list)
@@ -55,18 +57,6 @@ module RunApi
55
57
  validate_seed!(params)
56
58
  end
57
59
 
58
- def validate_required!(params, key)
59
- value = param(params, key)
60
- present = if value.is_a?(Array)
61
- value.any?
62
- else
63
- value.is_a?(String) ? !value.empty? : !value.nil?
64
- end
65
- return if present
66
-
67
- raise Core::ValidationError, "#{key} is required"
68
- end
69
-
70
60
  def validate_length!(params, key, max_length)
71
61
  value = param(params, key)
72
62
  return if value.nil? || value.to_s.length <= max_length
@@ -2,7 +2,9 @@
2
2
 
3
3
  module RunApi
4
4
  module GeminiOmni
5
+ # Type definitions and constants for the Gemini Omni API.
5
6
  module Types
7
+ # The 30 preset voice identities, each with distinct pitch, cadence, and personality.
6
8
  AUDIO_VOICES = %w[
7
9
  achernar achird algenib algieba alnilam aoede autonoe callirrhoe charon
8
10
  despina enceladus erinome fenrir gacrux iapetus kore laomedeia leda orus
@@ -10,46 +12,53 @@ module RunApi
10
12
  vindemiatrix zephyr zubenelgenubi
11
13
  ].freeze
12
14
 
15
+ # A created voice preset with its server-assigned ID.
13
16
  class Audio < RunApi::Core::BaseModel
14
17
  required :id, String
15
18
  optional :name, String
16
19
  end
17
20
 
21
+ # Result of a synchronous create-audio call.
18
22
  class CreateAudioResponse < RunApi::Core::BaseModel
19
23
  required :id, String
20
24
  optional :audio, -> { Audio }
21
25
  optional :error, String
22
26
  end
23
27
 
28
+ # URL to a generated or reference image.
24
29
  class Image < RunApi::Core::BaseModel
25
30
  optional :url, String
26
31
  end
27
32
 
33
+ # A created character with its ID, name, and reference images.
28
34
  class Character < RunApi::Core::BaseModel
29
35
  required :id, String
30
36
  optional :name, String
31
37
  optional :images, [-> { Image }]
32
38
  end
33
39
 
40
+ # Result of a synchronous create-character call.
34
41
  class CreateCharacterResponse < RunApi::Core::BaseModel
35
42
  required :id, String
36
43
  optional :character, -> { Character }
37
44
  optional :error, String
38
45
  end
39
46
 
40
- DURATIONS = [4, 6, 8, 10].freeze
41
- ASPECT_RATIOS = %w[16:9 9:16].freeze
42
- OUTPUT_RESOLUTIONS = %w[720p 1080p 4k].freeze
47
+ # Valid seed range for reproducible generation.
43
48
  SEED_RANGE = (0..2_147_483_647)
44
49
 
50
+ # URL to a generated video file.
45
51
  class Video < RunApi::Core::BaseModel
46
52
  optional :url, String
47
53
  end
48
54
 
55
+ # Async text-to-video task result with lifecycle status and generated videos.
49
56
  class TextToVideoResponse < RunApi::Core::TaskResponse
50
57
  optional :videos, [-> { Video }]
51
58
  end
52
59
 
60
+ # Narrowed response returned by +run+ once polling confirms completion.
61
+ # Videos are guaranteed present.
53
62
  class CompletedTextToVideoResponse < TextToVideoResponse
54
63
  required :videos, [-> { Video }]
55
64
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "gemini_omni/types"
5
+ require_relative "gemini_omni/contract_gen"
5
6
  require_relative "gemini_omni/resources/create_audio"
6
7
  require_relative "gemini_omni/resources/create_character"
7
8
  require_relative "gemini_omni/resources/text_to_video"
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.2.6
4
+ version: 0.3.0
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.2.13
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 gemini omni api Ruby SDK is the language-specific package for Gemini
25
+ version: 0.2.13
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
- video workflows that need JSON request bodies, task status lookup, and consistent
29
- RunAPI errors in Ruby.
28
+ video generation workflows when your application needs request bodies, task status
29
+ lookup, and consistent RunAPI errors in Ruby.
30
30
  email:
31
31
  - contact@runapi.ai
32
32
  executables: []
@@ -39,6 +39,7 @@ 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
42
43
  - lib/runapi/gemini_omni/resources/create_audio.rb
43
44
  - lib/runapi/gemini_omni/resources/create_character.rb
44
45
  - lib/runapi/gemini_omni/resources/text_to_video.rb
@@ -47,9 +48,11 @@ homepage: https://runapi.ai/models/gemini-omni
47
48
  licenses:
48
49
  - Apache-2.0
49
50
  metadata:
51
+ runapi_slug: gemini-omni
50
52
  homepage_uri: https://runapi.ai/models/gemini-omni
51
53
  documentation_uri: https://github.com/runapi-ai/gemini-omni-sdk/blob/main/ruby/README.md
52
54
  source_code_uri: https://github.com/runapi-ai/gemini-omni-sdk
55
+ bug_tracker_uri: https://github.com/runapi-ai/gemini-omni-sdk/issues
53
56
  changelog_uri: https://github.com/runapi-ai/gemini-omni-sdk/blob/main/CHANGELOG.md
54
57
  rdoc_options: []
55
58
  require_paths:
@@ -67,5 +70,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
70
  requirements: []
68
71
  rubygems_version: 4.0.10
69
72
  specification_version: 4
70
- summary: Gemini Omni API Ruby SDK for RunAPI
73
+ summary: Gemini Omni Ruby SDK for RunAPI
71
74
  test_files: []