@runapi.ai/nano-banana 0.2.4 → 0.2.6
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 +3 -1
- package/dist/index.d.mts +101 -32
- package/dist/index.d.ts +101 -32
- package/dist/index.js +42 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -10
- package/skills/nano-banana/README.md +4 -2
- package/skills/nano-banana/SKILL.md +17 -12
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Nano Banana API JavaScript SDK for RunAPI
|
|
2
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
|
|
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 editing, and creative production flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
|
|
4
4
|
|
|
5
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
6
|
|
|
@@ -24,6 +24,8 @@ const status = await client.generations.get(task.id);
|
|
|
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.
|
|
26
26
|
|
|
27
|
+
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.
|
|
28
|
+
|
|
27
29
|
## Language notes
|
|
28
30
|
|
|
29
31
|
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.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,109 +1,178 @@
|
|
|
1
|
-
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOptions } from '@runapi.ai/core';
|
|
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 (longest prompts + extreme ratios). */
|
|
4
5
|
type TextToImageModel = 'nano-banana' | 'nano-banana-pro' | 'nano-banana-2';
|
|
6
|
+
/** Dedicated editing model. Requires source images to transform. */
|
|
5
7
|
type EditImageModel = 'nano-banana-edit';
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
*/
|
|
8
|
+
/** Aspect ratio options for the standard model. */
|
|
9
|
+
type BaseAspectRatio = '1:1' | '9:16' | '16:9' | '3:4' | '4:3' | '3:2' | '2:3' | '5:4' | '4:5' | '21:9' | 'auto';
|
|
10
|
+
/** Aspect ratio options for the pro model. */
|
|
15
11
|
type AspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
|
|
16
12
|
/**
|
|
17
|
-
* V2 model aspect ratio options. Superset of
|
|
18
|
-
* (1:4, 1:8, 4:1, 8:1). Default is 'auto'.
|
|
13
|
+
* V2 model aspect ratio options. Superset of pro ratios, adding extreme
|
|
14
|
+
* panoramic/tall ratios (1:4, 1:8, 4:1, 8:1). Default is 'auto'.
|
|
19
15
|
*/
|
|
20
16
|
type AspectRatioV2 = AspectRatio | '1:4' | '1:8' | '4:1' | '8:1';
|
|
21
|
-
|
|
17
|
+
/** Output resolution tier. Pro and v2 default to 1k; higher tiers increase generation time. */
|
|
18
|
+
type OutputResolution = '1k' | '2k' | '4k';
|
|
19
|
+
/** Output image encoding format. */
|
|
22
20
|
type OutputFormat = 'png' | 'jpg' | 'jpeg';
|
|
21
|
+
/** Standard tier generation. Up to 8 reference images, max 5000-char prompt. */
|
|
23
22
|
interface GenerationBaseParams {
|
|
24
23
|
model: 'nano-banana';
|
|
25
24
|
prompt: string;
|
|
26
25
|
callback_url?: string;
|
|
27
26
|
output_format?: OutputFormat;
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
aspect_ratio?: BaseAspectRatio;
|
|
28
|
+
/** Optional visual guidance images (up to 8, max 30 MB each). */
|
|
29
|
+
reference_image_urls?: string[];
|
|
30
30
|
}
|
|
31
|
+
/** Pro tier generation. Adds output resolution control and wider aspect ratio set. */
|
|
31
32
|
interface GenerationProParams {
|
|
32
33
|
model: 'nano-banana-pro';
|
|
33
34
|
prompt: string;
|
|
34
35
|
callback_url?: string;
|
|
35
36
|
output_format?: OutputFormat;
|
|
36
37
|
aspect_ratio?: AspectRatio;
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
output_resolution?: OutputResolution;
|
|
39
|
+
/** Optional visual guidance images (up to 8, max 30 MB each). */
|
|
40
|
+
reference_image_urls?: string[];
|
|
39
41
|
}
|
|
42
|
+
/** V2 tier generation. Longest prompts (up to 20000 chars), extreme aspect ratios, up to 14 reference images. */
|
|
40
43
|
interface GenerationV2Params {
|
|
41
44
|
model: 'nano-banana-2';
|
|
42
45
|
prompt: string;
|
|
43
46
|
callback_url?: string;
|
|
44
47
|
output_format?: OutputFormat;
|
|
45
48
|
aspect_ratio?: AspectRatioV2;
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
output_resolution?: OutputResolution;
|
|
50
|
+
/** Optional visual guidance images (up to 14, max 30 MB each). */
|
|
51
|
+
reference_image_urls?: string[];
|
|
48
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Text-to-image parameters. A discriminated union on `model`: the accepted
|
|
55
|
+
* aspect ratios, prompt length, resolution, and reference image count differ per tier.
|
|
56
|
+
*/
|
|
49
57
|
type TextToImageParams = GenerationBaseParams | GenerationProParams | GenerationV2Params;
|
|
58
|
+
/**
|
|
59
|
+
* Edit image parameters. Requires source images to modify according to the prompt.
|
|
60
|
+
* Up to 10 source images, max 10 MB each.
|
|
61
|
+
*/
|
|
50
62
|
interface EditImageParams {
|
|
51
63
|
model: 'nano-banana-edit';
|
|
64
|
+
/** Edit instruction describing the desired changes (up to 5000 chars). */
|
|
52
65
|
prompt: string;
|
|
53
|
-
|
|
66
|
+
/** Source images to edit (up to 10 images, max 10 MB each). */
|
|
67
|
+
source_image_urls: string[];
|
|
54
68
|
callback_url?: string;
|
|
55
69
|
output_format?: OutputFormat;
|
|
56
|
-
|
|
70
|
+
aspect_ratio?: BaseAspectRatio;
|
|
57
71
|
}
|
|
58
72
|
interface TaskCreateResponse {
|
|
59
73
|
id: string;
|
|
60
74
|
}
|
|
75
|
+
/** A single generated or edited image result. */
|
|
76
|
+
interface Image {
|
|
77
|
+
/** CDN-delivered image URL. */
|
|
78
|
+
url: string;
|
|
79
|
+
/** Pre-CDN original location, when available. */
|
|
80
|
+
origin_url?: string;
|
|
81
|
+
}
|
|
82
|
+
/** Task result for a text-to-image generation request. */
|
|
61
83
|
interface TextToImageResponse {
|
|
62
84
|
id: string;
|
|
63
85
|
status: AsyncTaskStatus;
|
|
64
|
-
|
|
86
|
+
/** Output images, populated once the task completes successfully. */
|
|
87
|
+
images?: Image[];
|
|
88
|
+
/** Error message when the task has failed. */
|
|
65
89
|
error?: string;
|
|
66
90
|
[key: string]: unknown;
|
|
67
91
|
}
|
|
92
|
+
/** Task result for an image editing request. */
|
|
68
93
|
interface EditImageResponse {
|
|
69
94
|
id: string;
|
|
70
95
|
status: AsyncTaskStatus;
|
|
71
|
-
|
|
96
|
+
/** Output images, populated once the task completes successfully. */
|
|
97
|
+
images?: Image[];
|
|
98
|
+
/** Error message when the task has failed. */
|
|
72
99
|
error?: string;
|
|
73
100
|
[key: string]: unknown;
|
|
74
101
|
}
|
|
75
102
|
/**
|
|
76
103
|
* Resolved responses returned by the `run()` methods after polling sees
|
|
77
|
-
* `status: 'completed'`. Narrows the base response so `
|
|
104
|
+
* `status: 'completed'`. Narrows the base response so `images` is
|
|
78
105
|
* guaranteed non-optional in user code.
|
|
79
106
|
*/
|
|
80
107
|
type CompletedTextToImageResponse = TextToImageResponse & {
|
|
81
108
|
status: 'completed';
|
|
82
|
-
|
|
109
|
+
images: Image[];
|
|
83
110
|
};
|
|
84
111
|
type CompletedEditImageResponse = EditImageResponse & {
|
|
85
112
|
status: 'completed';
|
|
86
|
-
|
|
113
|
+
images: Image[];
|
|
87
114
|
};
|
|
88
115
|
|
|
116
|
+
/** Generates images from text prompts with optional reference image guidance. Model tier controls prompt length, resolution, and reference image limits. */
|
|
89
117
|
declare class TextToImage {
|
|
90
118
|
private readonly http;
|
|
91
119
|
constructor(http: HttpClient);
|
|
120
|
+
/**
|
|
121
|
+
* Generate an image from a text prompt and wait until complete.
|
|
122
|
+
* @param params Generation parameters.
|
|
123
|
+
* @param options Per-request and polling overrides.
|
|
124
|
+
* @returns The completed generation with image results.
|
|
125
|
+
*/
|
|
92
126
|
run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse>;
|
|
127
|
+
/**
|
|
128
|
+
* Create an image generation task; returns immediately with a task id.
|
|
129
|
+
* @param params Generation parameters.
|
|
130
|
+
* @param options Per-request overrides.
|
|
131
|
+
* @returns The task creation result with id.
|
|
132
|
+
*/
|
|
93
133
|
create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
134
|
+
/**
|
|
135
|
+
* Fetch the current status of an image generation task.
|
|
136
|
+
* @param id The task id.
|
|
137
|
+
* @param options Per-request overrides.
|
|
138
|
+
* @returns The current image generation task status.
|
|
139
|
+
*/
|
|
94
140
|
get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
|
|
95
141
|
}
|
|
96
142
|
|
|
143
|
+
/** Modifies existing images based on text prompts. Requires source images to edit. */
|
|
97
144
|
declare class EditImage {
|
|
98
145
|
private readonly http;
|
|
99
146
|
constructor(http: HttpClient);
|
|
147
|
+
/**
|
|
148
|
+
* Edit an image using text prompts and reference images and wait until complete.
|
|
149
|
+
* @param params Edit parameters.
|
|
150
|
+
* @param options Per-request and polling overrides.
|
|
151
|
+
* @returns The completed edit with image results.
|
|
152
|
+
*/
|
|
100
153
|
run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse>;
|
|
154
|
+
/**
|
|
155
|
+
* Create an image edit task; returns immediately with a task id.
|
|
156
|
+
* @param params Edit parameters.
|
|
157
|
+
* @param options Per-request overrides.
|
|
158
|
+
* @returns The task creation result with id.
|
|
159
|
+
*/
|
|
101
160
|
create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
161
|
+
/**
|
|
162
|
+
* Fetch the current status of an image edit task.
|
|
163
|
+
* @param id The task id.
|
|
164
|
+
* @param options Per-request overrides.
|
|
165
|
+
* @returns The current image edit task status.
|
|
166
|
+
*/
|
|
102
167
|
get(id: string, options?: RequestOptions): Promise<EditImageResponse>;
|
|
103
168
|
}
|
|
104
169
|
|
|
105
170
|
/**
|
|
106
|
-
* NanoBanana
|
|
171
|
+
* NanoBanana image generation and editing API client.
|
|
172
|
+
*
|
|
173
|
+
* Three generation tiers: standard (fast), pro (higher resolution, more
|
|
174
|
+
* reference images), and v2 (longest prompts, extreme aspect ratios, up to 14
|
|
175
|
+
* reference images). Editing uses the dedicated `nano-banana-edit` model.
|
|
107
176
|
*
|
|
108
177
|
* @example
|
|
109
178
|
* ```typescript
|
|
@@ -113,17 +182,17 @@ declare class EditImage {
|
|
|
113
182
|
* });
|
|
114
183
|
*
|
|
115
184
|
* const result = await client.textToImage.run({
|
|
116
|
-
* model: '
|
|
185
|
+
* model: 'nano-banana-pro',
|
|
117
186
|
* prompt: 'A futuristic cityscape at night',
|
|
118
187
|
* });
|
|
119
188
|
* ```
|
|
120
189
|
*/
|
|
121
|
-
declare class NanoBananaClient {
|
|
122
|
-
/**
|
|
190
|
+
declare class NanoBananaClient extends BaseClient {
|
|
191
|
+
/** Generate images from text prompts with optional reference image guidance. */
|
|
123
192
|
readonly textToImage: TextToImage;
|
|
124
|
-
/**
|
|
193
|
+
/** Edit existing images using text prompts and source images. */
|
|
125
194
|
readonly editImage: EditImage;
|
|
126
195
|
constructor(options?: ClientOptions);
|
|
127
196
|
}
|
|
128
197
|
|
|
129
|
-
export { type AspectRatio, type AspectRatioV2, type CompletedEditImageResponse, type CompletedTextToImageResponse, type EditImageModel, type EditImageParams, type EditImageResponse, type GenerationBaseParams, type GenerationProParams, type GenerationV2Params, type
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,109 +1,178 @@
|
|
|
1
|
-
import { AsyncTaskStatus, HttpClient, RequestOptions, PollingOptions, ClientOptions } from '@runapi.ai/core';
|
|
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 (longest prompts + extreme ratios). */
|
|
4
5
|
type TextToImageModel = 'nano-banana' | 'nano-banana-pro' | 'nano-banana-2';
|
|
6
|
+
/** Dedicated editing model. Requires source images to transform. */
|
|
5
7
|
type EditImageModel = 'nano-banana-edit';
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
*/
|
|
8
|
+
/** Aspect ratio options for the standard model. */
|
|
9
|
+
type BaseAspectRatio = '1:1' | '9:16' | '16:9' | '3:4' | '4:3' | '3:2' | '2:3' | '5:4' | '4:5' | '21:9' | 'auto';
|
|
10
|
+
/** Aspect ratio options for the pro model. */
|
|
15
11
|
type AspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
|
|
16
12
|
/**
|
|
17
|
-
* V2 model aspect ratio options. Superset of
|
|
18
|
-
* (1:4, 1:8, 4:1, 8:1). Default is 'auto'.
|
|
13
|
+
* V2 model aspect ratio options. Superset of pro ratios, adding extreme
|
|
14
|
+
* panoramic/tall ratios (1:4, 1:8, 4:1, 8:1). Default is 'auto'.
|
|
19
15
|
*/
|
|
20
16
|
type AspectRatioV2 = AspectRatio | '1:4' | '1:8' | '4:1' | '8:1';
|
|
21
|
-
|
|
17
|
+
/** Output resolution tier. Pro and v2 default to 1k; higher tiers increase generation time. */
|
|
18
|
+
type OutputResolution = '1k' | '2k' | '4k';
|
|
19
|
+
/** Output image encoding format. */
|
|
22
20
|
type OutputFormat = 'png' | 'jpg' | 'jpeg';
|
|
21
|
+
/** Standard tier generation. Up to 8 reference images, max 5000-char prompt. */
|
|
23
22
|
interface GenerationBaseParams {
|
|
24
23
|
model: 'nano-banana';
|
|
25
24
|
prompt: string;
|
|
26
25
|
callback_url?: string;
|
|
27
26
|
output_format?: OutputFormat;
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
aspect_ratio?: BaseAspectRatio;
|
|
28
|
+
/** Optional visual guidance images (up to 8, max 30 MB each). */
|
|
29
|
+
reference_image_urls?: string[];
|
|
30
30
|
}
|
|
31
|
+
/** Pro tier generation. Adds output resolution control and wider aspect ratio set. */
|
|
31
32
|
interface GenerationProParams {
|
|
32
33
|
model: 'nano-banana-pro';
|
|
33
34
|
prompt: string;
|
|
34
35
|
callback_url?: string;
|
|
35
36
|
output_format?: OutputFormat;
|
|
36
37
|
aspect_ratio?: AspectRatio;
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
output_resolution?: OutputResolution;
|
|
39
|
+
/** Optional visual guidance images (up to 8, max 30 MB each). */
|
|
40
|
+
reference_image_urls?: string[];
|
|
39
41
|
}
|
|
42
|
+
/** V2 tier generation. Longest prompts (up to 20000 chars), extreme aspect ratios, up to 14 reference images. */
|
|
40
43
|
interface GenerationV2Params {
|
|
41
44
|
model: 'nano-banana-2';
|
|
42
45
|
prompt: string;
|
|
43
46
|
callback_url?: string;
|
|
44
47
|
output_format?: OutputFormat;
|
|
45
48
|
aspect_ratio?: AspectRatioV2;
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
output_resolution?: OutputResolution;
|
|
50
|
+
/** Optional visual guidance images (up to 14, max 30 MB each). */
|
|
51
|
+
reference_image_urls?: string[];
|
|
48
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Text-to-image parameters. A discriminated union on `model`: the accepted
|
|
55
|
+
* aspect ratios, prompt length, resolution, and reference image count differ per tier.
|
|
56
|
+
*/
|
|
49
57
|
type TextToImageParams = GenerationBaseParams | GenerationProParams | GenerationV2Params;
|
|
58
|
+
/**
|
|
59
|
+
* Edit image parameters. Requires source images to modify according to the prompt.
|
|
60
|
+
* Up to 10 source images, max 10 MB each.
|
|
61
|
+
*/
|
|
50
62
|
interface EditImageParams {
|
|
51
63
|
model: 'nano-banana-edit';
|
|
64
|
+
/** Edit instruction describing the desired changes (up to 5000 chars). */
|
|
52
65
|
prompt: string;
|
|
53
|
-
|
|
66
|
+
/** Source images to edit (up to 10 images, max 10 MB each). */
|
|
67
|
+
source_image_urls: string[];
|
|
54
68
|
callback_url?: string;
|
|
55
69
|
output_format?: OutputFormat;
|
|
56
|
-
|
|
70
|
+
aspect_ratio?: BaseAspectRatio;
|
|
57
71
|
}
|
|
58
72
|
interface TaskCreateResponse {
|
|
59
73
|
id: string;
|
|
60
74
|
}
|
|
75
|
+
/** A single generated or edited image result. */
|
|
76
|
+
interface Image {
|
|
77
|
+
/** CDN-delivered image URL. */
|
|
78
|
+
url: string;
|
|
79
|
+
/** Pre-CDN original location, when available. */
|
|
80
|
+
origin_url?: string;
|
|
81
|
+
}
|
|
82
|
+
/** Task result for a text-to-image generation request. */
|
|
61
83
|
interface TextToImageResponse {
|
|
62
84
|
id: string;
|
|
63
85
|
status: AsyncTaskStatus;
|
|
64
|
-
|
|
86
|
+
/** Output images, populated once the task completes successfully. */
|
|
87
|
+
images?: Image[];
|
|
88
|
+
/** Error message when the task has failed. */
|
|
65
89
|
error?: string;
|
|
66
90
|
[key: string]: unknown;
|
|
67
91
|
}
|
|
92
|
+
/** Task result for an image editing request. */
|
|
68
93
|
interface EditImageResponse {
|
|
69
94
|
id: string;
|
|
70
95
|
status: AsyncTaskStatus;
|
|
71
|
-
|
|
96
|
+
/** Output images, populated once the task completes successfully. */
|
|
97
|
+
images?: Image[];
|
|
98
|
+
/** Error message when the task has failed. */
|
|
72
99
|
error?: string;
|
|
73
100
|
[key: string]: unknown;
|
|
74
101
|
}
|
|
75
102
|
/**
|
|
76
103
|
* Resolved responses returned by the `run()` methods after polling sees
|
|
77
|
-
* `status: 'completed'`. Narrows the base response so `
|
|
104
|
+
* `status: 'completed'`. Narrows the base response so `images` is
|
|
78
105
|
* guaranteed non-optional in user code.
|
|
79
106
|
*/
|
|
80
107
|
type CompletedTextToImageResponse = TextToImageResponse & {
|
|
81
108
|
status: 'completed';
|
|
82
|
-
|
|
109
|
+
images: Image[];
|
|
83
110
|
};
|
|
84
111
|
type CompletedEditImageResponse = EditImageResponse & {
|
|
85
112
|
status: 'completed';
|
|
86
|
-
|
|
113
|
+
images: Image[];
|
|
87
114
|
};
|
|
88
115
|
|
|
116
|
+
/** Generates images from text prompts with optional reference image guidance. Model tier controls prompt length, resolution, and reference image limits. */
|
|
89
117
|
declare class TextToImage {
|
|
90
118
|
private readonly http;
|
|
91
119
|
constructor(http: HttpClient);
|
|
120
|
+
/**
|
|
121
|
+
* Generate an image from a text prompt and wait until complete.
|
|
122
|
+
* @param params Generation parameters.
|
|
123
|
+
* @param options Per-request and polling overrides.
|
|
124
|
+
* @returns The completed generation with image results.
|
|
125
|
+
*/
|
|
92
126
|
run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse>;
|
|
127
|
+
/**
|
|
128
|
+
* Create an image generation task; returns immediately with a task id.
|
|
129
|
+
* @param params Generation parameters.
|
|
130
|
+
* @param options Per-request overrides.
|
|
131
|
+
* @returns The task creation result with id.
|
|
132
|
+
*/
|
|
93
133
|
create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
134
|
+
/**
|
|
135
|
+
* Fetch the current status of an image generation task.
|
|
136
|
+
* @param id The task id.
|
|
137
|
+
* @param options Per-request overrides.
|
|
138
|
+
* @returns The current image generation task status.
|
|
139
|
+
*/
|
|
94
140
|
get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
|
|
95
141
|
}
|
|
96
142
|
|
|
143
|
+
/** Modifies existing images based on text prompts. Requires source images to edit. */
|
|
97
144
|
declare class EditImage {
|
|
98
145
|
private readonly http;
|
|
99
146
|
constructor(http: HttpClient);
|
|
147
|
+
/**
|
|
148
|
+
* Edit an image using text prompts and reference images and wait until complete.
|
|
149
|
+
* @param params Edit parameters.
|
|
150
|
+
* @param options Per-request and polling overrides.
|
|
151
|
+
* @returns The completed edit with image results.
|
|
152
|
+
*/
|
|
100
153
|
run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse>;
|
|
154
|
+
/**
|
|
155
|
+
* Create an image edit task; returns immediately with a task id.
|
|
156
|
+
* @param params Edit parameters.
|
|
157
|
+
* @param options Per-request overrides.
|
|
158
|
+
* @returns The task creation result with id.
|
|
159
|
+
*/
|
|
101
160
|
create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
|
|
161
|
+
/**
|
|
162
|
+
* Fetch the current status of an image edit task.
|
|
163
|
+
* @param id The task id.
|
|
164
|
+
* @param options Per-request overrides.
|
|
165
|
+
* @returns The current image edit task status.
|
|
166
|
+
*/
|
|
102
167
|
get(id: string, options?: RequestOptions): Promise<EditImageResponse>;
|
|
103
168
|
}
|
|
104
169
|
|
|
105
170
|
/**
|
|
106
|
-
* NanoBanana
|
|
171
|
+
* NanoBanana image generation and editing API client.
|
|
172
|
+
*
|
|
173
|
+
* Three generation tiers: standard (fast), pro (higher resolution, more
|
|
174
|
+
* reference images), and v2 (longest prompts, extreme aspect ratios, up to 14
|
|
175
|
+
* reference images). Editing uses the dedicated `nano-banana-edit` model.
|
|
107
176
|
*
|
|
108
177
|
* @example
|
|
109
178
|
* ```typescript
|
|
@@ -113,17 +182,17 @@ declare class EditImage {
|
|
|
113
182
|
* });
|
|
114
183
|
*
|
|
115
184
|
* const result = await client.textToImage.run({
|
|
116
|
-
* model: '
|
|
185
|
+
* model: 'nano-banana-pro',
|
|
117
186
|
* prompt: 'A futuristic cityscape at night',
|
|
118
187
|
* });
|
|
119
188
|
* ```
|
|
120
189
|
*/
|
|
121
|
-
declare class NanoBananaClient {
|
|
122
|
-
/**
|
|
190
|
+
declare class NanoBananaClient extends BaseClient {
|
|
191
|
+
/** Generate images from text prompts with optional reference image guidance. */
|
|
123
192
|
readonly textToImage: TextToImage;
|
|
124
|
-
/**
|
|
193
|
+
/** Edit existing images using text prompts and source images. */
|
|
125
194
|
readonly editImage: EditImage;
|
|
126
195
|
constructor(options?: ClientOptions);
|
|
127
196
|
}
|
|
128
197
|
|
|
129
|
-
export { type AspectRatio, type AspectRatioV2, type CompletedEditImageResponse, type CompletedTextToImageResponse, type EditImageModel, type EditImageParams, type EditImageResponse, type GenerationBaseParams, type GenerationProParams, type GenerationV2Params, type
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,12 @@ var TextToImage = class {
|
|
|
47
47
|
this.http = http;
|
|
48
48
|
}
|
|
49
49
|
http;
|
|
50
|
+
/**
|
|
51
|
+
* Generate an image from a text prompt and wait until complete.
|
|
52
|
+
* @param params Generation parameters.
|
|
53
|
+
* @param options Per-request and polling overrides.
|
|
54
|
+
* @returns The completed generation with image results.
|
|
55
|
+
*/
|
|
50
56
|
async run(params, options) {
|
|
51
57
|
const { id } = await this.create(params, options);
|
|
52
58
|
const response = await (0, import_internal.pollUntilComplete)(() => this.get(id, options), {
|
|
@@ -55,12 +61,24 @@ var TextToImage = class {
|
|
|
55
61
|
});
|
|
56
62
|
return response;
|
|
57
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Create an image generation task; returns immediately with a task id.
|
|
66
|
+
* @param params Generation parameters.
|
|
67
|
+
* @param options Per-request overrides.
|
|
68
|
+
* @returns The task creation result with id.
|
|
69
|
+
*/
|
|
58
70
|
async create(params, options) {
|
|
59
71
|
return this.http.request("POST", ENDPOINT, {
|
|
60
72
|
body: (0, import_core.compactParams)(params),
|
|
61
73
|
...options
|
|
62
74
|
});
|
|
63
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Fetch the current status of an image generation task.
|
|
78
|
+
* @param id The task id.
|
|
79
|
+
* @param options Per-request overrides.
|
|
80
|
+
* @returns The current image generation task status.
|
|
81
|
+
*/
|
|
64
82
|
async get(id, options) {
|
|
65
83
|
return this.http.request("GET", `${ENDPOINT}/${id}`, {
|
|
66
84
|
...options
|
|
@@ -77,6 +95,12 @@ var EditImage = class {
|
|
|
77
95
|
this.http = http;
|
|
78
96
|
}
|
|
79
97
|
http;
|
|
98
|
+
/**
|
|
99
|
+
* Edit an image using text prompts and reference images and wait until complete.
|
|
100
|
+
* @param params Edit parameters.
|
|
101
|
+
* @param options Per-request and polling overrides.
|
|
102
|
+
* @returns The completed edit with image results.
|
|
103
|
+
*/
|
|
80
104
|
async run(params, options) {
|
|
81
105
|
const { id } = await this.create(params, options);
|
|
82
106
|
const response = await (0, import_internal2.pollUntilComplete)(() => this.get(id, options), {
|
|
@@ -85,12 +109,24 @@ var EditImage = class {
|
|
|
85
109
|
});
|
|
86
110
|
return response;
|
|
87
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Create an image edit task; returns immediately with a task id.
|
|
114
|
+
* @param params Edit parameters.
|
|
115
|
+
* @param options Per-request overrides.
|
|
116
|
+
* @returns The task creation result with id.
|
|
117
|
+
*/
|
|
88
118
|
async create(params, options) {
|
|
89
119
|
return this.http.request("POST", ENDPOINT2, {
|
|
90
120
|
body: (0, import_core2.compactParams)(params),
|
|
91
121
|
...options
|
|
92
122
|
});
|
|
93
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Fetch the current status of an image edit task.
|
|
126
|
+
* @param id The task id.
|
|
127
|
+
* @param options Per-request overrides.
|
|
128
|
+
* @returns The current image edit task status.
|
|
129
|
+
*/
|
|
94
130
|
async get(id, options) {
|
|
95
131
|
return this.http.request("GET", `${ENDPOINT2}/${id}`, {
|
|
96
132
|
...options
|
|
@@ -99,15 +135,15 @@ var EditImage = class {
|
|
|
99
135
|
};
|
|
100
136
|
|
|
101
137
|
// src/client.ts
|
|
102
|
-
var NanoBananaClient = class {
|
|
103
|
-
/**
|
|
138
|
+
var NanoBananaClient = class extends import_core3.BaseClient {
|
|
139
|
+
/** Generate images from text prompts with optional reference image guidance. */
|
|
104
140
|
textToImage;
|
|
105
|
-
/**
|
|
141
|
+
/** Edit existing images using text prompts and source images. */
|
|
106
142
|
editImage;
|
|
107
143
|
constructor(options = {}) {
|
|
108
|
-
|
|
109
|
-
this.textToImage = new TextToImage(http);
|
|
110
|
-
this.editImage = new EditImage(http);
|
|
144
|
+
super(options);
|
|
145
|
+
this.textToImage = new TextToImage(this.http);
|
|
146
|
+
this.editImage = new EditImage(this.http);
|
|
111
147
|
}
|
|
112
148
|
};
|
|
113
149
|
|
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 {
|
|
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,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ACtDA,IAAAC,eAA8B;AAC9B,IAAAC,mBAAkC;AAGlC,IAAMC,YAAW;AAGV,IAAM,YAAN,MAAgB;AAAA,EACrB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,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;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;;;AF1BO,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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/client.ts
|
|
2
|
-
import {
|
|
2
|
+
import { BaseClient } from "@runapi.ai/core";
|
|
3
3
|
|
|
4
4
|
// src/resources/text-to-image.ts
|
|
5
5
|
import { compactParams } from "@runapi.ai/core";
|
|
@@ -10,6 +10,12 @@ var TextToImage = class {
|
|
|
10
10
|
this.http = http;
|
|
11
11
|
}
|
|
12
12
|
http;
|
|
13
|
+
/**
|
|
14
|
+
* Generate an image from a text prompt and wait until complete.
|
|
15
|
+
* @param params Generation parameters.
|
|
16
|
+
* @param options Per-request and polling overrides.
|
|
17
|
+
* @returns The completed generation with image results.
|
|
18
|
+
*/
|
|
13
19
|
async run(params, options) {
|
|
14
20
|
const { id } = await this.create(params, options);
|
|
15
21
|
const response = await pollUntilComplete(() => this.get(id, options), {
|
|
@@ -18,12 +24,24 @@ var TextToImage = class {
|
|
|
18
24
|
});
|
|
19
25
|
return response;
|
|
20
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Create an image generation task; returns immediately with a task id.
|
|
29
|
+
* @param params Generation parameters.
|
|
30
|
+
* @param options Per-request overrides.
|
|
31
|
+
* @returns The task creation result with id.
|
|
32
|
+
*/
|
|
21
33
|
async create(params, options) {
|
|
22
34
|
return this.http.request("POST", ENDPOINT, {
|
|
23
35
|
body: compactParams(params),
|
|
24
36
|
...options
|
|
25
37
|
});
|
|
26
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Fetch the current status of an image generation task.
|
|
41
|
+
* @param id The task id.
|
|
42
|
+
* @param options Per-request overrides.
|
|
43
|
+
* @returns The current image generation task status.
|
|
44
|
+
*/
|
|
27
45
|
async get(id, options) {
|
|
28
46
|
return this.http.request("GET", `${ENDPOINT}/${id}`, {
|
|
29
47
|
...options
|
|
@@ -40,6 +58,12 @@ var EditImage = class {
|
|
|
40
58
|
this.http = http;
|
|
41
59
|
}
|
|
42
60
|
http;
|
|
61
|
+
/**
|
|
62
|
+
* Edit an image using text prompts and reference images and wait until complete.
|
|
63
|
+
* @param params Edit parameters.
|
|
64
|
+
* @param options Per-request and polling overrides.
|
|
65
|
+
* @returns The completed edit with image results.
|
|
66
|
+
*/
|
|
43
67
|
async run(params, options) {
|
|
44
68
|
const { id } = await this.create(params, options);
|
|
45
69
|
const response = await pollUntilComplete2(() => this.get(id, options), {
|
|
@@ -48,12 +72,24 @@ var EditImage = class {
|
|
|
48
72
|
});
|
|
49
73
|
return response;
|
|
50
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Create an image edit task; returns immediately with a task id.
|
|
77
|
+
* @param params Edit parameters.
|
|
78
|
+
* @param options Per-request overrides.
|
|
79
|
+
* @returns The task creation result with id.
|
|
80
|
+
*/
|
|
51
81
|
async create(params, options) {
|
|
52
82
|
return this.http.request("POST", ENDPOINT2, {
|
|
53
83
|
body: compactParams2(params),
|
|
54
84
|
...options
|
|
55
85
|
});
|
|
56
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Fetch the current status of an image edit task.
|
|
89
|
+
* @param id The task id.
|
|
90
|
+
* @param options Per-request overrides.
|
|
91
|
+
* @returns The current image edit task status.
|
|
92
|
+
*/
|
|
57
93
|
async get(id, options) {
|
|
58
94
|
return this.http.request("GET", `${ENDPOINT2}/${id}`, {
|
|
59
95
|
...options
|
|
@@ -62,15 +98,15 @@ var EditImage = class {
|
|
|
62
98
|
};
|
|
63
99
|
|
|
64
100
|
// src/client.ts
|
|
65
|
-
var NanoBananaClient = class {
|
|
66
|
-
/**
|
|
101
|
+
var NanoBananaClient = class extends BaseClient {
|
|
102
|
+
/** Generate images from text prompts with optional reference image guidance. */
|
|
67
103
|
textToImage;
|
|
68
|
-
/**
|
|
104
|
+
/** Edit existing images using text prompts and source images. */
|
|
69
105
|
editImage;
|
|
70
106
|
constructor(options = {}) {
|
|
71
|
-
|
|
72
|
-
this.textToImage = new TextToImage(http);
|
|
73
|
-
this.editImage = new EditImage(http);
|
|
107
|
+
super(options);
|
|
108
|
+
this.textToImage = new TextToImage(this.http);
|
|
109
|
+
this.editImage = new EditImage(this.http);
|
|
74
110
|
}
|
|
75
111
|
};
|
|
76
112
|
|
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 {
|
|
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,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,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ACtDA,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,qBAAAC,0BAAyB;AAGlC,IAAMC,YAAW;AAGV,IAAM,YAAN,MAAgB;AAAA,EACrB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAsD;AAC1E,WAAO,KAAK,KAAK,QAA2B,OAAO,GAAGE,SAAQ,IAAI,EAAE,IAAI;AAAA,MACtE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AF1BO,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;;;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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runapi.ai/nano-banana",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "RunAPI Nano Banana SDK for JavaScript, Ruby, and Go",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -25,17 +25,10 @@
|
|
|
25
25
|
"build": "tsup",
|
|
26
26
|
"test": "vitest run",
|
|
27
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"
|
|
28
|
+
"clean": "rm -rf dist"
|
|
36
29
|
},
|
|
37
30
|
"dependencies": {
|
|
38
|
-
"@runapi.ai/core": "^0.2.
|
|
31
|
+
"@runapi.ai/core": "^0.2.6"
|
|
39
32
|
},
|
|
40
33
|
"devDependencies": {
|
|
41
34
|
"@types/node": "^20.0.0",
|
|
@@ -53,9 +53,9 @@ const client = new NanoBananaClient();
|
|
|
53
53
|
const result = await client.textToImage.run({
|
|
54
54
|
model: 'nano-banana',
|
|
55
55
|
prompt: 'A bowl of fruit on a wooden table, soft daylight',
|
|
56
|
-
|
|
56
|
+
aspect_ratio: '16:9',
|
|
57
57
|
});
|
|
58
|
-
const url = result.
|
|
58
|
+
const url = result.images[0].url;
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
## Routing
|
|
@@ -77,6 +77,8 @@ const url = result.result_urls[0];
|
|
|
77
77
|
|
|
78
78
|
## Agent rules
|
|
79
79
|
|
|
80
|
+
- Integration work uses the target language SDK; one-off generation, manual smoke tests, debugging, or user-requested CLI runs use the RunAPI CLI skill: https://github.com/runapi-ai/cli-skill
|
|
81
|
+
- 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.
|
|
80
82
|
- Keep API keys in `RUNAPI_API_KEY` or RunAPI CLI config; never commit secrets.
|
|
81
83
|
- Prefer `create`, `get`, and `run` JSON passthrough patterns instead of inventing flags for every model parameter.
|
|
82
84
|
- For nano banana api pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
|
|
@@ -25,16 +25,25 @@ metadata:
|
|
|
25
25
|
|
|
26
26
|
Generate and edit images with Nano Banana through RunAPI. The default path for one-off agent tasks is the `runapi` CLI; SDKs are for application integration.
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Critical: Integration Runtime
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
30
|
+
- Integration work (app, backend, worker, library, Rails service, Node service, Go service, webhook pipeline, or production codebase) uses the **SDK integration path** for the target language.
|
|
31
|
+
- One-off generation, editing, transformation, manual smoke tests, debugging, or user-requested CLI runs use the **CLI path** with the `runapi` binary. For full CLI-specific agent guidance, see https://github.com/runapi-ai/cli-skill.
|
|
32
|
+
- Never shell out to the `runapi` CLI as the production runtime integration layer.
|
|
33
|
+
|
|
34
|
+
## SDK integration path
|
|
35
|
+
|
|
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
|
+
|
|
38
|
+
- JavaScript / TypeScript: `@runapi.ai/nano-banana`
|
|
39
|
+
- Ruby: `runapi-nano_banana`
|
|
40
|
+
- Go: `github.com/runapi-ai/nano-banana-sdk/go`
|
|
32
41
|
|
|
33
42
|
## CLI path
|
|
34
43
|
|
|
35
|
-
The `runapi` binary is the runtime dependency. Run `runapi auth status` first. For agents and headless runs, prefer `RUNAPI_API_KEY` or import it into saved config with `printf '%s' "$RUNAPI_API_KEY" | runapi auth import-token --token -`. Use `runapi login` only when the user explicitly wants interactive browser auth.
|
|
44
|
+
The `runapi` binary is the one-off and manual testing runtime dependency. For full CLI-specific agent guidance, see https://github.com/runapi-ai/cli-skill. Run `runapi auth status` first. For agents and headless runs, prefer `RUNAPI_API_KEY` or import it into saved config with `printf '%s' "$RUNAPI_API_KEY" | runapi auth import-token --token -`. Use `runapi login` only when the user explicitly wants interactive browser auth.
|
|
36
45
|
|
|
37
|
-
Inspect the available
|
|
46
|
+
Inspect the available commands and request fields with CLI help:
|
|
38
47
|
|
|
39
48
|
```shell
|
|
40
49
|
runapi nano-banana --help
|
|
@@ -54,15 +63,11 @@ runapi nano-banana text-to-image --async --input-file request.json
|
|
|
54
63
|
runapi wait <task-id> --service nano-banana --action text-to-image
|
|
55
64
|
```
|
|
56
65
|
|
|
57
|
-
Available
|
|
58
|
-
|
|
59
|
-
## SDK integration path
|
|
66
|
+
Available commands: `text-to-image`, `edit-image`.
|
|
60
67
|
|
|
61
|
-
|
|
68
|
+
## Generated file storage
|
|
62
69
|
|
|
63
|
-
-
|
|
64
|
-
- Ruby: `runapi-nano_banana`
|
|
65
|
-
- Go: `github.com/runapi-ai/nano-banana-sdk/go`
|
|
70
|
+
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.
|
|
66
71
|
|
|
67
72
|
## References
|
|
68
73
|
|