@runapi.ai/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.
- package/README.md +6 -6
- package/dist/index.d.mts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +184 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +186 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -4
- package/skills/nano-banana/README.md +3 -2
- package/skills/nano-banana/SKILL.md +2 -2
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Nano Banana
|
|
1
|
+
# Nano Banana JavaScript SDK for RunAPI
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Nano Banana JavaScript 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 JavaScript.
|
|
4
4
|
|
|
5
|
-
This
|
|
5
|
+
This README is the JavaScript 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 @@ npm install @runapi.ai/nano-banana
|
|
|
16
16
|
import { NanoBananaClient } from '@runapi.ai/nano-banana';
|
|
17
17
|
|
|
18
18
|
const client = new NanoBananaClient();
|
|
19
|
-
const task = await client.
|
|
19
|
+
const task = await client.textToImage.create({
|
|
20
20
|
// Pass the Nano Banana JSON request body from https://runapi.ai/docs#nano-banana.
|
|
21
21
|
});
|
|
22
|
-
const status = await client.
|
|
22
|
+
const status = await client.textToImage.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 the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The available resources
|
|
31
|
+
Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The available resources are `textToImage` and `editImage`. 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
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, BaseClient, ClientOptions } from '@runapi.ai/core';
|
|
2
2
|
export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundError, RateLimitError, RunApiError, ServiceUnavailableError, TaskFailedError, TaskTimeoutError, TimeoutError, ValidationError } from '@runapi.ai/core';
|
|
3
3
|
|
|
4
|
-
/** Generation model tiers: standard (fast), pro (higher resolution + more refs), v2
|
|
5
|
-
type TextToImageModel = 'nano-banana' | 'nano-banana-pro' | 'nano-banana-2';
|
|
4
|
+
/** Generation model tiers: standard (fast), pro (higher resolution + more refs), v2, and v2 lite. */
|
|
5
|
+
type TextToImageModel = 'nano-banana' | 'nano-banana-pro' | 'nano-banana-2' | 'nano-banana-2-lite';
|
|
6
6
|
/** Dedicated editing model. Requires source images to transform. */
|
|
7
7
|
type EditImageModel = 'nano-banana-edit';
|
|
8
8
|
/** Aspect ratio options for the standard model. */
|
|
@@ -50,11 +50,20 @@ interface GenerationV2Params {
|
|
|
50
50
|
/** Optional visual guidance images (up to 14, max 30 MB each). */
|
|
51
51
|
reference_image_urls?: string[];
|
|
52
52
|
}
|
|
53
|
+
/** V2 Lite generation. Requires aspect_ratio, accepts up to 10 references, and has no output format or resolution controls. */
|
|
54
|
+
interface GenerationV2LiteParams {
|
|
55
|
+
model: 'nano-banana-2-lite';
|
|
56
|
+
prompt: string;
|
|
57
|
+
callback_url?: string;
|
|
58
|
+
aspect_ratio: AspectRatioV2;
|
|
59
|
+
/** Optional visual guidance images (up to 10, max 30 MB each). */
|
|
60
|
+
reference_image_urls?: string[];
|
|
61
|
+
}
|
|
53
62
|
/**
|
|
54
63
|
* Text-to-image parameters. A discriminated union on `model`: the accepted
|
|
55
64
|
* aspect ratios, prompt length, resolution, and reference image count differ per tier.
|
|
56
65
|
*/
|
|
57
|
-
type TextToImageParams = GenerationBaseParams | GenerationProParams | GenerationV2Params;
|
|
66
|
+
type TextToImageParams = GenerationBaseParams | GenerationProParams | GenerationV2Params | GenerationV2LiteParams;
|
|
58
67
|
/**
|
|
59
68
|
* Edit image parameters. Requires source images to modify according to the prompt.
|
|
60
69
|
* Up to 10 source images, max 10 MB each.
|
|
@@ -195,4 +204,4 @@ declare class NanoBananaClient extends BaseClient {
|
|
|
195
204
|
constructor(options?: ClientOptions);
|
|
196
205
|
}
|
|
197
206
|
|
|
198
|
-
export { type AspectRatio, type AspectRatioV2, type BaseAspectRatio, type CompletedEditImageResponse, type CompletedTextToImageResponse, type EditImageModel, type EditImageParams, type EditImageResponse, type GenerationBaseParams, type GenerationProParams, type GenerationV2Params, type Image, NanoBananaClient, type OutputFormat, type OutputResolution, type TaskCreateResponse, type TextToImageModel, type TextToImageParams, type TextToImageResponse };
|
|
207
|
+
export { type AspectRatio, type AspectRatioV2, type BaseAspectRatio, type CompletedEditImageResponse, type CompletedTextToImageResponse, type EditImageModel, type EditImageParams, type EditImageResponse, type GenerationBaseParams, type GenerationProParams, type GenerationV2LiteParams, type GenerationV2Params, type Image, NanoBananaClient, type OutputFormat, type OutputResolution, type TaskCreateResponse, type TextToImageModel, type TextToImageParams, type TextToImageResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, BaseClient, ClientOptions } from '@runapi.ai/core';
|
|
2
2
|
export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundError, RateLimitError, RunApiError, ServiceUnavailableError, TaskFailedError, TaskTimeoutError, TimeoutError, ValidationError } from '@runapi.ai/core';
|
|
3
3
|
|
|
4
|
-
/** Generation model tiers: standard (fast), pro (higher resolution + more refs), v2
|
|
5
|
-
type TextToImageModel = 'nano-banana' | 'nano-banana-pro' | 'nano-banana-2';
|
|
4
|
+
/** Generation model tiers: standard (fast), pro (higher resolution + more refs), v2, and v2 lite. */
|
|
5
|
+
type TextToImageModel = 'nano-banana' | 'nano-banana-pro' | 'nano-banana-2' | 'nano-banana-2-lite';
|
|
6
6
|
/** Dedicated editing model. Requires source images to transform. */
|
|
7
7
|
type EditImageModel = 'nano-banana-edit';
|
|
8
8
|
/** Aspect ratio options for the standard model. */
|
|
@@ -50,11 +50,20 @@ interface GenerationV2Params {
|
|
|
50
50
|
/** Optional visual guidance images (up to 14, max 30 MB each). */
|
|
51
51
|
reference_image_urls?: string[];
|
|
52
52
|
}
|
|
53
|
+
/** V2 Lite generation. Requires aspect_ratio, accepts up to 10 references, and has no output format or resolution controls. */
|
|
54
|
+
interface GenerationV2LiteParams {
|
|
55
|
+
model: 'nano-banana-2-lite';
|
|
56
|
+
prompt: string;
|
|
57
|
+
callback_url?: string;
|
|
58
|
+
aspect_ratio: AspectRatioV2;
|
|
59
|
+
/** Optional visual guidance images (up to 10, max 30 MB each). */
|
|
60
|
+
reference_image_urls?: string[];
|
|
61
|
+
}
|
|
53
62
|
/**
|
|
54
63
|
* Text-to-image parameters. A discriminated union on `model`: the accepted
|
|
55
64
|
* aspect ratios, prompt length, resolution, and reference image count differ per tier.
|
|
56
65
|
*/
|
|
57
|
-
type TextToImageParams = GenerationBaseParams | GenerationProParams | GenerationV2Params;
|
|
66
|
+
type TextToImageParams = GenerationBaseParams | GenerationProParams | GenerationV2Params | GenerationV2LiteParams;
|
|
58
67
|
/**
|
|
59
68
|
* Edit image parameters. Requires source images to modify according to the prompt.
|
|
60
69
|
* Up to 10 source images, max 10 MB each.
|
|
@@ -195,4 +204,4 @@ declare class NanoBananaClient extends BaseClient {
|
|
|
195
204
|
constructor(options?: ClientOptions);
|
|
196
205
|
}
|
|
197
206
|
|
|
198
|
-
export { type AspectRatio, type AspectRatioV2, type BaseAspectRatio, type CompletedEditImageResponse, type CompletedTextToImageResponse, type EditImageModel, type EditImageParams, type EditImageResponse, type GenerationBaseParams, type GenerationProParams, type GenerationV2Params, type Image, NanoBananaClient, type OutputFormat, type OutputResolution, type TaskCreateResponse, type TextToImageModel, type TextToImageParams, type TextToImageResponse };
|
|
207
|
+
export { type AspectRatio, type AspectRatioV2, type BaseAspectRatio, type CompletedEditImageResponse, type CompletedTextToImageResponse, type EditImageModel, type EditImageParams, type EditImageResponse, type GenerationBaseParams, type GenerationProParams, type GenerationV2LiteParams, type GenerationV2Params, type Image, NanoBananaClient, type OutputFormat, type OutputResolution, type TaskCreateResponse, type TextToImageModel, type TextToImageParams, type TextToImageResponse };
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,184 @@ var import_core3 = require("@runapi.ai/core");
|
|
|
41
41
|
// src/resources/text-to-image.ts
|
|
42
42
|
var import_core = require("@runapi.ai/core");
|
|
43
43
|
var import_internal = require("@runapi.ai/core/internal");
|
|
44
|
+
|
|
45
|
+
// src/contract_gen.ts
|
|
46
|
+
var contract = {
|
|
47
|
+
"edit-image": {
|
|
48
|
+
"models": [
|
|
49
|
+
"nano-banana-edit"
|
|
50
|
+
],
|
|
51
|
+
"fields_by_model": {
|
|
52
|
+
"nano-banana-edit": {
|
|
53
|
+
"aspect_ratio": {
|
|
54
|
+
"enum": [
|
|
55
|
+
"1:1",
|
|
56
|
+
"9:16",
|
|
57
|
+
"16:9",
|
|
58
|
+
"3:4",
|
|
59
|
+
"4:3",
|
|
60
|
+
"3:2",
|
|
61
|
+
"2:3",
|
|
62
|
+
"5:4",
|
|
63
|
+
"4:5",
|
|
64
|
+
"21:9",
|
|
65
|
+
"auto"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"output_format": {
|
|
69
|
+
"enum": [
|
|
70
|
+
"png",
|
|
71
|
+
"jpeg"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"source_image_urls": {
|
|
75
|
+
"required": true
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"text-to-image": {
|
|
81
|
+
"models": [
|
|
82
|
+
"nano-banana",
|
|
83
|
+
"nano-banana-2",
|
|
84
|
+
"nano-banana-2-lite",
|
|
85
|
+
"nano-banana-pro"
|
|
86
|
+
],
|
|
87
|
+
"fields_by_model": {
|
|
88
|
+
"nano-banana": {
|
|
89
|
+
"aspect_ratio": {
|
|
90
|
+
"enum": [
|
|
91
|
+
"1:1",
|
|
92
|
+
"9:16",
|
|
93
|
+
"16:9",
|
|
94
|
+
"3:4",
|
|
95
|
+
"4:3",
|
|
96
|
+
"3:2",
|
|
97
|
+
"2:3",
|
|
98
|
+
"5:4",
|
|
99
|
+
"4:5",
|
|
100
|
+
"21:9",
|
|
101
|
+
"auto"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
"output_format": {
|
|
105
|
+
"enum": [
|
|
106
|
+
"png",
|
|
107
|
+
"jpeg",
|
|
108
|
+
"jpg"
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"nano-banana-2": {
|
|
113
|
+
"aspect_ratio": {
|
|
114
|
+
"enum": [
|
|
115
|
+
"1:1",
|
|
116
|
+
"1:4",
|
|
117
|
+
"1:8",
|
|
118
|
+
"2:3",
|
|
119
|
+
"3:2",
|
|
120
|
+
"3:4",
|
|
121
|
+
"4:1",
|
|
122
|
+
"4:3",
|
|
123
|
+
"4:5",
|
|
124
|
+
"5:4",
|
|
125
|
+
"8:1",
|
|
126
|
+
"9:16",
|
|
127
|
+
"16:9",
|
|
128
|
+
"21:9",
|
|
129
|
+
"auto"
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
"output_format": {
|
|
133
|
+
"enum": [
|
|
134
|
+
"png",
|
|
135
|
+
"jpeg",
|
|
136
|
+
"jpg"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"output_resolution": {
|
|
140
|
+
"enum": [
|
|
141
|
+
"1k",
|
|
142
|
+
"2k",
|
|
143
|
+
"4k"
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"nano-banana-2-lite": {
|
|
148
|
+
"aspect_ratio": {
|
|
149
|
+
"enum": [
|
|
150
|
+
"1:1",
|
|
151
|
+
"1:4",
|
|
152
|
+
"1:8",
|
|
153
|
+
"2:3",
|
|
154
|
+
"3:2",
|
|
155
|
+
"3:4",
|
|
156
|
+
"4:1",
|
|
157
|
+
"4:3",
|
|
158
|
+
"4:5",
|
|
159
|
+
"5:4",
|
|
160
|
+
"8:1",
|
|
161
|
+
"9:16",
|
|
162
|
+
"16:9",
|
|
163
|
+
"21:9",
|
|
164
|
+
"auto"
|
|
165
|
+
],
|
|
166
|
+
"required": true
|
|
167
|
+
},
|
|
168
|
+
"prompt": {
|
|
169
|
+
"required": true,
|
|
170
|
+
"min": 1,
|
|
171
|
+
"max": 2e4,
|
|
172
|
+
"length": true
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"nano-banana-pro": {
|
|
176
|
+
"aspect_ratio": {
|
|
177
|
+
"enum": [
|
|
178
|
+
"1:1",
|
|
179
|
+
"2:3",
|
|
180
|
+
"3:2",
|
|
181
|
+
"3:4",
|
|
182
|
+
"4:3",
|
|
183
|
+
"4:5",
|
|
184
|
+
"5:4",
|
|
185
|
+
"9:16",
|
|
186
|
+
"16:9",
|
|
187
|
+
"21:9",
|
|
188
|
+
"auto"
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
"output_format": {
|
|
192
|
+
"enum": [
|
|
193
|
+
"png",
|
|
194
|
+
"jpeg",
|
|
195
|
+
"jpg"
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
"output_resolution": {
|
|
199
|
+
"enum": [
|
|
200
|
+
"1k",
|
|
201
|
+
"2k",
|
|
202
|
+
"4k"
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
"rules": [
|
|
208
|
+
{
|
|
209
|
+
"when": {
|
|
210
|
+
"model": "nano-banana-2-lite"
|
|
211
|
+
},
|
|
212
|
+
"forbidden": [
|
|
213
|
+
"output_resolution",
|
|
214
|
+
"output_format"
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// src/resources/text-to-image.ts
|
|
44
222
|
var ENDPOINT = "/api/v1/nano_banana/text_to_image";
|
|
45
223
|
var TextToImage = class {
|
|
46
224
|
constructor(http) {
|
|
@@ -68,8 +246,10 @@ var TextToImage = class {
|
|
|
68
246
|
* @returns The task creation result with id.
|
|
69
247
|
*/
|
|
70
248
|
async create(params, options) {
|
|
249
|
+
const body = (0, import_core.compactParams)(params);
|
|
250
|
+
(0, import_core.validateParams)(contract["text-to-image"], body);
|
|
71
251
|
return this.http.request("POST", ENDPOINT, {
|
|
72
|
-
body
|
|
252
|
+
body,
|
|
73
253
|
...options
|
|
74
254
|
});
|
|
75
255
|
}
|
|
@@ -116,8 +296,10 @@ var EditImage = class {
|
|
|
116
296
|
* @returns The task creation result with id.
|
|
117
297
|
*/
|
|
118
298
|
async create(params, options) {
|
|
299
|
+
const body = (0, import_core2.compactParams)(params);
|
|
300
|
+
(0, import_core2.validateParams)(contract["edit-image"], body);
|
|
119
301
|
return this.http.request("POST", ENDPOINT2, {
|
|
120
|
-
body
|
|
302
|
+
body,
|
|
121
303
|
...options
|
|
122
304
|
});
|
|
123
305
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-image.ts","../src/resources/edit-image.ts"],"sourcesContent":["export { NanoBananaClient } from './client';\nexport * from './types';\n\n// Re-export core errors for convenience\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n","import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { EditImage } from './resources/edit-image';\n\n/**\n * NanoBanana image generation and editing API client.\n *\n * Three generation tiers: standard (fast), pro (higher resolution, more\n * reference images), and v2 (longest prompts, extreme aspect ratios, up to 14\n * reference images). Editing uses the dedicated `nano-banana-edit` model.\n *\n * @example\n * ```typescript\n * const client = new NanoBananaClient({\n * apiKey: 'your-api-key',\n * baseUrl: 'https://runapi.ai',\n * });\n *\n * const result = await client.textToImage.run({\n * model: 'nano-banana-pro',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class NanoBananaClient extends BaseClient {\n /** Generate images from text prompts with optional reference image guidance. */\n public readonly textToImage: TextToImage;\n /** Edit existing images using text prompts and source images. */\n public readonly editImage: EditImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.editImage = new EditImage(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedTextToImageResponse,\n TextToImageParams,\n TextToImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/text_to_image';\n\n/** Generates images from text prompts with optional reference image guidance. Model tier controls prompt length, resolution, and reference image limits. */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an image from a text prompt and wait until complete.\n * @param params Generation parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed generation with image results.\n */\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToImageResponse;\n }\n\n /**\n * Create an image generation task; returns immediately with a task id.\n * @param params Generation parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image generation task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image generation task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type { CompletedEditImageResponse, EditImageParams, EditImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/edit_image';\n\n/** Modifies existing images based on text prompts. Requires source images to edit. */\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Edit an image using text prompts and reference images and wait until complete.\n * @param params Edit parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed edit with image results.\n */\n async run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<EditImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedEditImageResponse;\n }\n\n /**\n * Create an image edit task; returns immediately with a task id.\n * @param params Edit parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image edit task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image edit task status.\n */\n async get(id: string, options?: RequestOptions): Promise<EditImageResponse> {\n return this.http.request<EditImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAA+C;;;ACC/C,kBAA8B;AAC9B,sBAAkC;AAQlC,IAAM,WAAW;AAGV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,UAAM,mCAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,UAAM,2BAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAA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ts","../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.ts","../src/resources/edit-image.ts"],"sourcesContent":["export { NanoBananaClient } from './client';\nexport * from './types';\n\n// Re-export core errors for convenience\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n","import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { EditImage } from './resources/edit-image';\n\n/**\n * NanoBanana image generation and editing API client.\n *\n * Three generation tiers: standard (fast), pro (higher resolution, more\n * reference images), and v2 (longest prompts, extreme aspect ratios, up to 14\n * reference images). Editing uses the dedicated `nano-banana-edit` model.\n *\n * @example\n * ```typescript\n * const client = new NanoBananaClient({\n * apiKey: 'your-api-key',\n * baseUrl: 'https://runapi.ai',\n * });\n *\n * const result = await client.textToImage.run({\n * model: 'nano-banana-pro',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class NanoBananaClient extends BaseClient {\n /** Generate images from text prompts with optional reference image guidance. */\n public readonly textToImage: TextToImage;\n /** Edit existing images using text prompts and source images. */\n public readonly editImage: EditImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.editImage = new EditImage(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedTextToImageResponse,\n TextToImageParams,\n TextToImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/text_to_image';\n\n/** Generates images from text prompts with optional reference image guidance. Model tier controls prompt length, resolution, and reference image limits. */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an image from a text prompt and wait until complete.\n * @param params Generation parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed generation with image results.\n */\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToImageResponse;\n }\n\n /**\n * Create an image generation task; returns immediately with a task id.\n * @param params Generation parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['text-to-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image generation task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image generation task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export const contract = {\n \"edit-image\": {\n \"models\": [\n \"nano-banana-edit\"\n ],\n \"fields_by_model\": {\n \"nano-banana-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"9:16\",\n \"16:9\",\n \"3:4\",\n \"4:3\",\n \"3:2\",\n \"2:3\",\n \"5:4\",\n \"4:5\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"source_image_urls\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-image\": {\n \"models\": [\n \"nano-banana\",\n \"nano-banana-2\",\n \"nano-banana-2-lite\",\n \"nano-banana-pro\"\n ],\n \"fields_by_model\": {\n \"nano-banana\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"9:16\",\n \"16:9\",\n \"3:4\",\n \"4:3\",\n \"3:2\",\n \"2:3\",\n \"5:4\",\n \"4:5\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n }\n },\n \"nano-banana-2\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"1:4\",\n \"1:8\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:1\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"8:1\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n }\n },\n \"nano-banana-2-lite\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"1:4\",\n \"1:8\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:1\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"8:1\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ],\n \"required\": true\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 1,\n \"max\": 20000,\n \"length\": true\n }\n },\n \"nano-banana-pro\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n }\n }\n },\n \"rules\": [\n {\n \"when\": {\n \"model\": \"nano-banana-2-lite\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"output_format\"\n ]\n }\n ]\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { CompletedEditImageResponse, EditImageParams, EditImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/edit_image';\n\n/** Modifies existing images based on text prompts. Requires source images to edit. */\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Edit an image using text prompts and reference images and wait until complete.\n * @param params Edit parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed edit with image results.\n */\n async run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<EditImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedEditImageResponse;\n }\n\n /**\n * Create an image edit task; returns immediately with a task id.\n * @param params Edit parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['edit-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image edit task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image edit task status.\n */\n async get(id: string, options?: RequestOptions): Promise<EditImageResponse> {\n return this.http.request<EditImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAA+C;;;ACC/C,kBAA8C;AAC9C,sBAAkC;;;ACF3B,IAAM,WAAW;AAA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AU;AAAA,MAC7D;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAsD;AAC1E,WAAO,KAAK,KAAK,QAA2B,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI;AAAA,MACtE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AH7BO,IAAM,mBAAN,cAA+B,wBAAW;AAAA;AAAA,EAE/B;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAC5C,SAAK,YAAY,IAAI,UAAU,KAAK,IAAI;AAAA,EAC1C;AACF;;;AD/BA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","import_core"]}
|
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,186 @@
|
|
|
2
2
|
import { BaseClient } from "@runapi.ai/core";
|
|
3
3
|
|
|
4
4
|
// src/resources/text-to-image.ts
|
|
5
|
-
import { compactParams } from "@runapi.ai/core";
|
|
5
|
+
import { compactParams, validateParams } from "@runapi.ai/core";
|
|
6
6
|
import { pollUntilComplete } from "@runapi.ai/core/internal";
|
|
7
|
+
|
|
8
|
+
// src/contract_gen.ts
|
|
9
|
+
var contract = {
|
|
10
|
+
"edit-image": {
|
|
11
|
+
"models": [
|
|
12
|
+
"nano-banana-edit"
|
|
13
|
+
],
|
|
14
|
+
"fields_by_model": {
|
|
15
|
+
"nano-banana-edit": {
|
|
16
|
+
"aspect_ratio": {
|
|
17
|
+
"enum": [
|
|
18
|
+
"1:1",
|
|
19
|
+
"9:16",
|
|
20
|
+
"16:9",
|
|
21
|
+
"3:4",
|
|
22
|
+
"4:3",
|
|
23
|
+
"3:2",
|
|
24
|
+
"2:3",
|
|
25
|
+
"5:4",
|
|
26
|
+
"4:5",
|
|
27
|
+
"21:9",
|
|
28
|
+
"auto"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"output_format": {
|
|
32
|
+
"enum": [
|
|
33
|
+
"png",
|
|
34
|
+
"jpeg"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"source_image_urls": {
|
|
38
|
+
"required": true
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"text-to-image": {
|
|
44
|
+
"models": [
|
|
45
|
+
"nano-banana",
|
|
46
|
+
"nano-banana-2",
|
|
47
|
+
"nano-banana-2-lite",
|
|
48
|
+
"nano-banana-pro"
|
|
49
|
+
],
|
|
50
|
+
"fields_by_model": {
|
|
51
|
+
"nano-banana": {
|
|
52
|
+
"aspect_ratio": {
|
|
53
|
+
"enum": [
|
|
54
|
+
"1:1",
|
|
55
|
+
"9:16",
|
|
56
|
+
"16:9",
|
|
57
|
+
"3:4",
|
|
58
|
+
"4:3",
|
|
59
|
+
"3:2",
|
|
60
|
+
"2:3",
|
|
61
|
+
"5:4",
|
|
62
|
+
"4:5",
|
|
63
|
+
"21:9",
|
|
64
|
+
"auto"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"output_format": {
|
|
68
|
+
"enum": [
|
|
69
|
+
"png",
|
|
70
|
+
"jpeg",
|
|
71
|
+
"jpg"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"nano-banana-2": {
|
|
76
|
+
"aspect_ratio": {
|
|
77
|
+
"enum": [
|
|
78
|
+
"1:1",
|
|
79
|
+
"1:4",
|
|
80
|
+
"1:8",
|
|
81
|
+
"2:3",
|
|
82
|
+
"3:2",
|
|
83
|
+
"3:4",
|
|
84
|
+
"4:1",
|
|
85
|
+
"4:3",
|
|
86
|
+
"4:5",
|
|
87
|
+
"5:4",
|
|
88
|
+
"8:1",
|
|
89
|
+
"9:16",
|
|
90
|
+
"16:9",
|
|
91
|
+
"21:9",
|
|
92
|
+
"auto"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"output_format": {
|
|
96
|
+
"enum": [
|
|
97
|
+
"png",
|
|
98
|
+
"jpeg",
|
|
99
|
+
"jpg"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"output_resolution": {
|
|
103
|
+
"enum": [
|
|
104
|
+
"1k",
|
|
105
|
+
"2k",
|
|
106
|
+
"4k"
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"nano-banana-2-lite": {
|
|
111
|
+
"aspect_ratio": {
|
|
112
|
+
"enum": [
|
|
113
|
+
"1:1",
|
|
114
|
+
"1:4",
|
|
115
|
+
"1:8",
|
|
116
|
+
"2:3",
|
|
117
|
+
"3:2",
|
|
118
|
+
"3:4",
|
|
119
|
+
"4:1",
|
|
120
|
+
"4:3",
|
|
121
|
+
"4:5",
|
|
122
|
+
"5:4",
|
|
123
|
+
"8:1",
|
|
124
|
+
"9:16",
|
|
125
|
+
"16:9",
|
|
126
|
+
"21:9",
|
|
127
|
+
"auto"
|
|
128
|
+
],
|
|
129
|
+
"required": true
|
|
130
|
+
},
|
|
131
|
+
"prompt": {
|
|
132
|
+
"required": true,
|
|
133
|
+
"min": 1,
|
|
134
|
+
"max": 2e4,
|
|
135
|
+
"length": true
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"nano-banana-pro": {
|
|
139
|
+
"aspect_ratio": {
|
|
140
|
+
"enum": [
|
|
141
|
+
"1:1",
|
|
142
|
+
"2:3",
|
|
143
|
+
"3:2",
|
|
144
|
+
"3:4",
|
|
145
|
+
"4:3",
|
|
146
|
+
"4:5",
|
|
147
|
+
"5:4",
|
|
148
|
+
"9:16",
|
|
149
|
+
"16:9",
|
|
150
|
+
"21:9",
|
|
151
|
+
"auto"
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
"output_format": {
|
|
155
|
+
"enum": [
|
|
156
|
+
"png",
|
|
157
|
+
"jpeg",
|
|
158
|
+
"jpg"
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
"output_resolution": {
|
|
162
|
+
"enum": [
|
|
163
|
+
"1k",
|
|
164
|
+
"2k",
|
|
165
|
+
"4k"
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"rules": [
|
|
171
|
+
{
|
|
172
|
+
"when": {
|
|
173
|
+
"model": "nano-banana-2-lite"
|
|
174
|
+
},
|
|
175
|
+
"forbidden": [
|
|
176
|
+
"output_resolution",
|
|
177
|
+
"output_format"
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// src/resources/text-to-image.ts
|
|
7
185
|
var ENDPOINT = "/api/v1/nano_banana/text_to_image";
|
|
8
186
|
var TextToImage = class {
|
|
9
187
|
constructor(http) {
|
|
@@ -31,8 +209,10 @@ var TextToImage = class {
|
|
|
31
209
|
* @returns The task creation result with id.
|
|
32
210
|
*/
|
|
33
211
|
async create(params, options) {
|
|
212
|
+
const body = compactParams(params);
|
|
213
|
+
validateParams(contract["text-to-image"], body);
|
|
34
214
|
return this.http.request("POST", ENDPOINT, {
|
|
35
|
-
body
|
|
215
|
+
body,
|
|
36
216
|
...options
|
|
37
217
|
});
|
|
38
218
|
}
|
|
@@ -50,7 +230,7 @@ var TextToImage = class {
|
|
|
50
230
|
};
|
|
51
231
|
|
|
52
232
|
// src/resources/edit-image.ts
|
|
53
|
-
import { compactParams as compactParams2 } from "@runapi.ai/core";
|
|
233
|
+
import { compactParams as compactParams2, validateParams as validateParams2 } from "@runapi.ai/core";
|
|
54
234
|
import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
|
|
55
235
|
var ENDPOINT2 = "/api/v1/nano_banana/edit_image";
|
|
56
236
|
var EditImage = class {
|
|
@@ -79,8 +259,10 @@ var EditImage = class {
|
|
|
79
259
|
* @returns The task creation result with id.
|
|
80
260
|
*/
|
|
81
261
|
async create(params, options) {
|
|
262
|
+
const body = compactParams2(params);
|
|
263
|
+
validateParams2(contract["edit-image"], body);
|
|
82
264
|
return this.http.request("POST", ENDPOINT2, {
|
|
83
|
-
body
|
|
265
|
+
body,
|
|
84
266
|
...options
|
|
85
267
|
});
|
|
86
268
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/resources/edit-image.ts","../src/index.ts"],"sourcesContent":["import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { EditImage } from './resources/edit-image';\n\n/**\n * NanoBanana image generation and editing API client.\n *\n * Three generation tiers: standard (fast), pro (higher resolution, more\n * reference images), and v2 (longest prompts, extreme aspect ratios, up to 14\n * reference images). Editing uses the dedicated `nano-banana-edit` model.\n *\n * @example\n * ```typescript\n * const client = new NanoBananaClient({\n * apiKey: 'your-api-key',\n * baseUrl: 'https://runapi.ai',\n * });\n *\n * const result = await client.textToImage.run({\n * model: 'nano-banana-pro',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class NanoBananaClient extends BaseClient {\n /** Generate images from text prompts with optional reference image guidance. */\n public readonly textToImage: TextToImage;\n /** Edit existing images using text prompts and source images. */\n public readonly editImage: EditImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.editImage = new EditImage(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedTextToImageResponse,\n TextToImageParams,\n TextToImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/text_to_image';\n\n/** Generates images from text prompts with optional reference image guidance. Model tier controls prompt length, resolution, and reference image limits. */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an image from a text prompt and wait until complete.\n * @param params Generation parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed generation with image results.\n */\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToImageResponse;\n }\n\n /**\n * Create an image generation task; returns immediately with a task id.\n * @param params Generation parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image generation task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image generation task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type { CompletedEditImageResponse, EditImageParams, EditImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/edit_image';\n\n/** Modifies existing images based on text prompts. Requires source images to edit. */\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Edit an image using text prompts and reference images and wait until complete.\n * @param params Edit parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed edit with image results.\n */\n async run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<EditImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedEditImageResponse;\n }\n\n /**\n * Create an image edit task; returns immediately with a task id.\n * @param params Edit parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image edit task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image edit task status.\n */\n async get(id: string, options?: RequestOptions): Promise<EditImageResponse> {\n return this.http.request<EditImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export { NanoBananaClient } from './client';\nexport * from './types';\n\n// Re-export core errors for convenience\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n"],"mappings":";AAAA,SAAS,kBAAsC;;;ACC/C,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAQlC,IAAM,WAAW;AAGV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAM,kBAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,MAAM,cAAc,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,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAC5C,SAAK,YAAY,IAAI,UAAU,KAAK,IAAI;AAAA,EAC1C;AACF;;;AG/BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","pollUntilComplete","ENDPOINT"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.ts","../src/resources/edit-image.ts","../src/index.ts"],"sourcesContent":["import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { EditImage } from './resources/edit-image';\n\n/**\n * NanoBanana image generation and editing API client.\n *\n * Three generation tiers: standard (fast), pro (higher resolution, more\n * reference images), and v2 (longest prompts, extreme aspect ratios, up to 14\n * reference images). Editing uses the dedicated `nano-banana-edit` model.\n *\n * @example\n * ```typescript\n * const client = new NanoBananaClient({\n * apiKey: 'your-api-key',\n * baseUrl: 'https://runapi.ai',\n * });\n *\n * const result = await client.textToImage.run({\n * model: 'nano-banana-pro',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class NanoBananaClient extends BaseClient {\n /** Generate images from text prompts with optional reference image guidance. */\n public readonly textToImage: TextToImage;\n /** Edit existing images using text prompts and source images. */\n public readonly editImage: EditImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.editImage = new EditImage(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedTextToImageResponse,\n TextToImageParams,\n TextToImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/text_to_image';\n\n/** Generates images from text prompts with optional reference image guidance. Model tier controls prompt length, resolution, and reference image limits. */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an image from a text prompt and wait until complete.\n * @param params Generation parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed generation with image results.\n */\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToImageResponse;\n }\n\n /**\n * Create an image generation task; returns immediately with a task id.\n * @param params Generation parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['text-to-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image generation task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image generation task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export const contract = {\n \"edit-image\": {\n \"models\": [\n \"nano-banana-edit\"\n ],\n \"fields_by_model\": {\n \"nano-banana-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"9:16\",\n \"16:9\",\n \"3:4\",\n \"4:3\",\n \"3:2\",\n \"2:3\",\n \"5:4\",\n \"4:5\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"source_image_urls\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-image\": {\n \"models\": [\n \"nano-banana\",\n \"nano-banana-2\",\n \"nano-banana-2-lite\",\n \"nano-banana-pro\"\n ],\n \"fields_by_model\": {\n \"nano-banana\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"9:16\",\n \"16:9\",\n \"3:4\",\n \"4:3\",\n \"3:2\",\n \"2:3\",\n \"5:4\",\n \"4:5\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n }\n },\n \"nano-banana-2\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"1:4\",\n \"1:8\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:1\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"8:1\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n }\n },\n \"nano-banana-2-lite\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"1:4\",\n \"1:8\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:1\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"8:1\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ],\n \"required\": true\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 1,\n \"max\": 20000,\n \"length\": true\n }\n },\n \"nano-banana-pro\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n }\n }\n },\n \"rules\": [\n {\n \"when\": {\n \"model\": \"nano-banana-2-lite\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"output_format\"\n ]\n }\n ]\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { CompletedEditImageResponse, EditImageParams, EditImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/edit_image';\n\n/** Modifies existing images based on text prompts. Requires source images to edit. */\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Edit an image using text prompts and reference images and wait until complete.\n * @param params Edit parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed edit with image results.\n */\n async run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<EditImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedEditImageResponse;\n }\n\n /**\n * Create an image edit task; returns immediately with a task id.\n * @param params Edit parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['edit-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image edit task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image edit task status.\n */\n async get(id: string, options?: RequestOptions): Promise<EditImageResponse> {\n return this.http.request<EditImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export { NanoBananaClient } from './client';\nexport * from './types';\n\n// Re-export core errors for convenience\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n"],"mappings":";AAAA,SAAS,kBAAsC;;;ACC/C,SAAS,eAAe,sBAAsB;AAC9C,SAAS,yBAAyB;;;ACF3B,IAAM,WAAW;AAAA,EACtB,cAAc;AAAA,IACZ,UAAU;AAAA,MACR;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,oBAAoB;AAAA,QAClB,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,iBAAiB;AAAA,UACf,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAAqB;AAAA,UACnB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,eAAe;AAAA,QACb,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,iBAAiB;AAAA,UACf,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MACA,iBAAiB;AAAA,QACf,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;A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,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAAyB,SAAuD;AAC3F,UAAM,OAAOC,eAAc,MAAM;AACjC,IAAAC,gBAAe,SAAS,YAAY,GAAmB,IAA+B;AACtF,WAAO,KAAK,KAAK,QAA4B,QAAQH,WAAU;AAAA,MAC7D;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAsD;AAC1E,WAAO,KAAK,KAAK,QAA2B,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI;AAAA,MACtE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AH7BO,IAAM,mBAAN,cAA+B,WAAW;AAAA;AAAA,EAE/B;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAC5C,SAAK,YAAY,IAAI,UAAU,KAAK,IAAI;AAAA,EAC1C;AACF;;;AI/BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","validateParams","pollUntilComplete","ENDPOINT","pollUntilComplete","compactParams","validateParams"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runapi.ai/nano-banana",
|
|
3
|
-
"
|
|
4
|
-
|
|
3
|
+
"runapi": {
|
|
4
|
+
"slug": "nano-banana"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.2.9",
|
|
7
|
+
"description": "RunAPI Nano Banana SDK for text-to-image and image editing workflows in JavaScript, Python, Ruby, Go, Java, and PHP",
|
|
5
8
|
"main": "./dist/index.js",
|
|
6
9
|
"module": "./dist/index.mjs",
|
|
7
10
|
"types": "./dist/index.d.ts",
|
|
@@ -28,7 +31,7 @@
|
|
|
28
31
|
"clean": "rm -rf dist"
|
|
29
32
|
},
|
|
30
33
|
"dependencies": {
|
|
31
|
-
"@runapi.ai/core": "^0.2.
|
|
34
|
+
"@runapi.ai/core": "^0.2.9"
|
|
32
35
|
},
|
|
33
36
|
"devDependencies": {
|
|
34
37
|
"@types/node": "^20.0.0",
|
|
@@ -49,8 +52,16 @@
|
|
|
49
52
|
"api",
|
|
50
53
|
"sdk",
|
|
51
54
|
"typescript",
|
|
55
|
+
"python",
|
|
52
56
|
"ruby",
|
|
53
|
-
"golang"
|
|
57
|
+
"golang",
|
|
58
|
+
"java",
|
|
59
|
+
"maven",
|
|
60
|
+
"gradle",
|
|
61
|
+
"image-generation",
|
|
62
|
+
"text-to-image",
|
|
63
|
+
"image-api",
|
|
64
|
+
"nano-banana-api"
|
|
54
65
|
],
|
|
55
66
|
"author": "RunAPI",
|
|
56
67
|
"license": "Apache-2.0",
|
|
@@ -58,5 +69,8 @@
|
|
|
58
69
|
"repository": {
|
|
59
70
|
"type": "git",
|
|
60
71
|
"url": "git+https://github.com/runapi-ai/nano-banana-sdk.git"
|
|
72
|
+
},
|
|
73
|
+
"bugs": {
|
|
74
|
+
"url": "https://github.com/runapi-ai/nano-banana-sdk/issues"
|
|
61
75
|
}
|
|
62
76
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</div>
|
|
22
22
|
<br/>
|
|
23
23
|
|
|
24
|
-
Generate and edit images with Nano Banana standard, pro, and edit models. This skill helps Claude Code, Codex, Gemini CLI, Cursor, and 50+ agents integrate Nano Banana through RunAPI.
|
|
24
|
+
Generate and edit images with Nano Banana standard, pro, v2, v2 lite, and edit models. This skill helps Claude Code, Codex, Gemini CLI, Cursor, and 50+ agents integrate Nano Banana through RunAPI.
|
|
25
25
|
|
|
26
26
|
The canonical agent file is `skills/nano-banana/SKILL.md`.
|
|
27
27
|
|
|
@@ -74,6 +74,7 @@ const url = result.images[0].url;
|
|
|
74
74
|
- [Pro](https://runapi.ai/models/nano-banana/pro)
|
|
75
75
|
- [Edit](https://runapi.ai/models/nano-banana/edit)
|
|
76
76
|
- [Nano Banana 2](https://runapi.ai/models/nano-banana/2)
|
|
77
|
+
- [Nano Banana 2 Lite](https://runapi.ai/models/nano-banana/2-lite)
|
|
77
78
|
|
|
78
79
|
## Agent rules
|
|
79
80
|
|
|
@@ -81,7 +82,7 @@ const url = result.images[0].url;
|
|
|
81
82
|
- RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
|
|
82
83
|
- Keep API keys in `RUNAPI_API_KEY` or RunAPI CLI config; never commit secrets.
|
|
83
84
|
- Prefer `create`, `get`, and `run` JSON passthrough patterns instead of inventing flags for every model parameter.
|
|
84
|
-
- For
|
|
85
|
+
- For pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
|
|
85
86
|
|
|
86
87
|
## License
|
|
87
88
|
|
|
@@ -36,7 +36,7 @@ Generate and edit images with Nano Banana through RunAPI. The default path for o
|
|
|
36
36
|
When integrating Nano Banana into an app, backend, worker, library, Rails service, Node service, Go service, webhook pipeline, or production workflow, start by checking the current SDK package and official usage. Confirm install commands, client methods (`create`, `get`, `run`), request fields, response shape, and error classes before using CLI help or raw HTTP examples. Use a RunAPI SDK package:
|
|
37
37
|
|
|
38
38
|
- JavaScript / TypeScript: `@runapi.ai/nano-banana`
|
|
39
|
-
- Ruby: `runapi-
|
|
39
|
+
- Ruby: `runapi-nano-banana`
|
|
40
40
|
- Go: `github.com/runapi-ai/nano-banana-sdk/go`
|
|
41
41
|
|
|
42
42
|
## CLI path
|
|
@@ -81,4 +81,4 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
|
|
|
81
81
|
- [Pro](https://runapi.ai/models/nano-banana/pro.md)
|
|
82
82
|
- [Edit](https://runapi.ai/models/nano-banana/edit.md)
|
|
83
83
|
- [Nano Banana 2](https://runapi.ai/models/nano-banana/2.md)
|
|
84
|
-
|
|
84
|
+
- [Nano Banana 2 Lite](https://runapi.ai/models/nano-banana/2-lite.md)
|