runapi-imagen-4 0.2.6 → 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 +4 -4
- data/README.md +8 -8
- data/lib/runapi/imagen_4/contract_gen.rb +66 -0
- data/lib/runapi/imagen_4/resources/remix_image.rb +2 -13
- data/lib/runapi/imagen_4/resources/text_to_image.rb +5 -13
- data/lib/runapi/imagen_4/types.rb +0 -11
- data/lib/runapi/imagen_4.rb +1 -0
- metadata +11 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ea234432febf88c1855e89f392cd149536bbe684e53ff1925ae96cef7389860c
|
|
4
|
+
data.tar.gz: 01eaf089e6d251e3bb5c96c17b9f1a228bf8fca32869040796f1d961d42a96a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6192d061bdd620f15a8cf5436aaa2c53c6a0ec8a780650f10c92f46be7cc112a1398e6cb2769dca74f16df7b92bb3b4a53927fb6f77eb0075a2c4f978eb1ebca
|
|
7
|
+
data.tar.gz: 5cba0828fa53be275b8e835b310a163d1d6b7fce906f3579b9a0f43509724138d5c40e58887c3ee8c1c1dc73dff89bc1a61aaf3faee378c7ca0f86e1eba510de
|
data/README.md
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
# Imagen API Ruby SDK for RunAPI
|
|
1
|
+
# Imagen 4 API Ruby SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Imagen 4 Ruby SDK is the language-specific package for Imagen 4 on RunAPI. Use this package for image generation, image editing, and creative production workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Ruby.
|
|
4
4
|
|
|
5
|
-
This
|
|
5
|
+
This README is the Ruby package guide inside the public `imagen-4-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/imagen-4; for API reference, use https://runapi.ai/docs#imagen-4; for SDK docs, use https://runapi.ai/docs#sdk-imagen-4.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
gem install runapi-
|
|
10
|
+
gem install runapi-imagen-4
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
15
15
|
```ruby
|
|
16
|
-
require "runapi-
|
|
16
|
+
require "runapi-imagen-4"
|
|
17
17
|
|
|
18
18
|
client = RunApi::Imagen4::Client.new
|
|
19
|
-
task = client.
|
|
19
|
+
task = client.text_to_image.create(
|
|
20
20
|
# Pass the Imagen 4 JSON request body from https://runapi.ai/docs#imagen-4.
|
|
21
21
|
)
|
|
22
|
-
status = client.
|
|
22
|
+
status = client.text_to_image.get(task.id)
|
|
23
23
|
```
|
|
24
24
|
|
|
25
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.
|
|
@@ -28,7 +28,7 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
|
|
|
28
28
|
|
|
29
29
|
## Language notes
|
|
30
30
|
|
|
31
|
-
Use Ruby keyword arguments and the `RunApi::Imagen4` error classes when building image jobs, Rails workers, or scripts. The available resources
|
|
31
|
+
Use Ruby keyword arguments and the `RunApi::Imagen4` error classes when building image jobs, Rails workers, or scripts. The available resources are `text_to_image` and `remix_image`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
|
|
32
32
|
|
|
33
33
|
## Links
|
|
34
34
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RunApi
|
|
4
|
+
module Imagen4
|
|
5
|
+
CONTRACT = {
|
|
6
|
+
"remix-image" => {
|
|
7
|
+
"models" => ["imagen-4-pro-remix-image"],
|
|
8
|
+
"fields_by_model" => {
|
|
9
|
+
"imagen-4-pro-remix-image" => {
|
|
10
|
+
"aspect_ratio" => {
|
|
11
|
+
"enum" => ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9", "auto"]
|
|
12
|
+
},
|
|
13
|
+
"output_format" => {
|
|
14
|
+
"enum" => ["png", "jpg"]
|
|
15
|
+
},
|
|
16
|
+
"output_resolution" => {
|
|
17
|
+
"enum" => ["1k", "2k", "4k"]
|
|
18
|
+
},
|
|
19
|
+
"source_image_urls" => {
|
|
20
|
+
"required" => true
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"text-to-image" => {
|
|
26
|
+
"models" => ["imagen-4", "imagen-4-fast", "imagen-4-ultra"],
|
|
27
|
+
"fields_by_model" => {
|
|
28
|
+
"imagen-4" => {
|
|
29
|
+
"aspect_ratio" => {
|
|
30
|
+
"enum" => ["1:1", "16:9", "9:16", "3:4", "4:3"]
|
|
31
|
+
},
|
|
32
|
+
"output_count" => {
|
|
33
|
+
"type" => "integer"
|
|
34
|
+
},
|
|
35
|
+
"seed" => {
|
|
36
|
+
"type" => "integer"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"imagen-4-fast" => {
|
|
40
|
+
"aspect_ratio" => {
|
|
41
|
+
"enum" => ["1:1", "16:9", "9:16", "3:4", "4:3"]
|
|
42
|
+
},
|
|
43
|
+
"output_count" => {
|
|
44
|
+
"enum" => [1, 2, 3, 4],
|
|
45
|
+
"type" => "integer"
|
|
46
|
+
},
|
|
47
|
+
"seed" => {
|
|
48
|
+
"type" => "integer"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"imagen-4-ultra" => {
|
|
52
|
+
"aspect_ratio" => {
|
|
53
|
+
"enum" => ["1:1", "16:9", "9:16", "3:4", "4:3"]
|
|
54
|
+
},
|
|
55
|
+
"output_count" => {
|
|
56
|
+
"type" => "integer"
|
|
57
|
+
},
|
|
58
|
+
"seed" => {
|
|
59
|
+
"type" => "integer"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}.freeze
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -35,22 +35,11 @@ module RunApi
|
|
|
35
35
|
private
|
|
36
36
|
|
|
37
37
|
def validate_params!(params)
|
|
38
|
-
|
|
39
|
-
raise Core::ValidationError, "model is required" unless model
|
|
40
|
-
unless Types::REMIX_MODELS.include?(model)
|
|
41
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::REMIX_MODELS.join(", ")}"
|
|
42
|
-
end
|
|
43
|
-
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
38
|
+
validate_contract!(CONTRACT["remix-image"], params)
|
|
44
39
|
|
|
45
|
-
|
|
46
|
-
validate_optional!(params, :aspect_ratio, Types::PRO_ASPECT_RATIOS)
|
|
47
|
-
validate_optional!(params, :output_resolution, Types::OUTPUT_RESOLUTIONS)
|
|
48
|
-
validate_optional!(params, :output_format, Types::OUTPUT_FORMATS)
|
|
49
|
-
end
|
|
40
|
+
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
50
41
|
|
|
51
|
-
def validate_source_image_urls!(params)
|
|
52
42
|
urls = param(params, :source_image_urls)
|
|
53
|
-
raise Core::ValidationError, "source_image_urls is required" if urls.nil? || (urls.respond_to?(:empty?) && urls.empty?)
|
|
54
43
|
return unless urls.respond_to?(:size) && urls.size > SOURCE_IMAGE_URLS_MAX
|
|
55
44
|
|
|
56
45
|
raise Core::ValidationError, "source_image_urls supports up to #{SOURCE_IMAGE_URLS_MAX} images"
|
|
@@ -34,21 +34,13 @@ module RunApi
|
|
|
34
34
|
private
|
|
35
35
|
|
|
36
36
|
def validate_params!(params)
|
|
37
|
-
|
|
38
|
-
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
39
|
-
|
|
40
|
-
model = param(params, :model)
|
|
41
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be: #{Types::MODELS.join(", ")}" unless Types::MODELS.include?(model)
|
|
37
|
+
validate_contract!(CONTRACT["text-to-image"], params)
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def validate_text_params!(params, model)
|
|
47
|
-
validate_optional!(params, :aspect_ratio, Types::TEXT_ASPECT_RATIOS)
|
|
48
|
-
return unless param(params, :output_count)
|
|
39
|
+
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
if param(params, :output_count) && param(params, :model) != "imagen-4-fast"
|
|
42
|
+
raise Core::ValidationError, "output_count is only supported for imagen-4-fast"
|
|
43
|
+
end
|
|
52
44
|
end
|
|
53
45
|
end
|
|
54
46
|
end
|
|
@@ -6,17 +6,6 @@ module RunApi
|
|
|
6
6
|
# Text-to-image supports three quality tiers; remix accepts source images
|
|
7
7
|
# with extended aspect ratios, resolution, and format control.
|
|
8
8
|
module Types
|
|
9
|
-
TEXT_MODELS = %w[imagen-4 imagen-4-fast imagen-4-ultra].freeze
|
|
10
|
-
REMIX_MODELS = %w[imagen-4-pro-remix-image].freeze
|
|
11
|
-
MODELS = (TEXT_MODELS + REMIX_MODELS).freeze
|
|
12
|
-
TEXT_ASPECT_RATIOS = %w[1:1 16:9 9:16 3:4 4:3].freeze
|
|
13
|
-
# Extended aspect ratios for remix, including "auto" which infers from source images.
|
|
14
|
-
PRO_ASPECT_RATIOS = %w[1:1 2:3 3:2 3:4 4:3 4:5 5:4 9:16 16:9 21:9 auto].freeze
|
|
15
|
-
OUTPUT_RESOLUTIONS = %w[1k 2k 4k].freeze
|
|
16
|
-
OUTPUT_FORMATS = %w[png jpg].freeze
|
|
17
|
-
# Batch sizes for imagen-4-fast (the only model supporting multi-image output).
|
|
18
|
-
OUTPUT_COUNTS = [1, 2, 3, 4].freeze
|
|
19
|
-
|
|
20
9
|
# A generated image with its CDN URL and optional unprocessed origin URL.
|
|
21
10
|
class Image < RunApi::Core::BaseModel
|
|
22
11
|
optional :url, String
|
data/lib/runapi/imagen_4.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: runapi-imagen-4
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.7
|
|
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.
|
|
18
|
+
version: 0.2.7
|
|
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.
|
|
26
|
-
description: The
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
version: 0.2.7
|
|
26
|
+
description: The Imagen 4 Ruby SDK is the language-specific package for Imagen 4 on
|
|
27
|
+
RunAPI. Use this package for image generation, image editing, and creative production
|
|
28
|
+
workflows when your application needs request bodies, task status lookup, and consistent
|
|
29
|
+
RunAPI errors in Ruby.
|
|
30
30
|
email:
|
|
31
31
|
- contact@runapi.ai
|
|
32
32
|
executables: []
|
|
@@ -39,6 +39,7 @@ files:
|
|
|
39
39
|
- lib/runapi-imagen_4.rb
|
|
40
40
|
- lib/runapi/imagen_4.rb
|
|
41
41
|
- lib/runapi/imagen_4/client.rb
|
|
42
|
+
- lib/runapi/imagen_4/contract_gen.rb
|
|
42
43
|
- lib/runapi/imagen_4/resources/remix_image.rb
|
|
43
44
|
- lib/runapi/imagen_4/resources/text_to_image.rb
|
|
44
45
|
- lib/runapi/imagen_4/types.rb
|
|
@@ -46,9 +47,11 @@ homepage: https://runapi.ai/models/imagen-4
|
|
|
46
47
|
licenses:
|
|
47
48
|
- Apache-2.0
|
|
48
49
|
metadata:
|
|
50
|
+
runapi_slug: imagen-4
|
|
49
51
|
homepage_uri: https://runapi.ai/models/imagen-4
|
|
50
52
|
documentation_uri: https://github.com/runapi-ai/imagen-4-sdk/blob/main/ruby/README.md
|
|
51
53
|
source_code_uri: https://github.com/runapi-ai/imagen-4-sdk
|
|
54
|
+
bug_tracker_uri: https://github.com/runapi-ai/imagen-4-sdk/issues
|
|
52
55
|
changelog_uri: https://github.com/runapi-ai/imagen-4-sdk/blob/main/CHANGELOG.md
|
|
53
56
|
rdoc_options: []
|
|
54
57
|
require_paths:
|
|
@@ -66,5 +69,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
66
69
|
requirements: []
|
|
67
70
|
rubygems_version: 4.0.10
|
|
68
71
|
specification_version: 4
|
|
69
|
-
summary: Imagen API Ruby SDK for RunAPI
|
|
72
|
+
summary: Imagen 4 API Ruby SDK for RunAPI
|
|
70
73
|
test_files: []
|