@runapi.ai/nano-banana 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Nano Banana API JavaScript SDK for RunAPI
1
+ # Nano Banana 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 editing, and creative production flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
3
+ The Nano Banana JavaScript SDK is the language-specific package for Nano Banana on RunAPI. Use this package for image generation, image editing, and creative production workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
4
4
 
5
- This 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.
5
+ This README is the JavaScript package guide inside the public `nano-banana-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/nano-banana; for API reference, use https://runapi.ai/docs#nano-banana; for SDK docs, use https://runapi.ai/docs#sdk-nano-banana.
6
6
 
7
7
  ## Install
8
8
 
@@ -16,17 +16,19 @@ npm install @runapi.ai/nano-banana
16
16
  import { NanoBananaClient } from '@runapi.ai/nano-banana';
17
17
 
18
18
  const client = new NanoBananaClient();
19
- const task = await client.generations.create({
19
+ const task = await client.textToImage.create({
20
20
  // Pass the Nano Banana JSON request body from https://runapi.ai/docs#nano-banana.
21
21
  });
22
- const status = await client.generations.get(task.id);
22
+ const status = await client.textToImage.get(task.id);
23
23
  ```
24
24
 
25
25
  Use `create` when you want to submit a task and return quickly, `get` when you need the latest task state, and `run` when a script should create and poll until completion. In web request handlers, prefer `create` plus webhook or later `get` polling so a worker is not held open.
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
- 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.
31
+ Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The available resources are `textToImage` and `editImage`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
30
32
 
31
33
  ## Links
32
34
 
package/dist/index.d.mts CHANGED
@@ -1,25 +1,34 @@
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';
8
+ /** Aspect ratio options for the standard model. */
6
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. */
7
11
  type AspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
8
12
  /**
9
- * V2 model aspect ratio options. Superset of Pro, adding extreme ratios
10
- * (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'.
11
15
  */
12
16
  type AspectRatioV2 = AspectRatio | '1:4' | '1:8' | '4:1' | '8:1';
17
+ /** Output resolution tier. Pro and v2 default to 1k; higher tiers increase generation time. */
13
18
  type OutputResolution = '1k' | '2k' | '4k';
19
+ /** Output image encoding format. */
14
20
  type OutputFormat = 'png' | 'jpg' | 'jpeg';
21
+ /** Standard tier generation. Up to 8 reference images, max 5000-char prompt. */
15
22
  interface GenerationBaseParams {
16
23
  model: 'nano-banana';
17
24
  prompt: string;
18
25
  callback_url?: string;
19
26
  output_format?: OutputFormat;
20
27
  aspect_ratio?: BaseAspectRatio;
28
+ /** Optional visual guidance images (up to 8, max 30 MB each). */
21
29
  reference_image_urls?: string[];
22
30
  }
