omnivideo-sdk 0.1.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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +75 -0
  4. data/lib/omnivideo_sdk.rb +149 -0
  5. metadata +51 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 15b1fd7e7feac50200fa166f9877f560c1f5ca88221071399b76dd444e6318e8
4
+ data.tar.gz: 394cebc000b84e1d7f52bac3ec4dff2f69a986963272dea7378baeef8bdcce52
5
+ SHA512:
6
+ metadata.gz: e8eb346898cd657e97f77bfb7b2c20993a3aa71529a278401aa2cdfcd7b055c2de81c0e0a287506e7a7b72da486c5a428049febe5210f7cf2e56869f22f7588b
7
+ data.tar.gz: 2276a07d746429d9529234a2859e6609d020b830ebe05d8796c9d1e78060f1061a2860e0d0cad0f7d3f02e357d59840c7220efa8c1814b4ce6ce8006a948b38d
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Omni Video
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # omnivideo-sdk (Ruby)
2
+
3
+ Ruby client for [Omni Video](https://omnivideo.net/) — generate video and image content with the **Gemini Omni Video** series of models.
4
+
5
+ [Omni Video](https://omnivideo.net/) hosts the Gemini Omni Video family (`seedance-2` for text/image → video, `gpt-image-2` and `nano-banana-2` for text/image → image) behind one simple REST API.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ gem install omnivideo-sdk
11
+ ```
12
+
13
+ Or in your Gemfile:
14
+
15
+ ```ruby
16
+ gem "omnivideo-sdk"
17
+ ```
18
+
19
+ ## Get an API key
20
+
21
+ Sign in at **<https://omnivideo.net/>**, open the account page, then create a `sk-…` token.
22
+
23
+ ```bash
24
+ export OMNIVIDEO_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
25
+ ```
26
+
27
+ ## Quick start
28
+
29
+ ```ruby
30
+ require "omnivideo_sdk"
31
+
32
+ client = OmnivideoSdk::Client.new # reads ENV["OMNIVIDEO_API_KEY"]
33
+
34
+ task = client.run(
35
+ model_id: "seedance-2",
36
+ prompt: "a serene zen garden at sunrise, ultra detailed",
37
+ aspect_ratio: "16:9"
38
+ )
39
+ puts task.output_url # video_url or image_url
40
+ ```
41
+
42
+ ### Lower level
43
+
44
+ ```ruby
45
+ task = client.create_task(
46
+ model_id: "gpt-image-2",
47
+ prompt: "cyberpunk corgi, neon rim light",
48
+ aspect_ratio: "1:1"
49
+ )
50
+
51
+ until task.done?
52
+ sleep 3
53
+ task = client.get_task(task.task_id)
54
+ end
55
+ puts task.image_url
56
+ ```
57
+
58
+ ## Models
59
+
60
+ | `model_id` | Modality | Output |
61
+ | --------------- | ------------------ | ----------- |
62
+ | `seedance-2` | text/image → video | `video_url` |
63
+ | `gpt-image-2` | text/image → image | `image_url` |
64
+ | `nano-banana-2` | text/image → image | `image_url` |
65
+
66
+ See current models and pricing on [omnivideo.net](https://omnivideo.net/).
67
+
68
+ ## Links
69
+
70
+ - Website & account: <https://omnivideo.net/>
71
+ - API docs: <https://omnivideo.net/api-docs>
72
+
73
+ ## License
74
+
75
+ MIT
@@ -0,0 +1,149 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "net/http"
5
+ require "uri"
6
+
7
+ # Omni Video Ruby SDK — generate video and image content with the Gemini Omni Video models.
8
+ # Sign in and create an API key at https://omnivideo.net/.
9
+ module OmnivideoSdk
10
+ VERSION = "0.1.0"
11
+ DEFAULT_BASE_URL = "https://omnivideo.net/api/v1"
12
+
13
+ module TaskStatus
14
+ QUEUED = 1
15
+ RUNNING = 2
16
+ SUCCESS = 3
17
+ FAILED = 4
18
+ end
19
+
20
+ class Error < StandardError
21
+ attr_reader :code, :status
22
+ def initialize(message, code: nil, status: nil)
23
+ super(message)
24
+ @code = code
25
+ @status = status
26
+ end
27
+ end
28
+
29
+ Task = Struct.new(:task_id, :task_status, :image_url, :video_url, :credits, :raw, keyword_init: true) do
30
+ def done?
31
+ [TaskStatus::SUCCESS, TaskStatus::FAILED].include?(task_status)
32
+ end
33
+
34
+ def output_url
35
+ video_url || image_url
36
+ end
37
+ end
38
+
39
+ class Client
40
+ attr_reader :api_key, :base_url, :timeout
41
+
42
+ def initialize(api_key: nil, base_url: DEFAULT_BASE_URL, timeout: 60)
43
+ @api_key = api_key || ENV["OMNIVIDEO_API_KEY"]
44
+ raise Error, "Missing API key. Pass api_key: or set OMNIVIDEO_API_KEY. Get one at https://omnivideo.net/" if @api_key.nil? || @api_key.empty?
45
+
46
+ @base_url = base_url.sub(%r{/+\z}, "")
47
+ @timeout = timeout
48
+ @http_factory = nil
49
+ end
50
+
51
+ # Inject a custom HTTP factory (lambda yielding an object responding to #request) — used in tests.
52
+ attr_accessor :http_factory
53
+
54
+ def create_task(model_id:, prompt:, image_urls: nil, aspect_ratio: nil, **extra)
55
+ body = { model_id: model_id, prompt: prompt }
56
+ body[:image_urls] = image_urls unless image_urls.nil?
57
+ body[:aspect_ratio] = aspect_ratio unless aspect_ratio.nil?
58
+ body.merge!(extra)
59
+ data = request(:post, "/tasks/create", body: body)
60
+ to_task(data)
61
+ end
62
+
63
+ def get_task(task_id)
64
+ data = request(:get, "/tasks/#{task_id}")
65
+ to_task(data)
66
+ end
67
+
68
+ def run(model_id:, prompt:, image_urls: nil, aspect_ratio: nil, poll_interval: 3.0, max_wait: 600.0, **extra)
69
+ task = create_task(model_id: model_id, prompt: prompt, image_urls: image_urls, aspect_ratio: aspect_ratio, **extra)
70
+ deadline = monotonic + max_wait
71
+ until task.done?
72
+ raise Error.new("Task #{task.task_id} did not finish within #{max_wait}s", code: task.task_status) if monotonic > deadline
73
+
74
+ sleep_for(poll_interval)
75
+ task = get_task(task.task_id)
76
+ end
77
+ raise Error.new("Task #{task.task_id} failed", code: TaskStatus::FAILED) if task.task_status == TaskStatus::FAILED
78
+
79
+ task
80
+ end
81
+
82
+ private
83
+
84
+ def request(method, path, body: nil)
85
+ uri = URI.parse("#{@base_url}#{path}")
86
+ req = case method
87
+ when :get then Net::HTTP::Get.new(uri)
88
+ when :post then Net::HTTP::Post.new(uri)
89
+ else raise ArgumentError, "unsupported method: #{method}"
90
+ end
91
+ req["Authorization"] = "Bearer #{@api_key}"
92
+ req["Accept"] = "application/json"
93
+ if body
94
+ req["Content-Type"] = "application/json"
95
+ req.body = JSON.dump(body)
96
+ end
97
+ response = http_for(uri).request(req)
98
+ handle(response, uri)
99
+ end
100
+
101
+ def handle(response, uri)
102
+ status = response.code.to_i
103
+ raise Error.new("Unauthorized — check your OMNIVIDEO_API_KEY (https://omnivideo.net/).", status: 401) if status == 401
104
+
105
+ payload =
106
+ begin
107
+ response.body.to_s.empty? ? {} : JSON.parse(response.body)
108
+ rescue JSON::ParserError => e
109
+ raise Error.new("Invalid JSON from #{uri}: #{response.body.to_s[0, 200]}", status: status), cause: e
110
+ end
111
+ unless (200..299).cover?(status)
112
+ raise Error.new(payload["msg"] || "HTTP #{status}", code: payload["code"], status: status)
113
+ end
114
+ if payload["code"] && payload["code"] != 200
115
+ raise Error.new(payload["msg"] || "Business error", code: payload["code"])
116
+ end
117
+ payload
118
+ end
119
+
120
+ def http_for(uri)
121
+ return @http_factory.call(uri) if @http_factory
122
+
123
+ http = Net::HTTP.new(uri.host, uri.port)
124
+ http.use_ssl = uri.scheme == "https"
125
+ http.read_timeout = @timeout
126
+ http
127
+ end
128
+
129
+ def to_task(payload)
130
+ Task.new(
131
+ task_id: payload["task_id"].to_s,
132
+ task_status: payload["task_status"] || TaskStatus::QUEUED,
133
+ image_url: payload["image_url"],
134
+ video_url: payload["video_url"],
135
+ credits: payload["credits"],
136
+ raw: payload
137
+ )
138
+ end
139
+
140
+ def monotonic
141
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
142
+ end
143
+
144
+ # Hookable for tests.
145
+ def sleep_for(seconds)
146
+ sleep(seconds)
147
+ end
148
+ end
149
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omnivideo-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Omni Video
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-05-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Tiny Ruby client for the Omni Video API. Supports seedance-2 (video)
14
+ and gpt-image-2 / nano-banana-2 (image) under the Gemini Omni Video family. Sign
15
+ in and create a key at https://omnivideo.net/.
16
+ email:
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE
22
+ - README.md
23
+ - lib/omnivideo_sdk.rb
24
+ homepage: https://omnivideo.net/
25
+ licenses:
26
+ - MIT
27
+ metadata:
28
+ homepage_uri: https://omnivideo.net/
29
+ documentation_uri: https://omnivideo.net/api-docs
30
+ source_code_uri: https://omnivideo.net/
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '2.7'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubygems_version: 3.0.3.1
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Omni Video Ruby SDK — generate video and image content with the Gemini Omni
50
+ Video series of models.
51
+ test_files: []