runapi-nano-banana 0.2.6 → 0.2.9
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 +7 -7
- data/lib/runapi/nano_banana/contract_gen.rb +77 -0
- data/lib/runapi/nano_banana/resources/edit_image.rb +9 -16
- data/lib/runapi/nano_banana/resources/text_to_image.rb +17 -18
- 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: 3737c1cd6272c4da25d7e643354bd6994e1e5f7deecf0d8e50a477498aaf4069
|
|
4
|
+
data.tar.gz: 91c62e9bf1e746a6aff3e3532045d3a44fee21bc11ee745ed4927d5bb2f9e823
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e336b5616cbb7537a6c7f12df8d5e18536c397af22d656549cf6e57f867b2b30e33265f1892f9b128cb2187695063f6e71896bb6e893088133c033c1ba21c70e
|
|
7
|
+
data.tar.gz: 6029e2fd0b8b712b86ca2ff62c9c397a0479478630f4f77a10305e9608eb7961bfaf695f0a4947b0dd4dccc3111bf237d49fcf9f8c94d64c7c66dd95ea7c5397
|
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
|
|
|
@@ -13,13 +13,13 @@ gem install runapi-nano-banana
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
15
15
|
```ruby
|
|
16
|
-
require "runapi
|
|
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,77 @@
|
|
|
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-2-lite", "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-2-lite" => {
|
|
45
|
+
"aspect_ratio" => {
|
|
46
|
+
"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"],
|
|
47
|
+
"required" => true
|
|
48
|
+
},
|
|
49
|
+
"prompt" => {
|
|
50
|
+
"required" => true,
|
|
51
|
+
"min" => 1,
|
|
52
|
+
"max" => 20000,
|
|
53
|
+
"length" => true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"nano-banana-pro" => {
|
|
57
|
+
"aspect_ratio" => {
|
|
58
|
+
"enum" => ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9", "auto"]
|
|
59
|
+
},
|
|
60
|
+
"output_format" => {
|
|
61
|
+
"enum" => ["png", "jpeg", "jpg"]
|
|
62
|
+
},
|
|
63
|
+
"output_resolution" => {
|
|
64
|
+
"enum" => ["1k", "2k", "4k"]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"rules" => [{
|
|
69
|
+
"when" => {
|
|
70
|
+
"model" => "nano-banana-2-lite"
|
|
71
|
+
},
|
|
72
|
+
"forbidden" => ["output_resolution", "output_format"]
|
|
73
|
+
}]
|
|
74
|
+
}
|
|
75
|
+
}.freeze
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -21,43 +21,36 @@ module RunApi
|
|
|
21
21
|
#
|
|
22
22
|
# @param params [Hash] edit parameters
|
|
23
23
|
# @return [RunApi::NanoBanana::Types::CompletedEditImageResponse] completed edit with image results
|
|
24
|
-
def run(**params)
|
|
25
|
-
task = create(**params)
|
|
26
|
-
poll_until_complete { get(task.id) }
|
|
24
|
+
def run(options: nil, **params)
|
|
25
|
+
task = create(options: options, **params)
|
|
26
|
+
poll_until_complete { get(task.id, options: options) }
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Create an image edit task.
|
|
30
30
|
#
|
|
31
31
|
# @param params [Hash] edit parameters
|
|
32
32
|
# @return [RunApi::NanoBanana::Types::EditImageResponse] task creation result with id
|
|
33
|
-
def create(**params)
|
|
33
|
+
def create(options: nil, **params)
|
|
34
34
|
params = compact_params(params)
|
|
35
35
|
validate_params!(params)
|
|
36
|
-
request(:post, ENDPOINT, body: params)
|
|
36
|
+
request(:post, ENDPOINT, body: params, options: options)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
# Get edit status by task ID.
|
|
40
40
|
#
|
|
41
41
|
# @param id [String] task ID
|
|
42
42
|
# @return [RunApi::NanoBanana::Types::EditImageResponse] current edit status
|
|
43
|
-
def get(id)
|
|
44
|
-
request(:get, "#{ENDPOINT}/#{id}")
|
|
43
|
+
def get(id, options: nil)
|
|
44
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
45
45
|
end
|
|
46
46
|
|
|
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
|
|
@@ -19,45 +19,44 @@ module RunApi
|
|
|
19
19
|
|
|
20
20
|
# Generate an image and wait until complete.
|
|
21
21
|
#
|
|
22
|
-
# @param params [Hash] generation parameters
|
|
22
|
+
# @param params [Hash] generation parameters (see {#create} for accepted keys)
|
|
23
23
|
# @return [RunApi::NanoBanana::Types::CompletedTextToImageResponse] completed generation with image results
|
|
24
|
-
def run(**params)
|
|
25
|
-
task = create(**params)
|
|
26
|
-
poll_until_complete { get(task.id) }
|
|
24
|
+
def run(options: nil, **params)
|
|
25
|
+
task = create(options: options, **params)
|
|
26
|
+
poll_until_complete { get(task.id, options: options) }
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Create an image generation task.
|
|
30
30
|
#
|
|
31
31
|
# @param params [Hash] generation parameters
|
|
32
|
+
# @option params [String] :model model slug, e.g. "nano-banana", "nano-banana-pro", "nano-banana-2", "nano-banana-2-lite"
|
|
33
|
+
# @option params [String] :prompt required; image description
|
|
34
|
+
# @option params [String] :aspect_ratio optional; required for nano-banana-2-lite
|
|
35
|
+
# @option params [String] :output_format optional; "png", "jpeg", or "jpg" (not supported by nano-banana-2-lite)
|
|
36
|
+
# @option params [String] :output_resolution optional; "1k", "2k", or "4k" (nano-banana-pro / nano-banana-2)
|
|
37
|
+
# @option params [Array<String>] :reference_image_urls optional; reference image URLs for visual
|
|
38
|
+
# guidance (nano-banana / nano-banana-pro up to 8, nano-banana-2 up to 14, nano-banana-2-lite up to 10; <=30MB each)
|
|
32
39
|
# @return [RunApi::NanoBanana::Types::TextToImageResponse] task creation result with id
|
|
33
|
-
def create(**params)
|
|
40
|
+
def create(options: nil, **params)
|
|
34
41
|
params = compact_params(params)
|
|
35
42
|
validate_params!(params)
|
|
36
|
-
request(:post, ENDPOINT, body: params)
|
|
43
|
+
request(:post, ENDPOINT, body: params, options: options)
|
|
37
44
|
end
|
|
38
45
|
|
|
39
46
|
# Get generation status by task ID.
|
|
40
47
|
#
|
|
41
48
|
# @param id [String] task ID
|
|
42
49
|
# @return [RunApi::NanoBanana::Types::TextToImageResponse] current generation status
|
|
43
|
-
def get(id)
|
|
44
|
-
request(:get, "#{ENDPOINT}/#{id}")
|
|
50
|
+
def get(id, options: nil)
|
|
51
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
45
52
|
end
|
|
46
53
|
|
|
47
54
|
private
|
|
48
55
|
|
|
49
56
|
def validate_params!(params)
|
|
50
|
-
|
|
51
|
-
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
57
|
+
validate_contract!(CONTRACT["text-to-image"], params)
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
unless Types::GENERATION_MODELS.include?(model)
|
|
55
|
-
raise Core::ValidationError, "Invalid model: #{model}. Must be one of: #{Types::GENERATION_MODELS.join(", ")}"
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
|
|
59
|
-
validate_optional!(params, :output_resolution, Types::OUTPUT_RESOLUTIONS)
|
|
60
|
-
validate_optional!(params, :output_format, Types::OUTPUT_FORMATS)
|
|
59
|
+
raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
|
|
61
60
|
end
|
|
62
61
|
end
|
|
63
62
|
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.9
|
|
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.9
|
|
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.9
|
|
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: []
|