31
+ /** Pro tier generation. Adds output resolution control and wider aspect ratio set. */
23
32
  interface GenerationProParams {
24
33
  model: 'nano-banana-pro';
25
34
  prompt: string;
@@ -27,8 +36,10 @@ interface GenerationProParams {
27
36
  output_format?: OutputFormat;
28
37
  aspect_ratio?: AspectRatio;
29
38
  output_resolution?: OutputResolution;
39
+ /** Optional visual guidance images (up to 8, max 30 MB each). */
30
40
  reference_image_urls?: string[];
31
41
  }
42
+ /** V2 tier generation. Longest prompts (up to 20000 chars), extreme aspect ratios, up to 14 reference images. */
32
43
  interface GenerationV2Params {
33
44
  model: 'nano-banana-2';
34
45
  prompt: string;
@@ -36,12 +47,23 @@ interface GenerationV2Params {
36
47
  output_format?: OutputFormat;
37
48
  aspect_ratio?: AspectRatioV2;
38
49
  output_resolution?: OutputResolution;
50
+ /** Optional visual guidance images (up to 14, max 30 MB each). */
39
51
  reference_image_urls?: string[];
40
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
+ */
41
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
+ */
42
62
  interface EditImageParams {
43
63
  model: 'nano-banana-edit';
64
+ /** Edit instruction describing the desired changes (up to 5000 chars). */
44
65
  prompt: string;
66
+ /** Source images to edit (up to 10 images, max 10 MB each). */
45
67
  source_image_urls: string[];
46
68
  callback_url?: string;
47
69
  output_format?: OutputFormat;
@@ -50,21 +72,30 @@ interface EditImageParams {
50
72
  interface TaskCreateResponse {
51
73
  id: string;
52
74
  }
75
+ /** A single generated or edited image result. */
53
76
  interface Image {
77
+ /** CDN-delivered image URL. */
54
78
  url: string;
79
+ /** Pre-CDN original location, when available. */
55
80
  origin_url?: string;
56
81
  }
82
+ /** Task result for a text-to-image generation request. */
57
83
  interface TextToImageResponse {
58
84
  id: string;
59
85
  status: AsyncTaskStatus;
86
+ /** Output images, populated once the task completes successfully. */
60
87
  images?: Image[];
88
+ /** Error message when the task has failed. */
61
89
  error?: string;
62
90
  [key: string]: unknown;
63
91
  }
92
+ /** Task result for an image editing request. */
64
93
  interface EditImageResponse {
65
94
  id: string;
66
95
  status: AsyncTaskStatus;
96
+ /** Output images, populated once the task completes successfully. */
67
97
  images?: Image[];
98
+ /** Error message when the task has failed. */
68
99
  error?: string;
69
100
  [key: string]: unknown;
70
101
  }
@@ -82,24 +113,66 @@ type CompletedEditImageResponse = EditImageResponse & {
82
113
  images: Image[];
83
114
  };
84
115
 
116
+ /** Generates images from text prompts with optional reference image guidance. Model tier controls prompt length, resolution, and reference image limits. */
85
117
  declare class TextToImage {
86
118
  private readonly http;
87
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
+ */
88
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
+ */
89
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
+ */
90
140
  get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
91
141
  }
92
142
 
143
+ /** Modifies existing images based on text prompts. Requires source images to edit. */
93
144
  declare class EditImage {
94
145
  private readonly http;
95
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
+ */
96
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
+ */
97
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
+ */
98
167
  get(id: string, options?: RequestOptions): Promise<EditImageResponse>;
99
168
  }
100
169
 
101
170
  /**
102
- * NanoBanana text-to-image API client.
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.
103
176
  *
104
177
  * @example
105
178
  * ```typescript
@@ -109,15 +182,15 @@ declare class EditImage {
109
182
  * });
110
183
  *
111
184
  * const result = await client.textToImage.run({
112
- * model: 'flux-kontext-pro',
185
+ * model: 'nano-banana-pro',
113
186
  * prompt: 'A futuristic cityscape at night',
114
187
  * });
115
188
  * ```
116
189
  */
117
- declare class NanoBananaClient {
118
- /** Text-to-image operations. */
190
+ declare class NanoBananaClient extends BaseClient {
191
+ /** Generate images from text prompts with optional reference image guidance. */
119
192
  readonly textToImage: TextToImage;
120
- /** Image editing operations. */
193
+ /** Edit existing images using text prompts and source images. */
121
194
  readonly editImage: EditImage;
122
195
  constructor(options?: ClientOptions);
123
196
  }
package/dist/index.d.ts CHANGED
@@ -1,25 +1,34 @@
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';
8
+ /** Aspect ratio options for the standard model. */
6
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. */
7
11
  type AspectRatio = '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' | 'auto';
8
12
  /**
9
- * V2 model aspect ratio options. Superset of Pro, adding extreme ratios
10
- * (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'.
11
15
  */
12
16
  type AspectRatioV2 = AspectRatio | '1:4' | '1:8' | '4:1' | '8:1';
17
+ /** Output resolution tier. Pro and v2 default to 1k; higher tiers increase generation time. */
13
18
  type OutputResolution = '1k' | '2k' | '4k';
19
+ /** Output image encoding format. */
14
20
  type OutputFormat = 'png' | 'jpg' | 'jpeg';
21
+ /** Standard tier generation. Up to 8 reference images, max 5000-char prompt. */
15
22
  interface GenerationBaseParams {
16
23
  model: 'nano-banana';
17
24
  prompt: string;
18
25
  callback_url?: string;
19
26
  output_format?: OutputFormat;
20
27
  aspect_ratio?: BaseAspectRatio;
28
+ /** Optional visual guidance images (up to 8, max 30 MB each). */
21
29
  reference_image_urls?: string[];
22
30
  }
31
+ /** Pro tier generation. Adds output resolution control and wider aspect ratio set. */
23
32
  interface GenerationProParams {
24
33
  model: 'nano-banana-pro';
25
34
  prompt: string;
@@ -27,8 +36,10 @@ interface GenerationProParams {
27
36
  output_format?: OutputFormat;
28
37
  aspect_ratio?: AspectRatio;
29
38
  output_resolution?: OutputResolution;
39
+ /** Optional visual guidance images (up to 8, max 30 MB each). */
30
40
  reference_image_urls?: string[];
31
41
  }
42
+ /** V2 tier generation. Longest prompts (up to 20000 chars), extreme aspect ratios, up to 14 reference images. */
32
43
  interface GenerationV2Params {
33
44
  model: 'nano-banana-2';
34
45
  prompt: string;
@@ -36,12 +47,23 @@ interface GenerationV2Params {
36
47
  output_format?: OutputFormat;
37
48
  aspect_ratio?: AspectRatioV2;
38
49
  output_resolution?: OutputResolution;
50
+ /** Optional visual guidance images (up to 14, max 30 MB each). */
39
51
  reference_image_urls?: string[];
40
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
+ */
41
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
+ */
42
62
  interface EditImageParams {
43
63
  model: 'nano-banana-edit';
64
+ /** Edit instruction describing the desired changes (up to 5000 chars). */
44
65
  prompt: string;
66
+ /** Source images to edit (up to 10 images, max 10 MB each). */
45
67
  source_image_urls: string[];
46
68
  callback_url?: string;
47
69
  output_format?: OutputFormat;
@@ -50,21 +72,30 @@ interface EditImageParams {
50
72
  interface TaskCreateResponse {
51
73
  id: string;
52
74
  }
75
+ /** A single generated or edited image result. */
53
76
  interface Image {
77
+ /** CDN-delivered image URL. */
54
78
  url: string;
79
+ /** Pre-CDN original location, when available. */
55
80
  origin_url?: string;
56
81
  }
82
+ /** Task result for a text-to-image generation request. */
57
83
  interface TextToImageResponse {
58
84
  id: string;
59
85
  status: AsyncTaskStatus;
86
+ /** Output images, populated once the task completes successfully. */
60
87
  images?: Image[];
88
+ /** Error message when the task has failed. */
61
89
  error?: string;
62
90
  [key: string]: unknown;
63
91
  }
92
+ /** Task result for an image editing request. */
64
93
  interface EditImageResponse {
65
94
  id: string;
66
95
  status: AsyncTaskStatus;
96
+ /** Output images, populated once the task completes successfully. */
67
97
  images?: Image[];
98
+ /** Error message when the task has failed. */
68
99
  error?: string;
69
100
  [key: string]: unknown;
70
101
  }
@@ -82,24 +113,66 @@ type CompletedEditImageResponse = EditImageResponse & {
82
113
  images: Image[];
83
114
  };
84
115
 
116
+ /** Generates images from text prompts with optional reference image guidance. Model tier controls prompt length, resolution, and reference image limits. */
85
117
  declare class TextToImage {
86
118
  private readonly http;
87
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
+ */
88
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
+ */
89
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
+ */
90
140
  get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
91
141
  }
92
142
 
143
+ /** Modifies existing images based on text prompts. Requires source images to edit. */
93
144
  declare class EditImage {
94
145
  private readonly http;
95
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
+ */
96
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
+ */
97
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
+ */
98
167
  get(id: string, options?: RequestOptions): Promise<EditImageResponse>;
99
168
  }
100
169
 
101
170
  /**
102
- * NanoBanana text-to-image API client.
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.
103
176
  *
104
177
  * @example
105
178
  * ```typescript
@@ -109,15 +182,15 @@ declare class EditImage {
109
182
  * });
110
183
  *
111
184
  * const result = await client.textToImage.run({
112
- * model: 'flux-kontext-pro',
185
+ * model: 'nano-banana-pro',
113
186
  * prompt: 'A futuristic cityscape at night',
114
187
  * });
115
188
  * ```
116
189
  */
117
- declare class NanoBananaClient {
118
- /** Text-to-image operations. */
190
+ declare class NanoBananaClient extends BaseClient {
191
+ /** Generate images from text prompts with optional reference image guidance. */
119
192
  readonly textToImage: TextToImage;
120
- /** Image editing operations. */
193
+ /** Edit existing images using text prompts and source images. */
121
194
  readonly editImage: EditImage;
122
195
  constructor(options?: ClientOptions);
123
196
  }
package/dist/index.js CHANGED
@@ -41,12 +41,156 @@ var import_core3 = require("@runapi.ai/core");
41
41
  // src/resources/text-to-image.ts
42
42
  var import_core = require("@runapi.ai/core");
43
43
  var import_internal = require("@runapi.ai/core/internal");
44
+
45
+ // src/contract_gen.ts
46
+ var contract = {
47
+ "edit-image": {
48
+ "models": [
49
+ "nano-banana-edit"
50
+ ],
51
+ "fields_by_model": {
52
+ "nano-banana-edit": {
53
+ "aspect_ratio": {
54
+ "enum": [
55
+ "1:1",
56
+ "9:16",
57
+ "16:9",
58
+ "3:4",
59
+ "4:3",
60
+ "3:2",
61
+ "2:3",
62
+ "5:4",
63
+ "4:5",
64
+ "21:9",
65
+ "auto"
66
+ ]
67
+ },
68
+ "output_format": {
69
+ "enum": [
70
+ "png",
71
+ "jpeg"
72
+ ]
73
+ },
74
+ "source_image_urls": {
75
+ "required": true
76
+ }
77
+ }
78
+ }
79
+ },
80
+ "text-to-image": {
81
+ "models": [
82
+ "nano-banana",
83
+ "nano-banana-2",
84
+ "nano-banana-pro"
85
+ ],
86
+ "fields_by_model": {
87
+ "nano-banana": {
88
+ "aspect_ratio": {
89
+ "enum": [
90
+ "1:1",
91
+ "9:16",
92
+ "16:9",
93
+ "3:4",
94
+ "4:3",
95
+ "3:2",
96
+ "2:3",
97
+ "5:4",
98
+ "4:5",
99
+ "21:9",
100
+ "auto"
101
+ ]
102
+ },
103
+ "output_format": {
104
+ "enum": [
105
+ "png",
106
+ "jpeg",
107
+ "jpg"
108
+ ]
109
+ }
110
+ },
111
+ "nano-banana-2": {
112
+ "aspect_ratio": {
113
+ "enum": [
114
+ "1:1",
115
+ "1:4",
116
+ "1:8",
117
+ "2:3",
118
+ "3:2",
119
+ "3:4",
120
+ "4:1",
121
+ "4:3",
122
+ "4:5",
123
+ "5:4",
124
+ "8:1",
125
+ "9:16",
126
+ "16:9",
127
+ "21:9",
128
+ "auto"
129
+ ]
130
+ },
131
+ "output_format": {
132
+ "enum": [
133
+ "png",
134
+ "jpeg",
135
+ "jpg"
136
+ ]
137
+ },
138
+ "output_resolution": {
139
+ "enum": [
140
+ "1k",
141
+ "2k",
142
+ "4k"
143
+ ]
144
+ }
145
+ },
146
+ "nano-banana-pro": {
147
+ "aspect_ratio": {
148
+ "enum": [
149
+ "1:1",
150
+ "2:3",
151
+ "3:2",
152
+ "3:4",
153
+ "4:3",
154
+ "4:5",
155
+ "5:4",
156
+ "9:16",
157
+ "16:9",
158
+ "21:9",
159
+ "auto"
160
+ ]
161
+ },
162
+ "output_format": {
163
+ "enum": [
164
+ "png",
165
+ "jpeg",
166
+ "jpg"
167
+ ]
168
+ },
169
+ "output_resolution": {
170
+ "enum": [
171
+ "1k",
172
+ "2k",
173
+ "4k"
174
+ ]
175
+ }
176
+ }
177
+ }
178
+ }
179
+ };
180
+
181
+ // src/resources/text-to-image.ts
44
182
  var ENDPOINT = "/api/v1/nano_banana/text_to_image";
45
183
  var TextToImage = class {
46
184
  constructor(http) {
47
185
  this.http = http;
48
186
  }
49
187
  http;
188
+ /**
189
+ * Generate an image from a text prompt and wait until complete.
190
+ * @param params Generation parameters.
191
+ * @param options Per-request and polling overrides.
192
+ * @returns The completed generation with image results.
193
+ */
50
194
  async run(params, options) {
51
195
  const { id } = await this.create(params, options);
52
196
  const response = await (0, import_internal.pollUntilComplete)(() => this.get(id, options), {
@@ -55,12 +199,26 @@ var TextToImage = class {
55
199
  });
56
200
  return response;
57
201
  }
202
+ /**
203
+ * Create an image generation task; returns immediately with a task id.
204
+ * @param params Generation parameters.
205
+ * @param options Per-request overrides.
206
+ * @returns The task creation result with id.
207
+ */
58
208
  async create(params, options) {
209
+ const body = (0, import_core.compactParams)(params);
210
+ (0, import_core.validateParams)(contract["text-to-image"], body);
59
211
  return this.http.request("POST", ENDPOINT, {
60
- body: (0, import_core.compactParams)(params),
212
+ body,
61
213
  ...options
62
214
  });
63
215
  }
216
+ /**
217
+ * Fetch the current status of an image generation task.
218
+ * @param id The task id.
219
+ * @param options Per-request overrides.
220
+ * @returns The current image generation task status.
221
+ */
64
222
  async get(id, options) {
65
223
  return this.http.request("GET", `${ENDPOINT}/${id}`, {
66
224
  ...options
@@ -77,6 +235,12 @@ var EditImage = class {
77
235
  this.http = http;
78
236
  }
79
237
  http;
238
+ /**
239
+ * Edit an image using text prompts and reference images and wait until complete.
240
+ * @param params Edit parameters.
241
+ * @param options Per-request and polling overrides.
242
+ * @returns The completed edit with image results.
243
+ */
80
244
  async run(params, options) {
81
245
  const { id } = await this.create(params, options);
82
246
  const response = await (0, import_internal2.pollUntilComplete)(() => this.get(id, options), {
@@ -85,12 +249,26 @@ var EditImage = class {
85
249
  });
86
250
  return response;
87
251
  }
252
+ /**
253
+ * Create an image edit task; returns immediately with a task id.
254
+ * @param params Edit parameters.
255
+ * @param options Per-request overrides.
256
+ * @returns The task creation result with id.
257
+ */
88
258
  async create(params, options) {
259
+ const body = (0, import_core2.compactParams)(params);
260
+ (0, import_core2.validateParams)(contract["edit-image"], body);
89
261
  return this.http.request("POST", ENDPOINT2, {
90
- body: (0, import_core2.compactParams)(params),
262
+ body,
91
263
  ...options
92
264
  });
93
265
  }
266
+ /**
267
+ * Fetch the current status of an image edit task.
268
+ * @param id The task id.
269
+ * @param options Per-request overrides.
270
+ * @returns The current image edit task status.
271
+ */
94
272
  async get(id, options) {
95
273
  return this.http.request("GET", `${ENDPOINT2}/${id}`, {
96
274
  ...options
@@ -99,15 +277,15 @@ var EditImage = class {
99
277
  };
100
278
 
101
279
  // src/client.ts
102
- var NanoBananaClient = class {
103
- /** Text-to-image operations. */
280
+ var NanoBananaClient = class extends import_core3.BaseClient {
281
+ /** Generate images from text prompts with optional reference image guidance. */
104
282
  textToImage;
105
- /** Image editing operations. */
283
+ /** Edit existing images using text prompts and source images. */
106
284
  editImage;
107
285
  constructor(options = {}) {
108
- const http = (0, import_core3.createHttpClient)(options);
109
- this.textToImage = new TextToImage(http);
110
- this.editImage = new EditImage(http);
286
+ super(options);
287
+ this.textToImage = new TextToImage(this.http);
288
+ this.editImage = new EditImage(this.http);
111
289
  }
112
290
  };
113
291
 
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 { 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;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AK,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"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.ts","../src/resources/edit-image.ts"],"sourcesContent":["export { NanoBananaClient } from './client';\nexport * from './types';\n\n// Re-export core errors for convenience\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n","import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { EditImage } from './resources/edit-image';\n\n/**\n * NanoBanana image generation and editing API client.\n *\n * Three generation tiers: standard (fast), pro (higher resolution, more\n * reference images), and v2 (longest prompts, extreme aspect ratios, up to 14\n * reference images). Editing uses the dedicated `nano-banana-edit` model.\n *\n * @example\n * ```typescript\n * const client = new NanoBananaClient({\n * apiKey: 'your-api-key',\n * baseUrl: 'https://runapi.ai',\n * });\n *\n * const result = await client.textToImage.run({\n * model: 'nano-banana-pro',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class NanoBananaClient extends BaseClient {\n /** Generate images from text prompts with optional reference image guidance. */\n public readonly textToImage: TextToImage;\n /** Edit existing images using text prompts and source images. */\n public readonly editImage: EditImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.editImage = new EditImage(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedTextToImageResponse,\n TextToImageParams,\n TextToImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/text_to_image';\n\n/** Generates images from text prompts with optional reference image guidance. Model tier controls prompt length, resolution, and reference image limits. */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an image from a text prompt and wait until complete.\n * @param params Generation parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed generation with image results.\n */\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToImageResponse;\n }\n\n /**\n * Create an image generation task; returns immediately with a task id.\n * @param params Generation parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['text-to-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image generation task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image generation task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export const contract = {\n \"edit-image\": {\n \"models\": [\n \"nano-banana-edit\"\n ],\n \"fields_by_model\": {\n \"nano-banana-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"9:16\",\n \"16:9\",\n \"3:4\",\n \"4:3\",\n \"3:2\",\n \"2:3\",\n \"5:4\",\n \"4:5\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"source_image_urls\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-image\": {\n \"models\": [\n \"nano-banana\",\n \"nano-banana-2\",\n \"nano-banana-pro\"\n ],\n \"fields_by_model\": {\n \"nano-banana\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"9:16\",\n \"16:9\",\n \"3:4\",\n \"4:3\",\n \"3:2\",\n \"2:3\",\n \"5:4\",\n \"4:5\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n }\n },\n \"nano-banana-2\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"1:4\",\n \"1:8\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:1\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"8:1\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n }\n },\n \"nano-banana-pro\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n }\n }\n }\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { CompletedEditImageResponse, EditImageParams, EditImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/edit_image';\n\n/** Modifies existing images based on text prompts. Requires source images to edit. */\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Edit an image using text prompts and reference images and wait until complete.\n * @param params Edit parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed edit with image results.\n */\n async run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<EditImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedEditImageResponse;\n }\n\n /**\n * Create an image edit task; returns immediately with a task id.\n * @param params Edit parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['edit-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image edit task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image edit task status.\n */\n async get(id: string, options?: RequestOptions): Promise<EditImageResponse> {\n return this.http.request<EditImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAA+C;;;ACC/C,kBAA8C;AAC9C,sBAAkC;;;ACF3B,IAAM,WAAW;AAAA,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core","import_internal","ENDPOINT","import_core"]}
package/dist/index.mjs CHANGED
@@ -1,15 +1,159 @@
1
1
  // src/client.ts
2
- import { createHttpClient } from "@runapi.ai/core";
2
+ import { BaseClient } from "@runapi.ai/core";
3
3
 
4
4
  // src/resources/text-to-image.ts
5
- import { compactParams } from "@runapi.ai/core";
5
+ import { compactParams, validateParams } from "@runapi.ai/core";
6
6
  import { pollUntilComplete } from "@runapi.ai/core/internal";
7
+
8
+ // src/contract_gen.ts
9
+ var contract = {
10
+ "edit-image": {
11
+ "models": [
12
+ "nano-banana-edit"
13
+ ],
14
+ "fields_by_model": {
15
+ "nano-banana-edit": {
16
+ "aspect_ratio": {
17
+ "enum": [
18
+ "1:1",
19
+ "9:16",
20
+ "16:9",
21
+ "3:4",
22
+ "4:3",
23
+ "3:2",
24
+ "2:3",
25
+ "5:4",
26
+ "4:5",
27
+ "21:9",
28
+ "auto"
29
+ ]
30
+ },
31
+ "output_format": {
32
+ "enum": [
33
+ "png",
34
+ "jpeg"
35
+ ]
36
+ },
37
+ "source_image_urls": {
38
+ "required": true
39
+ }
40
+ }
41
+ }
42
+ },
43
+ "text-to-image": {
44
+ "models": [
45
+ "nano-banana",
46
+ "nano-banana-2",
47
+ "nano-banana-pro"
48
+ ],
49
+ "fields_by_model": {
50
+ "nano-banana": {
51
+ "aspect_ratio": {
52
+ "enum": [
53
+ "1:1",
54
+ "9:16",
55
+ "16:9",
56
+ "3:4",
57
+ "4:3",
58
+ "3:2",
59
+ "2:3",
60
+ "5:4",
61
+ "4:5",
62
+ "21:9",
63
+ "auto"
64
+ ]
65
+ },
66
+ "output_format": {
67
+ "enum": [
68
+ "png",
69
+ "jpeg",
70
+ "jpg"
71
+ ]
72
+ }
73
+ },
74
+ "nano-banana-2": {
75
+ "aspect_ratio": {
76
+ "enum": [
77
+ "1:1",
78
+ "1:4",
79
+ "1:8",
80
+ "2:3",
81
+ "3:2",
82
+ "3:4",
83
+ "4:1",
84
+ "4:3",
85
+ "4:5",
86
+ "5:4",
87
+ "8:1",
88
+ "9:16",
89
+ "16:9",
90
+ "21:9",
91
+ "auto"
92
+ ]
93
+ },
94
+ "output_format": {
95
+ "enum": [
96
+ "png",
97
+ "jpeg",
98
+ "jpg"
99
+ ]
100
+ },
101
+ "output_resolution": {
102
+ "enum": [
103
+ "1k",
104
+ "2k",
105
+ "4k"
106
+ ]
107
+ }
108
+ },
109
+ "nano-banana-pro": {
110
+ "aspect_ratio": {
111
+ "enum": [
112
+ "1:1",
113
+ "2:3",
114
+ "3:2",
115
+ "3:4",
116
+ "4:3",
117
+ "4:5",
118
+ "5:4",
119
+ "9:16",
120
+ "16:9",
121
+ "21:9",
122
+ "auto"
123
+ ]
124
+ },
125
+ "output_format": {
126
+ "enum": [
127
+ "png",
128
+ "jpeg",
129
+ "jpg"
130
+ ]
131
+ },
132
+ "output_resolution": {
133
+ "enum": [
134
+ "1k",
135
+ "2k",
136
+ "4k"
137
+ ]
138
+ }
139
+ }
140
+ }
141
+ }
142
+ };
143
+
144
+ // src/resources/text-to-image.ts
7
145
  var ENDPOINT = "/api/v1/nano_banana/text_to_image";
8
146
  var TextToImage = class {
9
147
  constructor(http) {
10
148
  this.http = http;
11
149
  }
12
150
  http;
151
+ /**
152
+ * Generate an image from a text prompt and wait until complete.
153
+ * @param params Generation parameters.
154
+ * @param options Per-request and polling overrides.
155
+ * @returns The completed generation with image results.
156
+ */
13
157
  async run(params, options) {
14
158
  const { id } = await this.create(params, options);
15
159
  const response = await pollUntilComplete(() => this.get(id, options), {
@@ -18,12 +162,26 @@ var TextToImage = class {
18
162
  });
19
163
  return response;
20
164
  }
165
+ /**
166
+ * Create an image generation task; returns immediately with a task id.
167
+ * @param params Generation parameters.
168
+ * @param options Per-request overrides.
169
+ * @returns The task creation result with id.
170
+ */
21
171
  async create(params, options) {
172
+ const body = compactParams(params);
173
+ validateParams(contract["text-to-image"], body);
22
174
  return this.http.request("POST", ENDPOINT, {
23
- body: compactParams(params),
175
+ body,
24
176
  ...options
25
177
  });
26
178
  }
179
+ /**
180
+ * Fetch the current status of an image generation task.
181
+ * @param id The task id.
182
+ * @param options Per-request overrides.
183
+ * @returns The current image generation task status.
184
+ */
27
185
  async get(id, options) {
28
186
  return this.http.request("GET", `${ENDPOINT}/${id}`, {
29
187
  ...options
@@ -32,7 +190,7 @@ var TextToImage = class {
32
190
  };
33
191
 
34
192
  // src/resources/edit-image.ts
35
- import { compactParams as compactParams2 } from "@runapi.ai/core";
193
+ import { compactParams as compactParams2, validateParams as validateParams2 } from "@runapi.ai/core";
36
194
  import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
37
195
  var ENDPOINT2 = "/api/v1/nano_banana/edit_image";
38
196
  var EditImage = class {
@@ -40,6 +198,12 @@ var EditImage = class {
40
198
  this.http = http;
41
199
  }
42
200
  http;
201
+ /**
202
+ * Edit an image using text prompts and reference images and wait until complete.
203
+ * @param params Edit parameters.
204
+ * @param options Per-request and polling overrides.
205
+ * @returns The completed edit with image results.
206
+ */
43
207
  async run(params, options) {
44
208
  const { id } = await this.create(params, options);
45
209
  const response = await pollUntilComplete2(() => this.get(id, options), {
@@ -48,12 +212,26 @@ var EditImage = class {
48
212
  });
49
213
  return response;
50
214
  }
215
+ /**
216
+ * Create an image edit task; returns immediately with a task id.
217
+ * @param params Edit parameters.
218
+ * @param options Per-request overrides.
219
+ * @returns The task creation result with id.
220
+ */
51
221
  async create(params, options) {
222
+ const body = compactParams2(params);
223
+ validateParams2(contract["edit-image"], body);
52
224
  return this.http.request("POST", ENDPOINT2, {
53
- body: compactParams2(params),
225
+ body,
54
226
  ...options
55
227
  });
56
228
  }
229
+ /**
230
+ * Fetch the current status of an image edit task.
231
+ * @param id The task id.
232
+ * @param options Per-request overrides.
233
+ * @returns The current image edit task status.
234
+ */
57
235
  async get(id, options) {
58
236
  return this.http.request("GET", `${ENDPOINT2}/${id}`, {
59
237
  ...options
@@ -62,15 +240,15 @@ var EditImage = class {
62
240
  };
63
241
 
64
242
  // src/client.ts
65
- var NanoBananaClient = class {
66
- /** Text-to-image operations. */
243
+ var NanoBananaClient = class extends BaseClient {
244
+ /** Generate images from text prompts with optional reference image guidance. */
67
245
  textToImage;
68
- /** Image editing operations. */
246
+ /** Edit existing images using text prompts and source images. */
69
247
  editImage;
70
248
  constructor(options = {}) {
71
- const http = createHttpClient(options);
72
- this.textToImage = new TextToImage(http);
73
- this.editImage = new EditImage(http);
249
+ super(options);
250
+ this.textToImage = new TextToImage(this.http);
251
+ this.editImage = new EditImage(this.http);
74
252
  }
75
253
  };
76
254
 
@@ -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 { 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';\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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"]}
1
+ {"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.ts","../src/resources/edit-image.ts","../src/index.ts"],"sourcesContent":["import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { EditImage } from './resources/edit-image';\n\n/**\n * NanoBanana image generation and editing API client.\n *\n * Three generation tiers: standard (fast), pro (higher resolution, more\n * reference images), and v2 (longest prompts, extreme aspect ratios, up to 14\n * reference images). Editing uses the dedicated `nano-banana-edit` model.\n *\n * @example\n * ```typescript\n * const client = new NanoBananaClient({\n * apiKey: 'your-api-key',\n * baseUrl: 'https://runapi.ai',\n * });\n *\n * const result = await client.textToImage.run({\n * model: 'nano-banana-pro',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class NanoBananaClient extends BaseClient {\n /** Generate images from text prompts with optional reference image guidance. */\n public readonly textToImage: TextToImage;\n /** Edit existing images using text prompts and source images. */\n public readonly editImage: EditImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.editImage = new EditImage(this.http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedTextToImageResponse,\n TextToImageParams,\n TextToImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/text_to_image';\n\n/** Generates images from text prompts with optional reference image guidance. Model tier controls prompt length, resolution, and reference image limits. */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an image from a text prompt and wait until complete.\n * @param params Generation parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed generation with image results.\n */\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToImageResponse;\n }\n\n /**\n * Create an image generation task; returns immediately with a task id.\n * @param params Generation parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['text-to-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image generation task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image generation task status.\n */\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export const contract = {\n \"edit-image\": {\n \"models\": [\n \"nano-banana-edit\"\n ],\n \"fields_by_model\": {\n \"nano-banana-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"9:16\",\n \"16:9\",\n \"3:4\",\n \"4:3\",\n \"3:2\",\n \"2:3\",\n \"5:4\",\n \"4:5\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"source_image_urls\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-image\": {\n \"models\": [\n \"nano-banana\",\n \"nano-banana-2\",\n \"nano-banana-pro\"\n ],\n \"fields_by_model\": {\n \"nano-banana\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"9:16\",\n \"16:9\",\n \"3:4\",\n \"4:3\",\n \"3:2\",\n \"2:3\",\n \"5:4\",\n \"4:5\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n }\n },\n \"nano-banana-2\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"1:4\",\n \"1:8\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:1\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"8:1\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n }\n },\n \"nano-banana-pro\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"2:3\",\n \"3:2\",\n \"3:4\",\n \"4:3\",\n \"4:5\",\n \"5:4\",\n \"9:16\",\n \"16:9\",\n \"21:9\",\n \"auto\"\n ]\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\",\n \"jpg\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n }\n }\n }\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type { CompletedEditImageResponse, EditImageParams, EditImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/edit_image';\n\n/** Modifies existing images based on text prompts. Requires source images to edit. */\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Edit an image using text prompts and reference images and wait until complete.\n * @param params Edit parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed edit with image results.\n */\n async run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<EditImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedEditImageResponse;\n }\n\n /**\n * Create an image edit task; returns immediately with a task id.\n * @param params Edit parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['edit-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image edit task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current image edit task status.\n */\n async get(id: string, options?: RequestOptions): Promise<EditImageResponse> {\n return this.http.request<EditImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export { NanoBananaClient } from './client';\nexport * from './types';\n\n// Re-export core errors for convenience\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n"],"mappings":";AAAA,SAAS,kBAAsC;;;ACC/C,SAAS,eAAe,sBAAsB;AAC9C,SAAS,yBAAyB;;;ACF3B,IAAM,WAAW;AAAA,EACtB,cAAc;AAAA,IACZ,UAAU;AAAA,MACR;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,oBAAoB;AAAA,QAClB,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,iBAAiB;AAAA,UACf,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAAqB;AAAA,UACnB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,eAAe;AAAA,QACb,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,iBAAiB;AAAA,UACf,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MACA,iBAAiB;AAAA,QACf,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;A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AAAA;AAAA,EAE/B;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAC5C,SAAK,YAAY,IAAI,UAAU,KAAK,IAAI;AAAA,EAC1C;AACF;;;AI/BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","validateParams","pollUntilComplete","ENDPOINT","pollUntilComplete","compactParams","validateParams"]}
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@runapi.ai/nano-banana",
3
- "version": "0.2.5",
4
- "description": "RunAPI Nano Banana SDK for JavaScript, Ruby, and Go",
3
+ "runapi": {
4
+ "slug": "nano-banana"
5
+ },
6
+ "version": "0.2.7",
7
+ "description": "RunAPI Nano Banana SDK for text-to-image and image editing workflows in JavaScript, Python, Ruby, Go, and Java",
5
8
  "main": "./dist/index.js",
6
9
  "module": "./dist/index.mjs",
7
10
  "types": "./dist/index.d.ts",
@@ -28,7 +31,7 @@
28
31
  "clean": "rm -rf dist"
29
32
  },
30
33
  "dependencies": {
31
- "@runapi.ai/core": "^0.2.5"
34
+ "@runapi.ai/core": "^0.2.7"
32
35
  },
33
36
  "devDependencies": {
34
37
  "@types/node": "^20.0.0",
@@ -49,8 +52,16 @@
49
52
  "api",
50
53
  "sdk",
51
54
  "typescript",
55
+ "python",
52
56
  "ruby",
53
- "golang"
57
+ "golang",
58
+ "java",
59
+ "maven",
60
+ "gradle",
61
+ "image-generation",
62
+ "text-to-image",
63
+ "image-api",
64
+ "nano-banana-api"
54
65
  ],
55
66
  "author": "RunAPI",
56
67
  "license": "Apache-2.0",
@@ -58,5 +69,8 @@
58
69
  "repository": {
59
70
  "type": "git",
60
71
  "url": "git+https://github.com/runapi-ai/nano-banana-sdk.git"
72
+ },
73
+ "bugs": {
74
+ "url": "https://github.com/runapi-ai/nano-banana-sdk/issues"
61
75
  }
62
76
  }
@@ -77,9 +77,11 @@ const url = result.images[0].url;
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
- - For nano banana api pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
84
+ - For pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
83
85
 
84
86
  ## License
85
87
 
@@ -25,14 +25,23 @@ 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
- ## Routing decision
28
+ ## Critical: Integration Runtime
29
29
 
30
- - One-off generation, editing, or transformation for the user use the **CLI path** with the `runapi` binary.
31
- - Building an app, backend, worker, library, or production codebase use the **SDK integration path**.
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
46
  Inspect the available commands and request fields with CLI help:
38
47
 
@@ -56,13 +65,9 @@ runapi wait <task-id> --service nano-banana --action text-to-image
56
65
 
57
66
  Available commands: `text-to-image`, `edit-image`.
58
67
 
59
- ## SDK integration path
60
-
61
- When integrating Nano Banana into an app, backend, worker, or library — not for one-off tasks — use a RunAPI SDK package:
68
+ ## Generated file storage
62
69
 
63
- - JavaScript / TypeScript: `@runapi.ai/nano-banana`
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