runapi-nano-banana 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 +6 -6
- data/lib/runapi/nano_banana/contract_gen.rb +59 -0
- data/lib/runapi/nano_banana/resources/edit_image.rb +2 -9
- data/lib/runapi/nano_banana/resources/text_to_image.rb +2 -10
- data/lib/runapi/nano_banana/types.rb +0 -12
- data/lib/runapi/nano_banana.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: 832dd3e77b5049f32c247319b78e0a05b8c5c7d71c4cc0e16a1626011ba9248b
|
|
4
|
+
data.tar.gz: 23d94cd56e9f85984d903d7c8b4c9e1582e58614a48eae82d1f6bdbdcf5c0e1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba6d8452a6ddc1fcc6d700e20943f7cc454f9ebf653e50bdfef36365fd0bb8543e6b961b6400ed3943c6f1c1fc86eec9d9a5116c213ee8cf9338e1726e4f5d50
|
|
7
|
+
data.tar.gz: 127d62230b0d4c6a9c5f00fa3a38f49447426dba48299babc64c4ba6d697e5bcaa53b0be2c9fce803a1322eeac44d2cc12d61e0cfa2c9bd318125952fd0409cf
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Nano Banana
|
|
1
|
+
# Nano Banana Ruby SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Nano Banana Ruby SDK is the language-specific package for Nano Banana 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 `nano-banana-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/nano-banana; for API reference, use https://runapi.ai/docs#nano-banana; for SDK docs, use https://runapi.ai/docs#sdk-nano-banana.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -16,10 +16,10 @@ gem install runapi-nano-banana
|
|
|
16
16
|
require "runapi-nano-banana"
|
|
17
17
|
|
|
18
18
|
client = RunApi::NanoBanana::Client.new
|
|
19
|
-
task = client.
|
|
19
|
+
task = client.text_to_image.create(
|
|
20
20
|
# Pass the Nano Banana JSON request body from https://runapi.ai/docs#nano-banana.
|
|
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::NanoBanana` error classes when building image jobs, Rails workers, or scripts. The available resources
|
|
31
|
+
Use Ruby keyword arguments and the `RunApi::NanoBanana` error classes when building image jobs, Rails workers, or scripts. The available resources are `text_to_image` and `edit_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,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RunApi
|
|
4
|
+
module NanoBanana
|
|
5
|
+
CONTRACT = {
|
|
6
|
+
"edit-image" => {
|
|
7
|
+
"models" => ["nano-banana-edit"],
|
|
8
|
+
"fields_by_model" => {
|
|
9
|
+
"nano-banana-edit" => {
|
|
10
|
+
"aspect_ratio" => {
|
|
11
|
+
"enum" => ["1:1", "9:16", "16:9", "3:4", "4:3", "3:2", "2:3", "5:4", "4:5", "21:9", "auto"]
|
|
12
|
+
},
|
|
13
|
+
"output_format" => {
|
|
14
|
+
"enum" => ["png", "jpeg"]
|
|
15
|
+
},
|
|
16
|
+
"source_image_urls" => {
|
|
17
|
+
"required" => true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"text-to-image" => {
|
|
23
|
+
"models" => ["nano-banana", "nano-banana-2", "nano-banana-pro"],
|
|
24
|
+
"fields_by_model" => {
|
|
25
|
+
"nano-banana" => {
|
|
26
|
+
"aspect_ratio" => {
|
|
27
|
+
"enum" => ["1:1", "9:16", "16:9", "3:4", "4:3", "3:2", "2:3", "5:4", "4:5", "21:9", "auto"]
|
|
28
|
+
},
|
|
29
|
+
"output_format" => {
|
|
30
|
+
"enum" => ["png", "jpeg", "jpg"]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"nano-banana-2" => {
|
|
34
|
+
"aspect_ratio" => {
|
|
35
|
+
"enum" => ["1:1", "1:4", "1:8", "2:3", "3:2", "3:4", "4:1", "4:3", "4:5", "5:4", "8:1", "9:16", "16:9", "21:9", "auto"]
|
|
36
|
+
},
|
|
37
|
+
"output_format" => {
|
|
38
|
+
"enum" => ["png", "jpeg", "jpg"]
|
|
39
|
+
},
|
|
40
|
+
"output_resolution" => {
|
|
41
|
+
"enum" => ["1k", "2k", "4k"]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"nano-banana-pro" => {
|
|
45
|
+
"aspect_ratio" => {
|
|
46
|
+
"enum" => ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9", "auto"]
|
|
47
|
+
},
|
|
48
|
+
"output_format" => {
|
|
49
|
+
"enum" => ["png", "jpeg", "jpg"]
|
|
50
|
+
},
|
|
51
|
+
"output_resolution" => {
|
|
52
|
+
"enum" => ["1k", "2k", "4k"]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}.freeze
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -47,17 +47,10 @@ module RunApi
|
|
|
47
47
|
private
|
|
48
48
|
|
|
49
49
|
def validate_params!(params)
|
|
50
|
-
|
|
50
|
+
validate_contract!(CONTRACT["edit-image"], params)
|
|
51
|
+
|
|
51
52
|
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
52
53
|
raise Core::ValidationError, "source_image_urls is required" unless param(params, :source_image_urls)
|
|
53
|
-
|
|
54
|
-
model = param(params, :model)
|
|
55
|
-
unless Types::EDIT_MODELS.include?(model)
|
|
56
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::EDIT_MODELS.join(", ")}"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
validate_optional!(params, :output_format, Types::OUTPUT_FORMATS)
|
|
60
|
-
validate_optional!(params, :aspect_ratio, Types::BASE_ASPECT_RATIOS)
|
|
61
54
|
end
|
|
62
55
|
end
|
|
63
56
|
end
|
|
@@ -47,17 +47,9 @@ module RunApi
|
|
|
47
47
|
private
|
|
48
48
|
|
|
49
49
|
def validate_params!(params)
|
|
50
|
-
|
|
51
|
-
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
52
|
-
|
|
53
|
-
model = param(params, :model)
|
|
54
|
-
unless Types::GENERATION_MODELS.include?(model)
|
|
55
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::GENERATION_MODELS.join(", ")}"
|
|
56
|
-
end
|
|
50
|
+
validate_contract!(CONTRACT["text-to-image"], params)
|
|
57
51
|
|
|
58
|
-
|
|
59
|
-
validate_optional!(params, :output_resolution, Types::OUTPUT_RESOLUTIONS)
|
|
60
|
-
validate_optional!(params, :output_format, Types::OUTPUT_FORMATS)
|
|
52
|
+
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
61
53
|
end
|
|
62
54
|
end
|
|
63
55
|
end
|
|
@@ -3,18 +3,6 @@
|
|
|
3
3
|
module RunApi
|
|
4
4
|
module NanoBanana
|
|
5
5
|
module Types
|
|
6
|
-
# Generation tiers: standard (fast), pro (higher res + more refs), v2 (longest prompts + extreme ratios).
|
|
7
|
-
GENERATION_MODELS = %w[nano-banana nano-banana-pro nano-banana-2].freeze
|
|
8
|
-
# Dedicated editing model. Requires source images to transform.
|
|
9
|
-
EDIT_MODELS = %w[nano-banana-edit].freeze
|
|
10
|
-
|
|
11
|
-
BASE_ASPECT_RATIOS = %w[1:1 9:16 16:9 3:4 4:3 3:2 2:3 5:4 4:5 21:9 auto].freeze
|
|
12
|
-
# Full aspect ratio set including extreme panoramic ratios (1:4, 1:8, 4:1, 8:1) for v2.
|
|
13
|
-
ASPECT_RATIOS = %w[1:1 1:4 1:8 2:3 3:2 3:4 4:1 4:3 4:5 5:4 8:1 9:16 16:9 21:9 auto].freeze
|
|
14
|
-
# Output resolution tiers. Pro and v2 default to 1k; higher tiers increase generation time.
|
|
15
|
-
OUTPUT_RESOLUTIONS = %w[1k 2k 4k].freeze
|
|
16
|
-
OUTPUT_FORMATS = %w[png jpg jpeg].freeze
|
|
17
|
-
|
|
18
6
|
# A single generated or edited image result.
|
|
19
7
|
class Image < RunApi::Core::BaseModel
|
|
20
8
|
optional :url, String
|
data/lib/runapi/nano_banana.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: runapi-nano-banana
|
|
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 Nano Banana Ruby SDK is the language-specific package for Nano Banana
|
|
27
|
+
on 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-nano_banana.rb
|
|
40
40
|
- lib/runapi/nano_banana.rb
|
|
41
41
|
- lib/runapi/nano_banana/client.rb
|
|
42
|
+
- lib/runapi/nano_banana/contract_gen.rb
|
|
42
43
|
- lib/runapi/nano_banana/resources/edit_image.rb
|
|
43
44
|
- lib/runapi/nano_banana/resources/text_to_image.rb
|
|
44
45
|
- lib/runapi/nano_banana/types.rb
|
|
@@ -46,9 +47,11 @@ homepage: https://runapi.ai/models/nano-banana
|
|
|
46
47
|
licenses:
|
|
47
48
|
- Apache-2.0
|
|
48
49
|
metadata:
|
|
50
|
+
runapi_slug: nano-banana
|
|
49
51
|
homepage_uri: https://runapi.ai/models/nano-banana
|
|
50
52
|
documentation_uri: https://github.com/runapi-ai/nano-banana-sdk/blob/main/ruby/README.md
|
|
51
53
|
source_code_uri: https://github.com/runapi-ai/nano-banana-sdk
|
|
54
|
+
bug_tracker_uri: https://github.com/runapi-ai/nano-banana-sdk/issues
|
|
52
55
|
changelog_uri: https://github.com/runapi-ai/nano-banana-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: Nano Banana
|
|
72
|
+
summary: Nano Banana Ruby SDK for RunAPI
|
|
70
73
|
test_files: []
|