@runapi.ai/nano-banana 0.2.5 → 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 CHANGED
@@ -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,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
@@ -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
- /** Text-to-image operations. */
138
+ var NanoBananaClient = class extends import_core3.BaseClient {
139
+ /** Generate images from text prompts with optional reference image guidance. */
104
140
  textToImage;
105
- /** Image editing operations. */
141
+ /** Edit existing images using text prompts and source images. */
106
142
  editImage;
107
143
  constructor(options = {}) {
108
- const http = (0, import_core3.createHttpClient)(options);
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 { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { EditImage } from './resources/edit-image';\n\n/**\n * NanoBanana text-to-image API client.\n *\n * @example\n * ```typescript\n * const client = new NanoBananaClient({\n * apiKey: 'your-api-key',\n * baseUrl: 'https://runapi.ai',\n * });\n *\n * const result = await client.textToImage.run({\n * model: 'flux-kontext-pro',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class NanoBananaClient {\n /** Text-to-image operations. */\n public readonly textToImage: TextToImage;\n /** Image editing operations. */\n public readonly editImage: EditImage;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToImage = new TextToImage(http);\n this.editImage = new EditImage(http);\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type {\n CompletedTextToImageResponse,\n TextToImageParams,\n TextToImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/text_to_image';\n\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedTextToImageResponse;\n }\n\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<TextToImageResponse> {\n return this.http.request<TextToImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","import type { HttpClient, RequestOptions, PollingOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type { CompletedEditImageResponse, EditImageParams, EditImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/nano_banana/edit_image';\n\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<EditImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedEditImageResponse;\n }\n\n async create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n async get(id: string, options?: RequestOptions): Promise<EditImageResponse> {\n return this.http.request<EditImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAqD;;;ACCrD,kBAA8B;AAC9B,sBAAkC;AAQlC,IAAM,WAAW;AAEV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,UAAM,mCAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,UAAM,2BAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ACnCA,IAAAC,eAA8B;AAC9B,IAAAC,mBAAkC;AAGlC,IAAMC,YAAW;AAEV,IAAM,YAAN,MAAgB;AAAA,EACrB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAAyB,SAAgF;AACjH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,UAAM,oCAAqC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACvF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAAyB,SAAuD;AAC3F,WAAO,KAAK,KAAK,QAA4B,QAAQA,WAAU;AAAA,MAC7D,UAAM,4BAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAsD;AAC1E,WAAO,KAAK,KAAK,QAA2B,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI;AAAA,MACtE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AFXO,IAAM,mBAAN,MAAuB;AAAA;AAAA,EAEZ;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,WAAO,+BAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,YAAY,IAAI,UAAU,IAAI;AAAA,EACrC;AACF;;;AD3BA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","import_core"]}
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 { createHttpClient } from "@runapi.ai/core";
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
- /** Text-to-image operations. */
101
+ var NanoBananaClient = class extends BaseClient {
102
+ /** Generate images from text prompts with optional reference image guidance. */
67
103
  textToImage;
68
- /** Image editing operations. */
104
+ /** Edit existing images using text prompts and source images. */
69
105
  editImage;
70
106
  constructor(options = {}) {
71
- const http = createHttpClient(options);
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
 
@@ -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';\n"],"mappings":";AAAA,SAAS,wBAA4C;;;ACCrD,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAQlC,IAAM,WAAW;AAEV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAM,kBAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,MAAM,cAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ACnCA,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,qBAAAC,0BAAyB;AAGlC,IAAMC,YAAW;AAEV,IAAM,YAAN,MAAgB;AAAA,EACrB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAAyB,SAAgF;AACjH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAMD,mBAAqC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACvF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAAyB,SAAuD;AAC3F,WAAO,KAAK,KAAK,QAA4B,QAAQC,WAAU;AAAA,MAC7D,MAAMF,eAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAsD;AAC1E,WAAO,KAAK,KAAK,QAA2B,OAAO,GAAGE,SAAQ,IAAI,EAAE,IAAI;AAAA,MACtE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AFXO,IAAM,mBAAN,MAAuB;AAAA;AAAA,EAEZ;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO,iBAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,YAAY,IAAI,UAAU,IAAI;AAAA,EACrC;AACF;;;AG3BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","pollUntilComplete","ENDPOINT"]}
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.5",
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",
@@ -28,7 +28,7 @@
28
28
  "clean": "rm -rf dist"
29
29
  },
30
30
  "dependencies": {
31
- "@runapi.ai/core": "^0.2.5"
31
+ "@runapi.ai/core": "^0.2.6"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^20.0.0",
@@ -77,6 +77,8 @@ 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
84
  - For nano banana api pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
@@ -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