omniflash-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 +74 -0
  4. data/lib/omniflash_sdk.rb +162 -0
  5. metadata +51 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 84399f2a33feab8225aa7595c6cdf64f509c0b3b2d89fdb33418b2f07440fb30
4
+ data.tar.gz: 7edb3db7f8899f7ea9c0315d2d1fede4a2d8a94edb7cfb7017117a08e0ea32e8
5
+ SHA512:
6
+ metadata.gz: fda2a6b5c1ffda0ddbcdd4c8c6facd78a98ebd46e2899f753bc8d216e82148e96c2d740836e38ada949b75941033bb0c37eda4666ead90581c73b85d88db625e
7
+ data.tar.gz: 3a919446aec3b43097e87493b710e6dc7408f61ba2dadc82ff6f51551305be1136f3ea1e9a8ebae27f8c5c6cee2608f34b074d115763da99ed7ac025ff711798
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Omni Flash
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,74 @@
1
+ # omniflash-sdk (Ruby)
2
+
3
+ Ruby client for [Gemini Omni Flash](https://omniflash.net/) — generate short video clips (with synchronized audio) and images using Google's **Gemini Omni Flash** family of models.
4
+
5
+ [Gemini Omni Flash](https://omniflash.net/) wraps the Omni Flash family (`seedance-2` for text/image → video + audio, `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 omniflash-sdk
11
+ ```
12
+
13
+ ```ruby
14
+ gem "omniflash-sdk"
15
+ ```
16
+
17
+ ## Get an API key
18
+
19
+ Sign in at **[Gemini Omni Flash](https://omniflash.net/)**, open the account page, then create a `sk-…` token.
20
+
21
+ ```bash
22
+ export OMNIFLASH_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
23
+ ```
24
+
25
+ ## Quick start
26
+
27
+ ```ruby
28
+ require "omniflash_sdk"
29
+
30
+ client = OmniflashSdk::Client.new # reads ENV["OMNIFLASH_API_KEY"]
31
+
32
+ task = client.run(
33
+ model_id: "seedance-2",
34
+ prompt: "a kettle whistles as steam rises, cozy kitchen, warm light",
35
+ aspect_ratio: "16:9"
36
+ )
37
+ puts task.video_url
38
+ puts task.audio_url # synchronized audio
39
+ ```
40
+
41
+ ### Lower level
42
+
43
+ ```ruby
44
+ task = client.create_task(
45
+ model_id: "gpt-image-2",
46
+ prompt: "cyberpunk corgi, neon rim light",
47
+ aspect_ratio: "1:1"
48
+ )
49
+
50
+ until task.done?
51
+ sleep 3
52
+ task = client.get_task(task.task_id)
53
+ end
54
+ puts task.image_url
55
+ ```
56
+
57
+ ## Models
58
+
59
+ | `model_id` | Modality | Output |
60
+ | --------------- | ------------------ | ----------------------- |
61
+ | `seedance-2` | text/image → video | `video_url` + `audio_url` |
62
+ | `gpt-image-2` | text/image → image | `image_url` |
63
+ | `nano-banana-2` | text/image → image | `image_url` |
64
+
65
+ See current models and pricing on [Gemini Omni Flash](https://omniflash.net/).
66
+
67
+ ## Links
68
+
69
+ - Website & account: [Gemini Omni Flash](https://omniflash.net/)
70
+ - API docs: <https://omniflash.net/api-docs>
71
+
72
+ ## License
73
+
74
+ MIT
@@ -0,0 +1,162 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "net/http"
5
+ require "uri"
6
+
7
+ # Omni Flash Ruby SDK — generate short videos (with synchronized audio) and images
8
+ # via the Gemini Omni Flash family of models.
9
+ # Sign in and create an API key at https://omniflash.net/.
10
+ module OmniflashSdk
11
+ VERSION = "0.1.0"
12
+ DEFAULT_BASE_URL = "https://omniflash.net/api/v1"
13
+
14
+ module TaskStatus
15
+ QUEUED = 1
16
+ RUNNING = 2
17
+ SUCCESS = 3
18
+ FAILED = 4
19
+ end
20
+
21
+ class Error < StandardError
22
+ attr_reader :code, :status
23
+ def initialize(message, code: nil, status: nil)
24
+ super(message)
25
+ @code = code
26
+ @status = status
27
+ end
28
+ end
29
+
30
+ Task = Struct.new(
31
+ :task_id, :task_status, :image_url, :video_url, :audio_url,
32
+ :request_id, :task_type, :model_id, :credits, :created_at, :raw,
33
+ keyword_init: true
34
+ ) do
35
+ def done?
36
+ [TaskStatus::SUCCESS, TaskStatus::FAILED].include?(task_status)
37
+ end
38
+
39
+ def output_url
40
+ video_url || image_url || audio_url
41
+ end
42
+ end
43
+
44
+ class Client
45
+ attr_reader :api_key, :base_url, :timeout
46
+ attr_accessor :http_factory
47
+
48
+ def initialize(api_key: nil, base_url: DEFAULT_BASE_URL, timeout: 60)
49
+ @api_key = api_key || ENV["OMNIFLASH_API_KEY"]
50
+ raise Error, "Missing API key. Pass api_key: or set OMNIFLASH_API_KEY. Get one at https://omniflash.net/" if @api_key.nil? || @api_key.empty?
51
+
52
+ @base_url = base_url.sub(%r{/+\z}, "")
53
+ @timeout = timeout
54
+ @http_factory = nil
55
+ end
56
+
57
+ def create_task(model_id:, prompt:, image_urls: nil, aspect_ratio: nil, **extra)
58
+ body = { model_id: model_id, prompt: prompt }
59
+ body[:image_urls] = image_urls unless image_urls.nil?
60
+ body[:aspect_ratio] = aspect_ratio unless aspect_ratio.nil?
61
+ body.merge!(extra)
62
+ data = request(:post, "/tasks/create", body: body)
63
+ Task.new(
64
+ task_id: (data["task_id"] || "").to_s,
65
+ task_status: TaskStatus::QUEUED,
66
+ request_id: data["request_id"],
67
+ credits: data["credits"],
68
+ raw: data
69
+ )
70
+ end
71
+
72
+ def get_task(task_id)
73
+ data = request(:get, "/tasks/#{task_id}")
74
+ task_from_data(data)
75
+ end
76
+
77
+ def run(model_id:, prompt:, image_urls: nil, aspect_ratio: nil, poll_interval: 3.0, max_wait: 600.0, **extra)
78
+ task = create_task(model_id: model_id, prompt: prompt, image_urls: image_urls, aspect_ratio: aspect_ratio, **extra)
79
+ deadline = monotonic + max_wait
80
+ until task.done?
81
+ raise Error.new("Task #{task.task_id} did not finish within #{max_wait}s", code: task.task_status) if monotonic > deadline
82
+
83
+ sleep_for(poll_interval)
84
+ task = get_task(task.task_id)
85
+ end
86
+ raise Error.new("Task #{task.task_id} failed", code: TaskStatus::FAILED) if task.task_status == TaskStatus::FAILED
87
+
88
+ task
89
+ end
90
+
91
+ private
92
+
93
+ def request(method, path, body: nil)
94
+ uri = URI.parse("#{@base_url}#{path}")
95
+ req = case method
96
+ when :get then Net::HTTP::Get.new(uri)
97
+ when :post then Net::HTTP::Post.new(uri)
98
+ else raise ArgumentError, "unsupported method: #{method}"
99
+ end
100
+ req["Authorization"] = "Bearer #{@api_key}"
101
+ req["Accept"] = "application/json"
102
+ if body
103
+ req["Content-Type"] = "application/json"
104
+ req.body = JSON.dump(body)
105
+ end
106
+ response = http_for(uri).request(req)
107
+ handle(response, uri)
108
+ end
109
+
110
+ def handle(response, uri)
111
+ status = response.code.to_i
112
+ raise Error.new("Unauthorized — check your OMNIFLASH_API_KEY (https://omniflash.net/).", status: 401) if status == 401
113
+
114
+ envelope =
115
+ begin
116
+ response.body.to_s.empty? ? {} : JSON.parse(response.body)
117
+ rescue JSON::ParserError => e
118
+ raise Error.new("Invalid JSON from #{uri}: #{response.body.to_s[0, 200]}", status: status), cause: e
119
+ end
120
+ unless (200..299).cover?(status)
121
+ raise Error.new(envelope["msg"] || "HTTP #{status}", code: envelope["code"], status: status)
122
+ end
123
+ if envelope["code"] && envelope["code"] != 200
124
+ raise Error.new(envelope["msg"] || "Business error", code: envelope["code"])
125
+ end
126
+ envelope["data"] || envelope
127
+ end
128
+
129
+ def http_for(uri)
130
+ return @http_factory.call(uri) if @http_factory
131
+
132
+ http = Net::HTTP.new(uri.host, uri.port)
133
+ http.use_ssl = uri.scheme == "https"
134
+ http.read_timeout = @timeout
135
+ http
136
+ end
137
+
138
+ def task_from_data(data)
139
+ Task.new(
140
+ task_id: (data["task_id"] || "").to_s,
141
+ task_status: data["task_status"] || TaskStatus::QUEUED,
142
+ image_url: data["image_url"],
143
+ video_url: data["video_url"],
144
+ audio_url: data["audio_url"],
145
+ request_id: data["request_id"],
146
+ task_type: data["task_type"],
147
+ model_id: data["model_id"],
148
+ credits: data["credits"],
149
+ created_at: data["created_at"],
150
+ raw: data
151
+ )
152
+ end
153
+
154
+ def monotonic
155
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
156
+ end
157
+
158
+ def sleep_for(seconds)
159
+ sleep(seconds)
160
+ end
161
+ end
162
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniflash-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Omni Flash
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-05-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Tiny Ruby client for the Omni Flash API. Supports seedance-2 (video +
14
+ audio) and gpt-image-2 / nano-banana-2 (image) under the Gemini Omni Flash family.
15
+ Sign in and create a key at https://omniflash.net/.
16
+ email:
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE
22
+ - README.md
23
+ - lib/omniflash_sdk.rb
24
+ homepage: https://omniflash.net/
25
+ licenses:
26
+ - MIT
27
+ metadata:
28
+ homepage_uri: https://omniflash.net/
29
+ documentation_uri: https://omniflash.net/api-docs
30
+ source_code_uri: https://omniflash.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 Flash Ruby SDK — generate short videos (with synchronized audio) and
50
+ images using the Gemini Omni Flash family of models.
51
+ test_files: []