@runapi.ai/nano-banana 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Nano Banana API JavaScript SDK for RunAPI
2
+
3
+ The nano banana api JavaScript SDK is the language-specific package for Nano Banana on RunAPI. Use this nano banana api package for text-to-image, image-to-image, edit, and creative production flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
4
+
5
+ This nano banana api 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
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @runapi.ai/nano-banana
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```typescript
16
+ import { NanoBananaClient } from '@runapi.ai/nano-banana';
17
+
18
+ const client = new NanoBananaClient();
19
+ const task = await client.generations.create({
20
+ // Pass the Nano Banana JSON request body from https://runapi.ai/docs#nano-banana.
21
+ });
22
+ const status = await client.generations.get(task.id);
23
+ ```
24
+
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.
26
+
27
+ ## Language notes
28
+
29
+ Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The available resources include generations, and edits. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
30
+
31
+ ## Links
32
+
33
+ - Model page: https://runapi.ai/models/nano-banana
34
+ - SDK docs: https://runapi.ai/docs#sdk-nano-banana
35
+ - Product docs: https://runapi.ai/docs#nano-banana
36
+ - Pricing and rate limits: https://runapi.ai/models/nano-banana/nano-banana
37
+ - Provider comparison: https://runapi.ai/providers/google
38
+ - Full catalog: https://runapi.ai/models
39
+ - Repository: https://github.com/runapi-ai/nano-banana-sdk
40
+
41
+ ## License
42
+
43
+ Licensed under the Apache License, Version 2.0.
@@ -0,0 +1,129 @@
1
+ import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOptions } from '@runapi.ai/core';
2
+ export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundError, RateLimitError, RunApiError, ServiceUnavailableError, TaskFailedError, TaskTimeoutError, TimeoutError, ValidationError } from '@runapi.ai/core';
3
+
4
+ type TextToImageModel = 'nano-banana' | 'nano-banana-pro' | 'nano-banana-2';
5
+ type EditImageModel = 'nano-banana-edit';
6
+ /**
7
+ * Base model aspect ratio options.
8
+ * Note: Base model uses 'image_size' parameter which includes 'auto' option.
9
+ */
10
+ type ImageSize = '1:1' | '9:16' | '16:9' | '3:4' | '4:3' | '3:2' | '2:3' | '5:4' | '4:5' | '21:9' | 'auto';
11
+ /**
12
+ * Pro model aspect ratio options.
13
+ * Note: Pro model uses 'aspect_ratio' parameter (includes 'auto' option).
14
+ */
15
+ type AspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
16
+ /**
17
+ * V2 model aspect ratio options. Superset of Pro, adding extreme ratios
18
+ * (1:4, 1:8, 4:1, 8:1). Default is 'auto'.
19
+ */
20
+ type AspectRatioV2 = AspectRatio | '1:4' | '1:8' | '4:1' | '8:1';
21
+ type Resolution = '1K' | '2K' | '4K';
22
+ type OutputFormat = 'png' | 'jpg' | 'jpeg';
23
+ interface GenerationBaseParams {
24
+ model: 'nano-banana';
25
+ prompt: string;
26
+ callback_url?: string;
27
+ output_format?: OutputFormat;
28
+ image_size?: ImageSize;
29
+ image_input?: string[];
30
+ }
31
+ interface GenerationProParams {
32
+ model: 'nano-banana-pro';
33
+ prompt: string;
34
+ callback_url?: string;
35
+ output_format?: OutputFormat;
36
+ aspect_ratio?: AspectRatio;
37
+ resolution?: Resolution;
38
+ image_input?: string[];
39
+ }
40
+ interface GenerationV2Params {
41
+ model: 'nano-banana-2';
42
+ prompt: string;
43
+ callback_url?: string;
44
+ output_format?: OutputFormat;
45
+ aspect_ratio?: AspectRatioV2;
46
+ resolution?: Resolution;
47
+ image_input?: string[];
48
+ }
49
+ type TextToImageParams = GenerationBaseParams | GenerationProParams | GenerationV2Params;
50
+ interface EditImageParams {
51
+ model: 'nano-banana-edit';
52
+ prompt: string;
53
+ image_urls: string[];
54
+ callback_url?: string;
55
+ output_format?: OutputFormat;
56
+ image_size?: ImageSize;
57
+ }
58
+ interface TaskCreateResponse {
59
+ id: string;
60
+ }
61
+ interface TextToImageResponse {
62
+ id: string;
63
+ status: AsyncTaskStatus;
64
+ result_urls?: string[];
65
+ error?: string;
66
+ [key: string]: unknown;
67
+ }
68
+ interface EditImageResponse {
69
+ id: string;
70
+ status: AsyncTaskStatus;
71
+ result_urls?: string[];
72
+ error?: string;
73
+ [key: string]: unknown;
74
+ }
75
+ /**
76
+ * Resolved responses returned by the `run()` methods after polling sees
77
+ * `status: 'completed'`. Narrows the base response so `result_urls` is
78
+ * guaranteed non-optional in user code.
79
+ */
80
+ type CompletedTextToImageResponse = TextToImageResponse & {
81
+ status: 'completed';
82
+ result_urls: string[];
83
+ };
84
+ type CompletedEditImageResponse = EditImageResponse & {
85
+ status: 'completed';
86
+ result_urls: string[];
87
+ };
88
+
89
+ declare class TextToImage {
90
+ private readonly http;
91
+ constructor(http: HttpClient);
92
+ run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse>;
93
+ create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
94
+ get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
95
+ }
96
+
97
+ declare class EditImage {
98
+ private readonly http;
99
+ constructor(http: HttpClient);
100
+ run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse>;
101
+ create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
102
+ get(id: string, options?: RequestOptions): Promise<EditImageResponse>;
103
+ }
104
+
105
+ /**
106
+ * NanoBanana text-to-image API client.
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const client = new NanoBananaClient({
111
+ * apiKey: 'your-api-key',
112
+ * baseUrl: 'https://runapi.ai',
113
+ * });
114
+ *
115
+ * const result = await client.textToImage.run({
116
+ * model: 'flux-kontext-pro',
117
+ * prompt: 'A futuristic cityscape at night',
118
+ * });
119
+ * ```
120
+ */
121
+ declare class NanoBananaClient {
122
+ /** Text-to-image operations. */
123
+ readonly textToImage: TextToImage;
124
+ /** Image editing operations. */
125
+ readonly editImage: EditImage;
126
+ constructor(options?: ClientOptions);
127
+ }
128
+
129
+ export { type AspectRatio, type AspectRatioV2, type CompletedEditImageResponse, type CompletedTextToImageResponse, type EditImageModel, type EditImageParams, type EditImageResponse, type GenerationBaseParams, type GenerationProParams, type GenerationV2Params, type ImageSize, NanoBananaClient, type OutputFormat, type Resolution, type TaskCreateResponse, type TextToImageModel, type TextToImageParams, type TextToImageResponse };
@@ -0,0 +1,129 @@
1
+ import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOptions } from '@runapi.ai/core';
2
+ export { AuthenticationError, InsufficientCreditsError, NetworkError, NotFoundError, RateLimitError, RunApiError, ServiceUnavailableError, TaskFailedError, TaskTimeoutError, TimeoutError, ValidationError } from '@runapi.ai/core';
3
+
4
+ type TextToImageModel = 'nano-banana' | 'nano-banana-pro' | 'nano-banana-2';
5
+ type EditImageModel = 'nano-banana-edit';
6
+ /**
7
+ * Base model aspect ratio options.
8
+ * Note: Base model uses 'image_size' parameter which includes 'auto' option.
9
+ */
10
+ type ImageSize = '1:1' | '9:16' | '16:9' | '3:4' | '4:3' | '3:2' | '2:3' | '5:4' | '4:5' | '21:9' | 'auto';
11
+ /**
12
+ * Pro model aspect ratio options.
13
+ * Note: Pro model uses 'aspect_ratio' parameter (includes 'auto' option).
14
+ */
15
+ type AspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
16
+ /**
17
+ * V2 model aspect ratio options. Superset of Pro, adding extreme ratios
18
+ * (1:4, 1:8, 4:1, 8:1). Default is 'auto'.
19
+ */
20
+ type AspectRatioV2 = AspectRatio | '1:4' | '1:8' | '4:1' | '8:1';
21
+ type Resolution = '1K' | '2K' | '4K';
22
+ type OutputFormat = 'png' | 'jpg' | 'jpeg';
23
+ interface GenerationBaseParams {
24
+ model: 'nano-banana';
25
+ prompt: string;
26
+ callback_url?: string;
27
+ output_format?: OutputFormat;
28
+ image_size?: ImageSize;
29
+ image_input?: string[];
30
+ }
31
+ interface GenerationProParams {
32
+ model: 'nano-banana-pro';
33
+ prompt: string;
34
+ callback_url?: string;
35
+ output_format?: OutputFormat;
36
+ aspect_ratio?: AspectRatio;
37
+ resolution?: Resolution;
38
+ image_input?: string[];
39
+ }
40
+ interface GenerationV2Params {
41
+ model: 'nano-banana-2';
42
+ prompt: string;
43
+ callback_url?: string;
44
+ output_format?: OutputFormat;
45
+ aspect_ratio?: AspectRatioV2;
46
+ resolution?: Resolution;
47
+ image_input?: string[];
48
+ }
49
+ type TextToImageParams = GenerationBaseParams | GenerationProParams | GenerationV2Params;
50
+ interface EditImageParams {
51
+ model: 'nano-banana-edit';
52
+ prompt: string;
53
+ image_urls: string[];
54
+ callback_url?: string;
55
+ output_format?: OutputFormat;
56
+ image_size?: ImageSize;
57
+ }
58
+ interface TaskCreateResponse {
59
+ id: string;
60
+ }
61
+ interface TextToImageResponse {
62
+ id: string;
63
+ status: AsyncTaskStatus;
64
+ result_urls?: string[];
65
+ error?: string;
66
+ [key: string]: unknown;
67
+ }
68
+ interface EditImageResponse {
69
+ id: string;
70
+ status: AsyncTaskStatus;
71
+ result_urls?: string[];
72
+ error?: string;
73
+ [key: string]: unknown;
74
+ }
75
+ /**
76
+ * Resolved responses returned by the `run()` methods after polling sees
77
+ * `status: 'completed'`. Narrows the base response so `result_urls` is
78
+ * guaranteed non-optional in user code.
79
+ */
80
+ type CompletedTextToImageResponse = TextToImageResponse & {
81
+ status: 'completed';
82
+ result_urls: string[];
83
+ };
84
+ type CompletedEditImageResponse = EditImageResponse & {
85
+ status: 'completed';
86
+ result_urls: string[];
87
+ };
88
+
89
+ declare class TextToImage {
90
+ private readonly http;
91
+ constructor(http: HttpClient);
92
+ run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse>;
93
+ create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
94
+ get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
95
+ }
96
+
97
+ declare class EditImage {
98
+ private readonly http;
99
+ constructor(http: HttpClient);
100
+ run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse>;
101
+ create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
102
+ get(id: string, options?: RequestOptions): Promise<EditImageResponse>;
103
+ }
104
+
105
+ /**
106
+ * NanoBanana text-to-image API client.
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const client = new NanoBananaClient({
111
+ * apiKey: 'your-api-key',
112
+ * baseUrl: 'https://runapi.ai',
113
+ * });
114
+ *
115
+ * const result = await client.textToImage.run({
116
+ * model: 'flux-kontext-pro',
117
+ * prompt: 'A futuristic cityscape at night',
118
+ * });
119
+ * ```
120
+ */
121
+ declare class NanoBananaClient {
122
+ /** Text-to-image operations. */
123
+ readonly textToImage: TextToImage;
124
+ /** Image editing operations. */
125
+ readonly editImage: EditImage;
126
+ constructor(options?: ClientOptions);
127
+ }
128
+
129
+ export { type AspectRatio, type AspectRatioV2, type CompletedEditImageResponse, type CompletedTextToImageResponse, type EditImageModel, type EditImageParams, type EditImageResponse, type GenerationBaseParams, type GenerationProParams, type GenerationV2Params, type ImageSize, NanoBananaClient, type OutputFormat, type Resolution, type TaskCreateResponse, type TextToImageModel, type TextToImageParams, type TextToImageResponse };
package/dist/index.js ADDED
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AuthenticationError: () => import_core4.AuthenticationError,
24
+ InsufficientCreditsError: () => import_core4.InsufficientCreditsError,
25
+ NanoBananaClient: () => NanoBananaClient,
26
+ NetworkError: () => import_core4.NetworkError,
27
+ NotFoundError: () => import_core4.NotFoundError,
28
+ RateLimitError: () => import_core4.RateLimitError,
29
+ RunApiError: () => import_core4.RunApiError,
30
+ ServiceUnavailableError: () => import_core4.ServiceUnavailableError,
31
+ TaskFailedError: () => import_core4.TaskFailedError,
32
+ TaskTimeoutError: () => import_core4.TaskTimeoutError,
33
+ TimeoutError: () => import_core4.TimeoutError,
34
+ ValidationError: () => import_core4.ValidationError
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+
38
+ // src/client.ts
39
+ var import_core3 = require("@runapi.ai/core");
40
+
41
+ // src/resources/text-to-image.ts
42
+ var import_core = require("@runapi.ai/core");
43
+ var import_internal = require("@runapi.ai/core/internal");
44
+ var ENDPOINT = "/api/v1/nano_banana/text_to_image";
45
+ var TextToImage = class {
46
+ constructor(http) {
47
+ this.http = http;
48
+ }
49
+ http;
50
+ async run(params, options) {
51
+ const { id } = await this.create(params, options);
52
+ const response = await (0, import_internal.pollUntilComplete)(() => this.get(id, options), {
53
+ maxWaitMs: options?.maxWaitMs,
54
+ pollIntervalMs: options?.pollIntervalMs
55
+ });
56
+ return response;
57
+ }
58
+ async create(params, options) {
59
+ return this.http.request("POST", ENDPOINT, {
60
+ body: (0, import_core.compactParams)(params),
61
+ ...options
62
+ });
63
+ }
64
+ async get(id, options) {
65
+ return this.http.request("GET", `${ENDPOINT}/${id}`, {
66
+ ...options
67
+ });
68
+ }
69
+ };
70
+
71
+ // src/resources/edit-image.ts
72
+ var import_core2 = require("@runapi.ai/core");
73
+ var import_internal2 = require("@runapi.ai/core/internal");
74
+ var ENDPOINT2 = "/api/v1/nano_banana/edit_image";
75
+ var EditImage = class {
76
+ constructor(http) {
77
+ this.http = http;
78
+ }
79
+ http;
80
+ async run(params, options) {
81
+ const { id } = await this.create(params, options);
82
+ const response = await (0, import_internal2.pollUntilComplete)(() => this.get(id, options), {
83
+ maxWaitMs: options?.maxWaitMs,
84
+ pollIntervalMs: options?.pollIntervalMs
85
+ });
86
+ return response;
87
+ }
88
+ async create(params, options) {
89
+ return this.http.request("POST", ENDPOINT2, {
90
+ body: (0, import_core2.compactParams)(params),
91
+ ...options
92
+ });
93
+ }
94
+ async get(id, options) {
95
+ return this.http.request("GET", `${ENDPOINT2}/${id}`, {
96
+ ...options
97
+ });
98
+ }
99
+ };
100
+
101
+ // src/client.ts
102
+ var NanoBananaClient = class {
103
+ /** Text-to-image operations. */
104
+ textToImage;
105
+ /** Image editing operations. */
106
+ editImage;
107
+ constructor(options = {}) {
108
+ const http = (0, import_core3.createHttpClient)(options);
109
+ this.textToImage = new TextToImage(http);
110
+ this.editImage = new EditImage(http);
111
+ }
112
+ };
113
+
114
+ // src/index.ts
115
+ var import_core4 = require("@runapi.ai/core");
116
+ // Annotate the CommonJS export names for ESM import in node:
117
+ 0 && (module.exports = {
118
+ AuthenticationError,
119
+ InsufficientCreditsError,
120
+ NanoBananaClient,
121
+ NetworkError,
122
+ NotFoundError,
123
+ RateLimitError,
124
+ RunApiError,
125
+ ServiceUnavailableError,
126
+ TaskFailedError,
127
+ TaskTimeoutError,
128
+ TimeoutError,
129
+ ValidationError
130
+ });
131
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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 { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { EditImage } from './resources/edit-image';\n\n/**\n * NanoBanana text-to-image API client.\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: 'flux-kontext-pro',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class NanoBananaClient {\n /** Text-to-image operations. */\n public readonly textToImage: TextToImage;\n /** Image editing operations. */\n public readonly editImage: EditImage;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToImage = new TextToImage(http);\n this.editImage = new EditImage(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\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\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 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 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\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\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 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 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,eAAqD;;;ACCrD,kBAA8B;AAC9B,sBAAkC;AAQlC,IAAM,WAAW;AAEV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,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,EAEA,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,EAEA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ACnCA,IAAAC,eAA8B;AAC9B,IAAAC,mBAAkC;AAGlC,IAAMC,YAAW;AAEV,IAAM,YAAN,MAAgB;AAAA,EACrB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAAyB,SAAgF;AACjH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,UAAM,oCAAqC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACvF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAAyB,SAAuD;AAC3F,WAAO,KAAK,KAAK,QAA4B,QAAQA,WAAU;AAAA,MAC7D,UAAM,4BAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAsD;AAC1E,WAAO,KAAK,KAAK,QAA2B,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI;AAAA,MACtE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AFXO,IAAM,mBAAN,MAAuB;AAAA;AAAA,EAEZ;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,WAAO,+BAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,YAAY,IAAI,UAAU,IAAI;AAAA,EACrC;AACF;;;AD3BA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","import_core"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,105 @@
1
+ // src/client.ts
2
+ import { createHttpClient } from "@runapi.ai/core";
3
+
4
+ // src/resources/text-to-image.ts
5
+ import { compactParams } from "@runapi.ai/core";
6
+ import { pollUntilComplete } from "@runapi.ai/core/internal";
7
+ var ENDPOINT = "/api/v1/nano_banana/text_to_image";
8
+ var TextToImage = class {
9
+ constructor(http) {
10
+ this.http = http;
11
+ }
12
+ http;
13
+ async run(params, options) {
14
+ const { id } = await this.create(params, options);
15
+ const response = await pollUntilComplete(() => this.get(id, options), {
16
+ maxWaitMs: options?.maxWaitMs,
17
+ pollIntervalMs: options?.pollIntervalMs
18
+ });
19
+ return response;
20
+ }
21
+ async create(params, options) {
22
+ return this.http.request("POST", ENDPOINT, {
23
+ body: compactParams(params),
24
+ ...options
25
+ });
26
+ }
27
+ async get(id, options) {
28
+ return this.http.request("GET", `${ENDPOINT}/${id}`, {
29
+ ...options
30
+ });
31
+ }
32
+ };
33
+
34
+ // src/resources/edit-image.ts
35
+ import { compactParams as compactParams2 } from "@runapi.ai/core";
36
+ import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
37
+ var ENDPOINT2 = "/api/v1/nano_banana/edit_image";
38
+ var EditImage = class {
39
+ constructor(http) {
40
+ this.http = http;
41
+ }
42
+ http;
43
+ async run(params, options) {
44
+ const { id } = await this.create(params, options);
45
+ const response = await pollUntilComplete2(() => this.get(id, options), {
46
+ maxWaitMs: options?.maxWaitMs,
47
+ pollIntervalMs: options?.pollIntervalMs
48
+ });
49
+ return response;
50
+ }
51
+ async create(params, options) {
52
+ return this.http.request("POST", ENDPOINT2, {
53
+ body: compactParams2(params),
54
+ ...options
55
+ });
56
+ }
57
+ async get(id, options) {
58
+ return this.http.request("GET", `${ENDPOINT2}/${id}`, {
59
+ ...options
60
+ });
61
+ }
62
+ };
63
+
64
+ // src/client.ts
65
+ var NanoBananaClient = class {
66
+ /** Text-to-image operations. */
67
+ textToImage;
68
+ /** Image editing operations. */
69
+ editImage;
70
+ constructor(options = {}) {
71
+ const http = createHttpClient(options);
72
+ this.textToImage = new TextToImage(http);
73
+ this.editImage = new EditImage(http);
74
+ }
75
+ };
76
+
77
+ // src/index.ts
78
+ import {
79
+ RunApiError,
80
+ AuthenticationError,
81
+ InsufficientCreditsError,
82
+ NotFoundError,
83
+ ValidationError,
84
+ RateLimitError,
85
+ ServiceUnavailableError,
86
+ NetworkError,
87
+ TimeoutError,
88
+ TaskTimeoutError,
89
+ TaskFailedError
90
+ } from "@runapi.ai/core";
91
+ export {
92
+ AuthenticationError,
93
+ InsufficientCreditsError,
94
+ NanoBananaClient,
95
+ NetworkError,
96
+ NotFoundError,
97
+ RateLimitError,
98
+ RunApiError,
99
+ ServiceUnavailableError,
100
+ TaskFailedError,
101
+ TaskTimeoutError,
102
+ TimeoutError,
103
+ ValidationError
104
+ };
105
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/resources/edit-image.ts","../src/index.ts"],"sourcesContent":["import { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { EditImage } from './resources/edit-image';\n\n/**\n * NanoBanana text-to-image API client.\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: 'flux-kontext-pro',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class NanoBananaClient {\n /** Text-to-image operations. */\n public readonly textToImage: TextToImage;\n /** Image editing operations. */\n public readonly editImage: EditImage;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToImage = new TextToImage(http);\n this.editImage = new EditImage(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\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\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 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 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\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\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 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 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,wBAA4C;;;ACCrD,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAQlC,IAAM,WAAW;AAEV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,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,EAEA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,MAAM,cAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ACnCA,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,qBAAAC,0BAAyB;AAGlC,IAAMC,YAAW;AAEV,IAAM,YAAN,MAAgB;AAAA,EACrB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAAyB,SAAgF;AACjH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAMD,mBAAqC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACvF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAAyB,SAAuD;AAC3F,WAAO,KAAK,KAAK,QAA4B,QAAQC,WAAU;AAAA,MAC7D,MAAMF,eAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAsD;AAC1E,WAAO,KAAK,KAAK,QAA2B,OAAO,GAAGE,SAAQ,IAAI,EAAE,IAAI;AAAA,MACtE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AFXO,IAAM,mBAAN,MAAuB;AAAA;AAAA,EAEZ;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO,iBAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,YAAY,IAAI,UAAU,IAAI;AAAA,EACrC;AACF;;;AG3BA;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"]}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@runapi.ai/nano-banana",
3
+ "version": "0.2.0",
4
+ "description": "RunAPI Nano Banana SDK for JavaScript, Ruby, and Go",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "skills",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "engines": {
22
+ "node": ">=18.0.0"
23
+ },
24
+ "scripts": {
25
+ "build": "tsup",
26
+ "test": "vitest run",
27
+ "typecheck": "tsc --noEmit",
28
+ "clean": "rm -rf dist",
29
+ "test:base": "dotenv -e manual-tests/.env -- tsx manual-tests/test-generation-base.ts",
30
+ "test:pro": "dotenv -e manual-tests/.env -- tsx manual-tests/test-generation-pro.ts",
31
+ "test:edit": "dotenv -e manual-tests/.env -- tsx manual-tests/test-edit.ts",
32
+ "test:polling": "dotenv -e manual-tests/.env -- tsx manual-tests/test-polling.ts",
33
+ "test:errors": "dotenv -e manual-tests/.env -- tsx manual-tests/test-error-handling.ts",
34
+ "test:all": "dotenv -e manual-tests/.env -- tsx manual-tests/test-all.ts",
35
+ "test:manual": "pnpm run test:all"
36
+ },
37
+ "dependencies": {
38
+ "@runapi.ai/core": "^0.2.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^20.0.0",
42
+ "@vitest/coverage-v8": "^1.6.0",
43
+ "dotenv-cli": "^11.0.0",
44
+ "tsup": "^8.0.0",
45
+ "tsx": "^4.7.0",
46
+ "typescript": "^5.4.0",
47
+ "vitest": "^1.6.0"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "keywords": [
53
+ "runapi",
54
+ "runapi-ai",
55
+ "nano-banana",
56
+ "api",
57
+ "sdk",
58
+ "typescript",
59
+ "ruby",
60
+ "golang"
61
+ ],
62
+ "author": "RunAPI",
63
+ "license": "Apache-2.0",
64
+ "homepage": "https://runapi.ai/models/nano-banana",
65
+ "repository": {
66
+ "type": "git",
67
+ "url": "git+https://github.com/runapi-ai/nano-banana-sdk.git"
68
+ }
69
+ }
@@ -0,0 +1,54 @@
1
+ # Nano Banana API Skill for RunAPI
2
+
3
+ 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.
4
+
5
+ The canonical agent file is `skills/nano-banana/SKILL.md`.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npx skills add runapi-ai/nano-banana -g
11
+ ```
12
+
13
+ Or manually: clone this repo and copy `skills/nano-banana/` into your agent's skills directory.
14
+
15
+ ## Quick example
16
+
17
+ ```typescript
18
+ import { NanoBananaClient } from '@runapi.ai/nano-banana';
19
+
20
+ const client = new NanoBananaClient();
21
+ const result = await client.textToImage.run({
22
+ model: 'nano-banana',
23
+ prompt: 'A bowl of fruit on a wooden table, soft daylight',
24
+ image_size: '16:9',
25
+ });
26
+ const url = result.result_urls[0];
27
+ ```
28
+
29
+ ## Routing
30
+
31
+ - Model page: https://runapi.ai/models/nano-banana
32
+ - Product docs: https://runapi.ai/docs#nano-banana
33
+ - SDK docs: https://runapi.ai/docs#sdk-nano-banana
34
+ - SDK repository: https://github.com/runapi-ai/nano-banana-sdk
35
+ - Pricing and rate limits: https://runapi.ai/models/nano-banana/nano-banana
36
+ - Provider comparison: https://runapi.ai/providers/google
37
+ - Browse all RunAPI models and skills: https://runapi.ai/models
38
+
39
+ ## Variants
40
+
41
+ - [Standard](https://runapi.ai/models/nano-banana/nano-banana)
42
+ - [Pro](https://runapi.ai/models/nano-banana/pro)
43
+ - [Edit](https://runapi.ai/models/nano-banana/edit)
44
+ - [Nano Banana 2](https://runapi.ai/models/nano-banana/2)
45
+
46
+ ## Agent rules
47
+
48
+ - Keep API keys in `RUNAPI_API_KEY` or RunAPI CLI config; never commit secrets.
49
+ - Prefer `create`, `get`, and `run` JSON passthrough patterns instead of inventing flags for every model parameter.
50
+ - For nano banana api pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
51
+
52
+ ## License
53
+
54
+ Licensed under the Apache License, Version 2.0.
@@ -0,0 +1,206 @@
1
+ ---
2
+ name: nano-banana
3
+ description: Generate and edit images (Nano Banana base / pro text-to-image and image-to-image, Nano Banana Edit) through RunAPI.ai using the @runapi.ai/nano-banana Node/TypeScript SDK. Use when the user asks to add Nano Banana image generation or editing, or writes against @runapi.ai/nano-banana. Triggers on "nano banana", "nano-banana", "image generation", "image edit", "生成图片", "图片编辑", "@runapi.ai/nano-banana".
4
+ documentation: https://runapi.ai/models/nano-banana
5
+ provider_page: https://runapi.ai/providers/google
6
+ catalog: https://runapi.ai/models
7
+ ---
8
+ # @runapi.ai/nano-banana — RunAPI.ai Nano Banana image generation
9
+
10
+ Build Node / TypeScript integrations that generate and edit images through RunAPI.ai.
11
+
12
+ ## Setup
13
+
14
+ Requires **Node 18+** (global `fetch`).
15
+
16
+ ```bash
17
+ npm install @runapi.ai/nano-banana
18
+ ```
19
+
20
+ Set your API key in the environment:
21
+
22
+ ```dotenv
23
+ # .env
24
+ RUNAPI_API_KEY=runapi_xxx # get one at https://runapi.ai/settings/api_keys
25
+ ```
26
+
27
+ ```ts
28
+ import { NanoBananaClient } from '@runapi.ai/nano-banana';
29
+
30
+ // The SDK reads RUNAPI_API_KEY from the environment automatically.
31
+ const client = new NanoBananaClient();
32
+ ```
33
+
34
+ Pass `{ apiKey }` explicitly if you manage secrets differently. `baseUrl` defaults to `https://runapi.ai`; override only for local development.
35
+
36
+ ## Core recipe — text to image
37
+
38
+ ```ts
39
+ const result = await client.textToImage.run({
40
+ model: 'nano-banana',
41
+ prompt: 'A bowl of fruit on a wooden table, soft daylight',
42
+ image_size: '16:9',
43
+ });
44
+
45
+ const url = result.result_urls[0];
46
+ ```
47
+
48
+ `run()` creates the task, auto-polls, and resolves only when the task completes — `result_urls[0]` is guaranteed on the resolved value. On failure it throws `TaskFailedError`; on polling timeout it throws `TaskTimeoutError`. Use `run()` for scripts and short-lived processes. For request handlers, split it:
49
+
50
+ ```ts
51
+ const { id } = await client.textToImage.create({ model: 'nano-banana', prompt: '...' });
52
+ // return 202 immediately; fetch later:
53
+ const status = await client.textToImage.get(id);
54
+ if (status.status === 'completed') { /* ... */ }
55
+ ```
56
+
57
+ Do not hold a web worker open waiting on `run()`. Split + webhook is the production pattern.
58
+
59
+ `run()` polls every 2 s for up to 15 min by default. Tune when needed:
60
+
61
+ ```ts
62
+ await client.textToImage.run(params, { maxWaitMs: 5 * 60_000, pollIntervalMs: 2_000 });
63
+ ```
64
+
65
+ If `TaskTimeoutError` fires, the task is still running server-side — resume with `textToImage.get(id)` or finish via webhook.
66
+
67
+ ## Pro model — higher fidelity + resolution
68
+
69
+ ```ts
70
+ const result = await client.textToImage.run({
71
+ model: 'nano-banana-pro',
72
+ prompt: 'A futuristic city skyline at dusk',
73
+ aspect_ratio: '16:9', // pro uses aspect_ratio, not image_size
74
+ resolution: '2K', // 1K | 2K | 4K
75
+ output_format: 'jpeg',
76
+ });
77
+ ```
78
+
79
+ You can also pass `image_input: string[]` on any text-to-image model for image-guided generation.
80
+
81
+ ## V2 model — long prompts + wider aspect ratios
82
+
83
+ ```ts
84
+ const result = await client.textToImage.run({
85
+ model: 'nano-banana-2',
86
+ prompt: '...up to 20,000 characters, with up to 14 reference images...',
87
+ aspect_ratio: '1:8', // v2 adds extreme ratios 1:4, 1:8, 4:1, 8:1
88
+ resolution: '2K', // 1K | 2K | 4K (billed 16¢ / 24¢ / 36¢)
89
+ output_format: 'jpg',
90
+ });
91
+ ```
92
+
93
+ ## EditImage — transform an existing image
94
+
95
+ ```ts
96
+ const edited = await client.editImage.run({
97
+ model: 'nano-banana-edit',
98
+ prompt: 'Make it look like a watercolor painting',
99
+ image_urls: ['https://cdn.example.com/source.jpg'],
100
+ image_size: '1:1',
101
+ });
102
+
103
+ console.log(edited.result_urls[0]);
104
+ ```
105
+
106
+ ## Models
107
+
108
+ | `model` | Params | Use case |
109
+ |---|---|---|
110
+ | `nano-banana` | `image_size`, `image_input?` | Base text-to-image / image-guided. |
111
+ | `nano-banana-pro` | `aspect_ratio`, `resolution`, `image_input?` | Higher fidelity, 1K/2K/4K. |
112
+ | `nano-banana-2` | `aspect_ratio`, `resolution`, `image_input?` | V2: long prompts (≤20k chars), ≤14 reference images, extra aspect ratios. |
113
+ | `nano-banana-edit` | `image_urls`, `image_size` | Prompt-driven edit of a source image. |
114
+
115
+ `image_size` / `aspect_ratio` values (base / pro): `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9`, `auto`. V2 adds `1:4`, `1:8`, `4:1`, `8:1`. `output_format`: `png` / `jpg` / `jpeg`.
116
+
117
+ Exact credit costs per model are shown at https://runapi.ai/pricing and in the dashboard — do not hardcode prices in application code.
118
+
119
+ ## Callbacks (webhooks)
120
+
121
+ Pass `callback_url` on `create()` (or any `run()` call) and RunAPI will POST the final payload to you:
122
+
123
+ ```ts
124
+ await client.textToImage.create({
125
+ model: 'nano-banana',
126
+ prompt: '...',
127
+ callback_url: 'https://your.app/webhooks/runapi/nano-banana',
128
+ });
129
+ ```
130
+
131
+ Payload shape:
132
+
133
+ ```ts
134
+ { id: string; status: 'completed' | 'failed'; result_urls?: string[]; error?: string }
135
+ ```
136
+
137
+ **Always verify the signature before trusting the body.** RunAPI signs every callback with your account's Callback Secret (rotate at `/accounts/callback_secret`). Headers:
138
+
139
+ - `X-Callback-Id` — UUID, store to make handler idempotent
140
+ - `X-Callback-Timestamp` — unix seconds, reject if `|now - ts| > 300`
141
+ - `X-Callback-Signature` — base64 HMAC-SHA256 over `` `${id}.${ts}.${rawBody}` `` using the base64-decoded secret
142
+
143
+ ```ts
144
+ import crypto from 'node:crypto';
145
+
146
+ function verify(raw: string, id: string, ts: string, sig: string, secret: string) {
147
+ const key = Buffer.from(secret, 'base64');
148
+ const mac = crypto.createHmac('sha256', key)
149
+ .update(`${id}.${ts}.${raw}`)
150
+ .digest('base64');
151
+ return crypto.timingSafeEqual(Buffer.from(mac), Buffer.from(sig));
152
+ }
153
+ ```
154
+
155
+ Reply `2xx` within 10s; any non-2xx triggers retries.
156
+
157
+ ## Errors
158
+
159
+ All errors are re-exported from `@runapi.ai/core`. Always `instanceof` — never string-match messages.
160
+
161
+ | Error | Status | Action |
162
+ |---|---|---|
163
+ | `AuthenticationError` | 401 | abort; surface "reconnect your API key" |
164
+ | `InsufficientCreditsError` | 402 | prompt user to top up at runapi.ai/billing |
165
+ | `ValidationError` | 400 / 422 | fix params; do not retry |
166
+ | `RateLimitError` | 429 | sleep `err.retryAfterMs`, then retry |
167
+ | `ServiceUnavailableError` | 503 / 455 | retry with backoff; transient service issue |
168
+ | `TaskFailedError` | — | show `err.details` to user; do not auto-retry |
169
+ | `TaskTimeoutError` | — | re-poll with `<resource>.get(id)` |
170
+
171
+ ```ts
172
+ import { InsufficientCreditsError, TaskFailedError } from '@runapi.ai/nano-banana';
173
+
174
+ try {
175
+ await client.textToImage.run({ model: 'nano-banana', prompt: '...' });
176
+ } catch (err) {
177
+ if (err instanceof InsufficientCreditsError) { /* surface top-up CTA */ }
178
+ else if (err instanceof TaskFailedError) { /* show err.details */ }
179
+ else throw err;
180
+ }
181
+ ```
182
+
183
+ ## Gotchas
184
+
185
+ - `model` is required on every call.
186
+ - The base model uses **`image_size`**; pro and v2 use **`aspect_ratio`**. They are different fields — do not substitute one for the other.
187
+ - `resolution` (`1K` / `2K` / `4K`) applies to `nano-banana-pro` and `nano-banana-2`.
188
+ - EditImage (`editImage.run`) require `image_urls` (an array), not `image_input`.
189
+ - Response uses `result_urls` (an array of URL strings), not `images` or `videos`.
190
+ - `callback_url` must be reachable from the public internet. `localhost` / `127.0.0.1` URLs will never fire — use a tunnel (cloudflared, ngrok, tailscale funnel) when developing locally.
191
+
192
+ ## Dig deeper
193
+
194
+ Package README (full API surface, all params): `node_modules/@runapi.ai/nano-banana/README.md`. Types: `@runapi.ai/nano-banana/dist/types.d.ts`. Product docs: https://runapi.ai/docs.
195
+
196
+ ## RunAPI public routing
197
+
198
+ nano banana api public links use the API-379 catalog route map. The main nano banana api page is https://runapi.ai/models/nano-banana. SDK docs live at https://runapi.ai/docs#sdk-nano-banana and product docs live at https://runapi.ai/docs#nano-banana.
199
+
200
+ Pricing, rate limits, and commercial usage for nano banana api should point to the most specific variant page:
201
+ - [Standard](https://runapi.ai/models/nano-banana/nano-banana)
202
+ - [Pro](https://runapi.ai/models/nano-banana/pro)
203
+ - [Edit](https://runapi.ai/models/nano-banana/edit)
204
+ - [Nano Banana 2](https://runapi.ai/models/nano-banana/2)
205
+
206
+ Compare Nano Banana with other Google models at https://runapi.ai/providers/google. Browse every RunAPI model and skill at https://runapi.ai/models. SDK repository: https://github.com/runapi-ai/nano-banana-sdk. Skill repository: https://github.com/runapi-ai/nano-banana.