@runapi.ai/seedream 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -41,402 +41,6 @@ var import_core4 = 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
- "decompose-layers": {
48
- "models": [
49
- "seedream-5-pro-layer-decomposition"
50
- ],
51
- "fields_by_model": {
52
- "seedream-5-pro-layer-decomposition": {
53
- "image_url": {
54
- "required": true
55
- },
56
- "output_format": {
57
- "enum": [
58
- "png",
59
- "jpeg"
60
- ]
61
- },
62
- "prompt": {
63
- "max": 5e3,
64
- "length": true
65
- },
66
- "size": {
67
- "enum": [
68
- "auto",
69
- "1K",
70
- "1.5K",
71
- "2K"
72
- ]
73
- }
74
- }
75
- }
76
- },
77
- "edit-image": {
78
- "models": [
79
- "seedream-4.5-edit",
80
- "seedream-5-lite-edit",
81
- "seedream-5-pro-edit",
82
- "seedream-v4-edit"
83
- ],
84
- "fields_by_model": {
85
- "seedream-4.5-edit": {
86
- "aspect_ratio": {
87
- "enum": [
88
- "1:1",
89
- "4:3",
90
- "3:4",
91
- "16:9",
92
- "9:16",
93
- "2:3",
94
- "3:2",
95
- "21:9"
96
- ],
97
- "required": true
98
- },
99
- "output_count": {
100
- "type": "integer"
101
- },
102
- "output_quality": {
103
- "enum": [
104
- "basic",
105
- "high"
106
- ],
107
- "required": true
108
- },
109
- "seed": {
110
- "type": "integer"
111
- },
112
- "source_image_urls": {
113
- "required": true,
114
- "min_items": 1,
115
- "max_items": 14
116
- }
117
- },
118
- "seedream-5-lite-edit": {
119
- "aspect_ratio": {
120
- "enum": [
121
- "1:1",
122
- "4:3",
123
- "3:4",
124
- "16:9",
125
- "9:16",
126
- "2:3",
127
- "3:2",
128
- "21:9"
129
- ],
130
- "required": true
131
- },
132
- "output_count": {
133
- "type": "integer"
134
- },
135
- "output_format": {
136
- "enum": [
137
- "png",
138
- "jpeg"
139
- ]
140
- },
141
- "output_quality": {
142
- "enum": [
143
- "basic",
144
- "high",
145
- "ultra"
146
- ],
147
- "required": true
148
- },
149
- "seed": {
150
- "type": "integer"
151
- },
152
- "source_image_urls": {
153
- "required": true,
154
- "min_items": 1,
155
- "max_items": 14
156
- }
157
- },
158
- "seedream-5-pro-edit": {
159
- "aspect_ratio": {
160
- "enum": [
161
- "1:1",
162
- "4:3",
163
- "3:4",
164
- "16:9",
165
- "9:16",
166
- "2:3",
167
- "3:2",
168
- "21:9"
169
- ],
170
- "required": true
171
- },
172
- "output_format": {
173
- "enum": [
174
- "png",
175
- "jpeg"
176
- ]
177
- },
178
- "output_quality": {
179
- "enum": [
180
- "basic",
181
- "high"
182
- ],
183
- "required": true
184
- },
185
- "prompt": {
186
- "required": true,
187
- "min": 3,
188
- "max": 5e3,
189
- "length": true
190
- },
191
- "source_image_urls": {
192
- "required": true,
193
- "min_items": 1,
194
- "max_items": 10
195
- }
196
- },
197
- "seedream-v4-edit": {
198
- "aspect_ratio": {
199
- "enum": [
200
- "1:1",
201
- "4:3",
202
- "3:4",
203
- "3:2",
204
- "2:3",
205
- "16:9",
206
- "9:16",
207
- "21:9"
208
- ]
209
- },
210
- "output_count": {
211
- "enum": [
212
- 1,
213
- 2,
214
- 3,
215
- 4,
216
- 5,
217
- 6
218
- ],
219
- "type": "integer"
220
- },
221
- "output_resolution": {
222
- "enum": [
223
- "1k",
224
- "2k",
225
- "4k"
226
- ]
227
- },
228
- "seed": {
229
- "type": "integer"
230
- },
231
- "source_image_urls": {
232
- "required": true,
233
- "min_items": 1,
234
- "max_items": 10
235
- }
236
- }
237
- },
238
- "rules": [
239
- {
240
- "when": {
241
- "model": "seedream-4.5-edit"
242
- },
243
- "forbidden": [
244
- "output_format"
245
- ]
246
- },
247
- {
248
- "when": {
249
- "model": "seedream-5-pro-edit"
250
- },
251
- "forbidden": [
252
- "output_resolution",
253
- "output_count",
254
- "seed"
255
- ]
256
- },
257
- {
258
- "when": {
259
- "model": "seedream-v4-edit"
260
- },
261
- "forbidden": [
262
- "output_format"
263
- ]
264
- }
265
- ]
266
- },
267
- "text-to-image": {
268
- "models": [
269
- "seedream-4.5-text-to-image",
270
- "seedream-5-lite-text-to-image",
271
- "seedream-5-pro-text-to-image",
272
- "seedream-v4-text-to-image"
273
- ],
274
- "fields_by_model": {
275
- "seedream-4.5-text-to-image": {
276
- "aspect_ratio": {
277
- "enum": [
278
- "1:1",
279
- "4:3",
280
- "3:4",
281
- "16:9",
282
- "9:16",
283
- "2:3",
284
- "3:2",
285
- "21:9"
286
- ],
287
- "required": true
288
- },
289
- "output_count": {
290
- "type": "integer"
291
- },
292
- "output_quality": {
293
- "enum": [
294
- "basic",
295
- "high"
296
- ],
297
- "required": true
298
- },
299
- "seed": {
300
- "type": "integer"
301
- }
302
- },
303
- "seedream-5-lite-text-to-image": {
304
- "aspect_ratio": {
305
- "enum": [
306
- "1:1",
307
- "4:3",
308
- "3:4",
309
- "16:9",
310
- "9:16",
311
- "2:3",
312
- "3:2",
313
- "21:9"
314
- ],
315
- "required": true
316
- },
317
- "output_count": {
318
- "type": "integer"
319
- },
320
- "output_format": {
321
- "enum": [
322
- "png",
323
- "jpeg"
324
- ]
325
- },
326
- "output_quality": {
327
- "enum": [
328
- "basic",
329
- "high",
330
- "ultra"
331
- ],
332
- "required": true
333
- },
334
- "seed": {
335
- "type": "integer"
336
- }
337
- },
338
- "seedream-5-pro-text-to-image": {
339
- "aspect_ratio": {
340
- "enum": [
341
- "1:1",
342
- "4:3",
343
- "3:4",
344
- "16:9",
345
- "9:16",
346
- "2:3",
347
- "3:2",
348
- "21:9"
349
- ],
350
- "required": true
351
- },
352
- "output_format": {
353
- "enum": [
354
- "png",
355
- "jpeg"
356
- ]
357
- },
358
- "output_quality": {
359
- "enum": [
360
- "basic",
361
- "high"
362
- ],
363
- "required": true
364
- },
365
- "prompt": {
366
- "required": true,
367
- "min": 3,
368
- "max": 5e3,
369
- "length": true
370
- }
371
- },
372
- "seedream-v4-text-to-image": {
373
- "aspect_ratio": {
374
- "enum": [
375
- "1:1",
376
- "4:3",
377
- "3:4",
378
- "3:2",
379
- "2:3",
380
- "16:9",
381
- "9:16",
382
- "21:9"
383
- ]
384
- },
385
- "output_count": {
386
- "enum": [
387
- 1,
388
- 2,
389
- 3,
390
- 4,
391
- 5,
392
- 6
393
- ],
394
- "type": "integer"
395
- },
396
- "output_resolution": {
397
- "enum": [
398
- "1k",
399
- "2k",
400
- "4k"
401
- ]
402
- },
403
- "seed": {
404
- "type": "integer"
405
- }
406
- }
407
- },
408
- "rules": [
409
- {
410
- "when": {
411
- "model": "seedream-4.5-text-to-image"
412
- },
413
- "forbidden": [
414
- "output_format"
415
- ]
416
- },
417
- {
418
- "when": {
419
- "model": "seedream-5-pro-text-to-image"
420
- },
421
- "forbidden": [
422
- "output_resolution",
423
- "output_count",
424
- "seed"
425
- ]
426
- },
427
- {
428
- "when": {
429
- "model": "seedream-v4-text-to-image"
430
- },
431
- "forbidden": [
432
- "output_format"
433
- ]
434
- }
435
- ]
436
- }
437
- };
438
-
439
- // src/resources/text-to-image.ts
440
44
  var ENDPOINT = "/api/v1/seedream/text_to_image";
441
45
  var TextToImage = class {
442
46
  constructor(http) {
@@ -465,7 +69,6 @@ var TextToImage = class {
465
69
  */
466
70
  async create(params, options) {
467
71
  const body = (0, import_core.compactParams)(params);
468
- (0, import_core.validateParams)(contract["text-to-image"], body);
469
72
  return this.http.request("POST", ENDPOINT, {
470
73
  body,
471
74
  ...options
@@ -515,7 +118,6 @@ var EditImage = class {
515
118
  */
516
119
  async create(params, options) {
517
120
  const body = (0, import_core2.compactParams)(params);
518
- (0, import_core2.validateParams)(contract["edit-image"], body);
519
121
  return this.http.request("POST", ENDPOINT2, {
520
122
  body,
521
123
  ...options
@@ -552,7 +154,6 @@ var DecomposeLayers = class {
552
154
  }
553
155
  async create(params, options) {
554
156
  const body = (0, import_core3.compactParams)(params);
555
- (0, import_core3.validateParams)(contract["decompose-layers"], body);
556
157
  return this.http.request("POST", ENDPOINT3, { body, ...options });
557
158
  }
558
159
  async get(id, options) {
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/contract_gen.ts","../src/resources/edit-image.ts","../src/resources/decompose-layers.ts"],"sourcesContent":["export { SeedreamClient } from './client';\nexport * from './types';\n\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';\nimport { DecomposeLayers } from './resources/decompose-layers';\n\n/**\n * Seedream image generation and editing API client.\n *\n * Three model families with different field requirements:\n * - **4.5**: requires `aspect_ratio` and `output_quality`\n * - **5-lite**: same required fields as 4.5, faster generation\n * - **V4**: uses `output_resolution` instead; supports `seed` and batch `output_count`\n *\n * @example\n * ```typescript\n * const client = new SeedreamClient({ apiKey: 'your-api-key' });\n *\n * // Seedream 4.5\n * const result = await client.textToImage.run({\n * model: 'seedream-4.5-text-to-image',\n * prompt: 'A beautiful product render',\n * aspect_ratio: '16:9',\n * output_quality: 'high',\n * });\n *\n * // Seedream V4 with batch output\n * const batch = await client.textToImage.run({\n * model: 'seedream-v4-text-to-image',\n * prompt: 'Minimalist logo design',\n * output_count: 4,\n * });\n * ```\n */\nexport class SeedreamClient extends BaseClient {\n /** Text-to-image generation across Seedream model versions. */\n public readonly textToImage: TextToImage;\n /** Edit source images according to a text prompt. */\n public readonly editImage: EditImage;\n /** Separate an image into a base image and independent layers. */\n public readonly decomposeLayers: DecomposeLayers;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.editImage = new EditImage(this.http);\n this.decomposeLayers = new DecomposeLayers(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/seedream/text_to_image';\n\n/**\n * Generates images from text prompts across Seedream model versions.\n * Field requirements vary by model family: 4.5/5-Lite/5 Pro require\n * `aspect_ratio` and `output_quality`; V4 uses `output_resolution` and supports\n * `seed`/`output_count`.\n */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Create a text to image task and wait until complete.\n * @param params Text to image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed text to image response.\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 a text to image task; returns immediately with a task id.\n * @param params Text to image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result.\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 a text to image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text to image 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 \"decompose-layers\": {\n \"models\": [\n \"seedream-5-pro-layer-decomposition\"\n ],\n \"fields_by_model\": {\n \"seedream-5-pro-layer-decomposition\": {\n \"image_url\": {\n \"required\": true\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"prompt\": {\n \"max\": 5000,\n \"length\": true\n },\n \"size\": {\n \"enum\": [\n \"auto\",\n \"1K\",\n \"1.5K\",\n \"2K\"\n ]\n }\n }\n }\n },\n \"edit-image\": {\n \"models\": [\n \"seedream-4.5-edit\",\n \"seedream-5-lite-edit\",\n \"seedream-5-pro-edit\",\n \"seedream-v4-edit\"\n ],\n \"fields_by_model\": {\n \"seedream-4.5-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\"\n ],\n \"required\": true\n },\n \"seed\": {\n \"type\": \"integer\"\n },\n \"source_image_urls\": {\n \"required\": true,\n \"min_items\": 1,\n \"max_items\": 14\n }\n },\n \"seedream-5-lite-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\",\n \"ultra\"\n ],\n \"required\": true\n },\n \"seed\": {\n \"type\": \"integer\"\n },\n \"source_image_urls\": {\n \"required\": true,\n \"min_items\": 1,\n \"max_items\": 14\n }\n },\n \"seedream-5-pro-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\"\n ],\n \"required\": true\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 3,\n \"max\": 5000,\n \"length\": true\n },\n \"source_image_urls\": {\n \"required\": true,\n \"min_items\": 1,\n \"max_items\": 10\n }\n },\n \"seedream-v4-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"3:2\",\n \"2:3\",\n \"16:9\",\n \"9:16\",\n \"21:9\"\n ]\n },\n \"output_count\": {\n \"enum\": [\n 1,\n 2,\n 3,\n 4,\n 5,\n 6\n ],\n \"type\": \"integer\"\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n },\n \"seed\": {\n \"type\": \"integer\"\n },\n \"source_image_urls\": {\n \"required\": true,\n \"min_items\": 1,\n \"max_items\": 10\n }\n }\n },\n \"rules\": [\n {\n \"when\": {\n \"model\": \"seedream-4.5-edit\"\n },\n \"forbidden\": [\n \"output_format\"\n ]\n },\n {\n \"when\": {\n \"model\": \"seedream-5-pro-edit\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"output_count\",\n \"seed\"\n ]\n },\n {\n \"when\": {\n \"model\": \"seedream-v4-edit\"\n },\n \"forbidden\": [\n \"output_format\"\n ]\n }\n ]\n },\n \"text-to-image\": {\n \"models\": [\n \"seedream-4.5-text-to-image\",\n \"seedream-5-lite-text-to-image\",\n \"seedream-5-pro-text-to-image\",\n \"seedream-v4-text-to-image\"\n ],\n \"fields_by_model\": {\n \"seedream-4.5-text-to-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\"\n ],\n \"required\": true\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"seedream-5-lite-text-to-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\",\n \"ultra\"\n ],\n \"required\": true\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"seedream-5-pro-text-to-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\"\n ],\n \"required\": true\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 3,\n \"max\": 5000,\n \"length\": true\n }\n },\n \"seedream-v4-text-to-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"3:2\",\n \"2:3\",\n \"16:9\",\n \"9:16\",\n \"21:9\"\n ]\n },\n \"output_count\": {\n \"enum\": [\n 1,\n 2,\n 3,\n 4,\n 5,\n 6\n ],\n \"type\": \"integer\"\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n }\n },\n \"rules\": [\n {\n \"when\": {\n \"model\": \"seedream-4.5-text-to-image\"\n },\n \"forbidden\": [\n \"output_format\"\n ]\n },\n {\n \"when\": {\n \"model\": \"seedream-5-pro-text-to-image\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"output_count\",\n \"seed\"\n ]\n },\n {\n \"when\": {\n \"model\": \"seedream-v4-text-to-image\"\n },\n \"forbidden\": [\n \"output_format\"\n ]\n }\n ]\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedEditImageResponse,\n EditImageParams,\n EditImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/seedream/edit_image';\n\n/**\n * Modifies source images according to a text prompt.\n * 5 Pro and V4 accept up to 10 source images; 4.5 and 5-Lite accept up to 14.\n */\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Create an edit image task and wait until complete.\n * @param params Edit image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed edit image response.\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 edit image task; returns immediately with a task id.\n * @param params Edit image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result.\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 edit image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current edit image 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","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 CompletedDecomposeLayersResponse,\n DecomposeLayersParams,\n DecomposeLayersResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/seedream/decompose_layers';\n\n/** Separates one image into a base image and independent transparent layers. */\nexport class DecomposeLayers {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: DecomposeLayersParams, options?: RequestOptions & PollingOptions): Promise<CompletedDecomposeLayersResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<DecomposeLayersResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n }) as Promise<CompletedDecomposeLayersResponse>;\n }\n\n async create(params: DecomposeLayersParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['decompose-layers'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, { body, ...options });\n }\n\n async get(id: string, options?: RequestOptions): Promise<DecomposeLayersResponse> {\n return this.http.request<DecomposeLayersResponse>('GET', `${ENDPOINT}/${id}`, { ...options });\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,EACtB,oBAAoB;AAAA,IAClB,UAAU;AAAA,MACR;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,sCAAsC;AAAA,QACpC,aAAa;AAAA,UACX,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AAuD;AACjG,UAAM,WAAO,4BAAc,MAAM;AACjC,qCAAe,SAAS,kBAAkB,GAAmB,IAA+B;AAC5F,WAAO,KAAK,KAAK,QAA4B,QAAQA,WAAU,EAAE,MAAM,GAAG,QAAQ,CAAC;AAAA,EACrF;AAAA,EAEA,MAAM,IAAI,IAAY,SAA4D;AAChF,WAAO,KAAK,KAAK,QAAiC,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;AAAA,EAC9F;AACF;;;AJDO,IAAM,iBAAN,cAA6B,wBAAW;AAAA;AAAA,EAE7B;AAAA;AAAA,EAEA;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;AACxC,SAAK,kBAAkB,IAAI,gBAAgB,KAAK,IAAI;AAAA,EACtD;AACF;;;AD5CA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","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","../src/resources/decompose-layers.ts"],"sourcesContent":["export { SeedreamClient } from './client';\nexport * from './types';\n\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';\nimport { DecomposeLayers } from './resources/decompose-layers';\n\n/**\n * Seedream image generation and editing API client.\n *\n * Three model families with different field requirements:\n * - **4.5**: requires `aspect_ratio` and `output_quality`\n * - **5-lite**: same required fields as 4.5, faster generation\n * - **V4**: uses `output_resolution` instead; supports `seed` and batch `output_count`\n *\n * @example\n * ```typescript\n * const client = new SeedreamClient({ apiKey: 'your-api-key' });\n *\n * // Seedream 4.5\n * const result = await client.textToImage.run({\n * model: 'seedream-4.5-text-to-image',\n * prompt: 'A beautiful product render',\n * aspect_ratio: '16:9',\n * output_quality: 'high',\n * });\n *\n * // Seedream V4 with batch output\n * const batch = await client.textToImage.run({\n * model: 'seedream-v4-text-to-image',\n * prompt: 'Minimalist logo design',\n * output_count: 4,\n * });\n * ```\n */\nexport class SeedreamClient extends BaseClient {\n /** Text-to-image generation across Seedream model versions. */\n public readonly textToImage: TextToImage;\n /** Edit source images according to a text prompt. */\n public readonly editImage: EditImage;\n /** Separate an image into a base image and independent layers. */\n public readonly decomposeLayers: DecomposeLayers;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.editImage = new EditImage(this.http);\n this.decomposeLayers = new DecomposeLayers(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/seedream/text_to_image';\n\n/**\n * Generates images from text prompts across Seedream model versions.\n * Field requirements vary by model family: 4.5/5-Lite/5 Pro require\n * `aspect_ratio` and `output_quality`; V4 uses `output_resolution` and supports\n * `seed`/`output_count`.\n */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Create a text to image task and wait until complete.\n * @param params Text to image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed text to image response.\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 a text to image task; returns immediately with a task id.\n * @param params Text to image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text to image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text to image 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 {\n CompletedEditImageResponse,\n EditImageParams,\n EditImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/seedream/edit_image';\n\n/**\n * Modifies source images according to a text prompt.\n * 5 Pro and V4 accept up to 10 source images; 4.5 and 5-Lite accept up to 14.\n */\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Create an edit image task and wait until complete.\n * @param params Edit image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed edit image response.\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 edit image task; returns immediately with a task id.\n * @param params Edit image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result.\n */\n async create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an edit image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current edit image 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","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 CompletedDecomposeLayersResponse,\n DecomposeLayersParams,\n DecomposeLayersResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/seedream/decompose_layers';\n\n/** Separates one image into a base image and independent transparent layers. */\nexport class DecomposeLayers {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: DecomposeLayersParams, options?: RequestOptions & PollingOptions): Promise<CompletedDecomposeLayersResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<DecomposeLayersResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n }) as Promise<CompletedDecomposeLayersResponse>;\n }\n\n async create(params: DecomposeLayersParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, { body, ...options });\n }\n\n async get(id: string, options?: RequestOptions): Promise<DecomposeLayersResponse> {\n return this.http.request<DecomposeLayersResponse>('GET', `${ENDPOINT}/${id}`, { ...options });\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;AAQV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EA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AK,YAAY,IAAI,UAAU,KAAK,IAAI;AACxC,SAAK,kBAAkB,IAAI,gBAAgB,KAAK,IAAI;AAAA,EACtD;AACF;;;AD5CA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","import_core","import_internal","ENDPOINT","import_core"]}
package/dist/index.mjs CHANGED
@@ -2,404 +2,8 @@
2
2
  import { BaseClient } from "@runapi.ai/core";
3
3
 
4
4
  // src/resources/text-to-image.ts
5
- import { compactParams, validateParams } from "@runapi.ai/core";
5
+ import { compactParams } from "@runapi.ai/core";
6
6
  import { pollUntilComplete } from "@runapi.ai/core/internal";
7
-
8
- // src/contract_gen.ts
9
- var contract = {
10
- "decompose-layers": {
11
- "models": [
12
- "seedream-5-pro-layer-decomposition"
13
- ],
14
- "fields_by_model": {
15
- "seedream-5-pro-layer-decomposition": {
16
- "image_url": {
17
- "required": true
18
- },
19
- "output_format": {
20
- "enum": [
21
- "png",
22
- "jpeg"
23
- ]
24
- },
25
- "prompt": {
26
- "max": 5e3,
27
- "length": true
28
- },
29
- "size": {
30
- "enum": [
31
- "auto",
32
- "1K",
33
- "1.5K",
34
- "2K"
35
- ]
36
- }
37
- }
38
- }
39
- },
40
- "edit-image": {
41
- "models": [
42
- "seedream-4.5-edit",
43
- "seedream-5-lite-edit",
44
- "seedream-5-pro-edit",
45
- "seedream-v4-edit"
46
- ],
47
- "fields_by_model": {
48
- "seedream-4.5-edit": {
49
- "aspect_ratio": {
50
- "enum": [
51
- "1:1",
52
- "4:3",
53
- "3:4",
54
- "16:9",
55
- "9:16",
56
- "2:3",
57
- "3:2",
58
- "21:9"
59
- ],
60
- "required": true
61
- },
62
- "output_count": {
63
- "type": "integer"
64
- },
65
- "output_quality": {
66
- "enum": [
67
- "basic",
68
- "high"
69
- ],
70
- "required": true
71
- },
72
- "seed": {
73
- "type": "integer"
74
- },
75
- "source_image_urls": {
76
- "required": true,
77
- "min_items": 1,
78
- "max_items": 14
79
- }
80
- },
81
- "seedream-5-lite-edit": {
82
- "aspect_ratio": {
83
- "enum": [
84
- "1:1",
85
- "4:3",
86
- "3:4",
87
- "16:9",
88
- "9:16",
89
- "2:3",
90
- "3:2",
91
- "21:9"
92
- ],
93
- "required": true
94
- },
95
- "output_count": {
96
- "type": "integer"
97
- },
98
- "output_format": {
99
- "enum": [
100
- "png",
101
- "jpeg"
102
- ]
103
- },
104
- "output_quality": {
105
- "enum": [
106
- "basic",
107
- "high",
108
- "ultra"
109
- ],
110
- "required": true
111
- },
112
- "seed": {
113
- "type": "integer"
114
- },
115
- "source_image_urls": {
116
- "required": true,
117
- "min_items": 1,
118
- "max_items": 14
119
- }
120
- },
121
- "seedream-5-pro-edit": {
122
- "aspect_ratio": {
123
- "enum": [
124
- "1:1",
125
- "4:3",
126
- "3:4",
127
- "16:9",
128
- "9:16",
129
- "2:3",
130
- "3:2",
131
- "21:9"
132
- ],
133
- "required": true
134
- },
135
- "output_format": {
136
- "enum": [
137
- "png",
138
- "jpeg"
139
- ]
140
- },
141
- "output_quality": {
142
- "enum": [
143
- "basic",
144
- "high"
145
- ],
146
- "required": true
147
- },
148
- "prompt": {
149
- "required": true,
150
- "min": 3,
151
- "max": 5e3,
152
- "length": true
153
- },
154
- "source_image_urls": {
155
- "required": true,
156
- "min_items": 1,
157
- "max_items": 10
158
- }
159
- },
160
- "seedream-v4-edit": {
161
- "aspect_ratio": {
162
- "enum": [
163
- "1:1",
164
- "4:3",
165
- "3:4",
166
- "3:2",
167
- "2:3",
168
- "16:9",
169
- "9:16",
170
- "21:9"
171
- ]
172
- },
173
- "output_count": {
174
- "enum": [
175
- 1,
176
- 2,
177
- 3,
178
- 4,
179
- 5,
180
- 6
181
- ],
182
- "type": "integer"
183
- },
184
- "output_resolution": {
185
- "enum": [
186
- "1k",
187
- "2k",
188
- "4k"
189
- ]
190
- },
191
- "seed": {
192
- "type": "integer"
193
- },
194
- "source_image_urls": {
195
- "required": true,
196
- "min_items": 1,
197
- "max_items": 10
198
- }
199
- }
200
- },
201
- "rules": [
202
- {
203
- "when": {
204
- "model": "seedream-4.5-edit"
205
- },
206
- "forbidden": [
207
- "output_format"
208
- ]
209
- },
210
- {
211
- "when": {
212
- "model": "seedream-5-pro-edit"
213
- },
214
- "forbidden": [
215
- "output_resolution",
216
- "output_count",
217
- "seed"
218
- ]
219
- },
220
- {
221
- "when": {
222
- "model": "seedream-v4-edit"
223
- },
224
- "forbidden": [
225
- "output_format"
226
- ]
227
- }
228
- ]
229
- },
230
- "text-to-image": {
231
- "models": [
232
- "seedream-4.5-text-to-image",
233
- "seedream-5-lite-text-to-image",
234
- "seedream-5-pro-text-to-image",
235
- "seedream-v4-text-to-image"
236
- ],
237
- "fields_by_model": {
238
- "seedream-4.5-text-to-image": {
239
- "aspect_ratio": {
240
- "enum": [
241
- "1:1",
242
- "4:3",
243
- "3:4",
244
- "16:9",
245
- "9:16",
246
- "2:3",
247
- "3:2",
248
- "21:9"
249
- ],
250
- "required": true
251
- },
252
- "output_count": {
253
- "type": "integer"
254
- },
255
- "output_quality": {
256
- "enum": [
257
- "basic",
258
- "high"
259
- ],
260
- "required": true
261
- },
262
- "seed": {
263
- "type": "integer"
264
- }
265
- },
266
- "seedream-5-lite-text-to-image": {
267
- "aspect_ratio": {
268
- "enum": [
269
- "1:1",
270
- "4:3",
271
- "3:4",
272
- "16:9",
273
- "9:16",
274
- "2:3",
275
- "3:2",
276
- "21:9"
277
- ],
278
- "required": true
279
- },
280
- "output_count": {
281
- "type": "integer"
282
- },
283
- "output_format": {
284
- "enum": [
285
- "png",
286
- "jpeg"
287
- ]
288
- },
289
- "output_quality": {
290
- "enum": [
291
- "basic",
292
- "high",
293
- "ultra"
294
- ],
295
- "required": true
296
- },
297
- "seed": {
298
- "type": "integer"
299
- }
300
- },
301
- "seedream-5-pro-text-to-image": {
302
- "aspect_ratio": {
303
- "enum": [
304
- "1:1",
305
- "4:3",
306
- "3:4",
307
- "16:9",
308
- "9:16",
309
- "2:3",
310
- "3:2",
311
- "21:9"
312
- ],
313
- "required": true
314
- },
315
- "output_format": {
316
- "enum": [
317
- "png",
318
- "jpeg"
319
- ]
320
- },
321
- "output_quality": {
322
- "enum": [
323
- "basic",
324
- "high"
325
- ],
326
- "required": true
327
- },
328
- "prompt": {
329
- "required": true,
330
- "min": 3,
331
- "max": 5e3,
332
- "length": true
333
- }
334
- },
335
- "seedream-v4-text-to-image": {
336
- "aspect_ratio": {
337
- "enum": [
338
- "1:1",
339
- "4:3",
340
- "3:4",
341
- "3:2",
342
- "2:3",
343
- "16:9",
344
- "9:16",
345
- "21:9"
346
- ]
347
- },
348
- "output_count": {
349
- "enum": [
350
- 1,
351
- 2,
352
- 3,
353
- 4,
354
- 5,
355
- 6
356
- ],
357
- "type": "integer"
358
- },
359
- "output_resolution": {
360
- "enum": [
361
- "1k",
362
- "2k",
363
- "4k"
364
- ]
365
- },
366
- "seed": {
367
- "type": "integer"
368
- }
369
- }
370
- },
371
- "rules": [
372
- {
373
- "when": {
374
- "model": "seedream-4.5-text-to-image"
375
- },
376
- "forbidden": [
377
- "output_format"
378
- ]
379
- },
380
- {
381
- "when": {
382
- "model": "seedream-5-pro-text-to-image"
383
- },
384
- "forbidden": [
385
- "output_resolution",
386
- "output_count",
387
- "seed"
388
- ]
389
- },
390
- {
391
- "when": {
392
- "model": "seedream-v4-text-to-image"
393
- },
394
- "forbidden": [
395
- "output_format"
396
- ]
397
- }
398
- ]
399
- }
400
- };
401
-
402
- // src/resources/text-to-image.ts
403
7
  var ENDPOINT = "/api/v1/seedream/text_to_image";
404
8
  var TextToImage = class {
405
9
  constructor(http) {
@@ -428,7 +32,6 @@ var TextToImage = class {
428
32
  */
429
33
  async create(params, options) {
430
34
  const body = compactParams(params);
431
- validateParams(contract["text-to-image"], body);
432
35
  return this.http.request("POST", ENDPOINT, {
433
36
  body,
434
37
  ...options
@@ -448,7 +51,7 @@ var TextToImage = class {
448
51
  };
449
52
 
450
53
  // src/resources/edit-image.ts
451
- import { compactParams as compactParams2, validateParams as validateParams2 } from "@runapi.ai/core";
54
+ import { compactParams as compactParams2 } from "@runapi.ai/core";
452
55
  import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
453
56
  var ENDPOINT2 = "/api/v1/seedream/edit_image";
454
57
  var EditImage = class {
@@ -478,7 +81,6 @@ var EditImage = class {
478
81
  */
479
82
  async create(params, options) {
480
83
  const body = compactParams2(params);
481
- validateParams2(contract["edit-image"], body);
482
84
  return this.http.request("POST", ENDPOINT2, {
483
85
  body,
484
86
  ...options
@@ -498,7 +100,7 @@ var EditImage = class {
498
100
  };
499
101
 
500
102
  // src/resources/decompose-layers.ts
501
- import { compactParams as compactParams3, validateParams as validateParams3 } from "@runapi.ai/core";
103
+ import { compactParams as compactParams3 } from "@runapi.ai/core";
502
104
  import { pollUntilComplete as pollUntilComplete3 } from "@runapi.ai/core/internal";
503
105
  var ENDPOINT3 = "/api/v1/seedream/decompose_layers";
504
106
  var DecomposeLayers = class {
@@ -515,7 +117,6 @@ var DecomposeLayers = class {
515
117
  }
516
118
  async create(params, options) {
517
119
  const body = compactParams3(params);
518
- validateParams3(contract["decompose-layers"], body);
519
120
  return this.http.request("POST", ENDPOINT3, { body, ...options });
520
121
  }
521
122
  async get(id, options) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.ts","../src/resources/edit-image.ts","../src/resources/decompose-layers.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';\nimport { DecomposeLayers } from './resources/decompose-layers';\n\n/**\n * Seedream image generation and editing API client.\n *\n * Three model families with different field requirements:\n * - **4.5**: requires `aspect_ratio` and `output_quality`\n * - **5-lite**: same required fields as 4.5, faster generation\n * - **V4**: uses `output_resolution` instead; supports `seed` and batch `output_count`\n *\n * @example\n * ```typescript\n * const client = new SeedreamClient({ apiKey: 'your-api-key' });\n *\n * // Seedream 4.5\n * const result = await client.textToImage.run({\n * model: 'seedream-4.5-text-to-image',\n * prompt: 'A beautiful product render',\n * aspect_ratio: '16:9',\n * output_quality: 'high',\n * });\n *\n * // Seedream V4 with batch output\n * const batch = await client.textToImage.run({\n * model: 'seedream-v4-text-to-image',\n * prompt: 'Minimalist logo design',\n * output_count: 4,\n * });\n * ```\n */\nexport class SeedreamClient extends BaseClient {\n /** Text-to-image generation across Seedream model versions. */\n public readonly textToImage: TextToImage;\n /** Edit source images according to a text prompt. */\n public readonly editImage: EditImage;\n /** Separate an image into a base image and independent layers. */\n public readonly decomposeLayers: DecomposeLayers;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.editImage = new EditImage(this.http);\n this.decomposeLayers = new DecomposeLayers(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/seedream/text_to_image';\n\n/**\n * Generates images from text prompts across Seedream model versions.\n * Field requirements vary by model family: 4.5/5-Lite/5 Pro require\n * `aspect_ratio` and `output_quality`; V4 uses `output_resolution` and supports\n * `seed`/`output_count`.\n */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Create a text to image task and wait until complete.\n * @param params Text to image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed text to image response.\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 a text to image task; returns immediately with a task id.\n * @param params Text to image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result.\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 a text to image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text to image 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 \"decompose-layers\": {\n \"models\": [\n \"seedream-5-pro-layer-decomposition\"\n ],\n \"fields_by_model\": {\n \"seedream-5-pro-layer-decomposition\": {\n \"image_url\": {\n \"required\": true\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"prompt\": {\n \"max\": 5000,\n \"length\": true\n },\n \"size\": {\n \"enum\": [\n \"auto\",\n \"1K\",\n \"1.5K\",\n \"2K\"\n ]\n }\n }\n }\n },\n \"edit-image\": {\n \"models\": [\n \"seedream-4.5-edit\",\n \"seedream-5-lite-edit\",\n \"seedream-5-pro-edit\",\n \"seedream-v4-edit\"\n ],\n \"fields_by_model\": {\n \"seedream-4.5-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\"\n ],\n \"required\": true\n },\n \"seed\": {\n \"type\": \"integer\"\n },\n \"source_image_urls\": {\n \"required\": true,\n \"min_items\": 1,\n \"max_items\": 14\n }\n },\n \"seedream-5-lite-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\",\n \"ultra\"\n ],\n \"required\": true\n },\n \"seed\": {\n \"type\": \"integer\"\n },\n \"source_image_urls\": {\n \"required\": true,\n \"min_items\": 1,\n \"max_items\": 14\n }\n },\n \"seedream-5-pro-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\"\n ],\n \"required\": true\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 3,\n \"max\": 5000,\n \"length\": true\n },\n \"source_image_urls\": {\n \"required\": true,\n \"min_items\": 1,\n \"max_items\": 10\n }\n },\n \"seedream-v4-edit\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"3:2\",\n \"2:3\",\n \"16:9\",\n \"9:16\",\n \"21:9\"\n ]\n },\n \"output_count\": {\n \"enum\": [\n 1,\n 2,\n 3,\n 4,\n 5,\n 6\n ],\n \"type\": \"integer\"\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n },\n \"seed\": {\n \"type\": \"integer\"\n },\n \"source_image_urls\": {\n \"required\": true,\n \"min_items\": 1,\n \"max_items\": 10\n }\n }\n },\n \"rules\": [\n {\n \"when\": {\n \"model\": \"seedream-4.5-edit\"\n },\n \"forbidden\": [\n \"output_format\"\n ]\n },\n {\n \"when\": {\n \"model\": \"seedream-5-pro-edit\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"output_count\",\n \"seed\"\n ]\n },\n {\n \"when\": {\n \"model\": \"seedream-v4-edit\"\n },\n \"forbidden\": [\n \"output_format\"\n ]\n }\n ]\n },\n \"text-to-image\": {\n \"models\": [\n \"seedream-4.5-text-to-image\",\n \"seedream-5-lite-text-to-image\",\n \"seedream-5-pro-text-to-image\",\n \"seedream-v4-text-to-image\"\n ],\n \"fields_by_model\": {\n \"seedream-4.5-text-to-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\"\n ],\n \"required\": true\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"seedream-5-lite-text-to-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_count\": {\n \"type\": \"integer\"\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\",\n \"ultra\"\n ],\n \"required\": true\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n },\n \"seedream-5-pro-text-to-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"2:3\",\n \"3:2\",\n \"21:9\"\n ],\n \"required\": true\n },\n \"output_format\": {\n \"enum\": [\n \"png\",\n \"jpeg\"\n ]\n },\n \"output_quality\": {\n \"enum\": [\n \"basic\",\n \"high\"\n ],\n \"required\": true\n },\n \"prompt\": {\n \"required\": true,\n \"min\": 3,\n \"max\": 5000,\n \"length\": true\n }\n },\n \"seedream-v4-text-to-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"3:2\",\n \"2:3\",\n \"16:9\",\n \"9:16\",\n \"21:9\"\n ]\n },\n \"output_count\": {\n \"enum\": [\n 1,\n 2,\n 3,\n 4,\n 5,\n 6\n ],\n \"type\": \"integer\"\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\",\n \"4k\"\n ]\n },\n \"seed\": {\n \"type\": \"integer\"\n }\n }\n },\n \"rules\": [\n {\n \"when\": {\n \"model\": \"seedream-4.5-text-to-image\"\n },\n \"forbidden\": [\n \"output_format\"\n ]\n },\n {\n \"when\": {\n \"model\": \"seedream-5-pro-text-to-image\"\n },\n \"forbidden\": [\n \"output_resolution\",\n \"output_count\",\n \"seed\"\n ]\n },\n {\n \"when\": {\n \"model\": \"seedream-v4-text-to-image\"\n },\n \"forbidden\": [\n \"output_format\"\n ]\n }\n ]\n }\n} as const;\n","import type { HttpClient, RequestOptions, PollingOptions, ActionSchema } from '@runapi.ai/core';\nimport { compactParams, validateParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport { contract } from '../contract_gen';\nimport type {\n CompletedEditImageResponse,\n EditImageParams,\n EditImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/seedream/edit_image';\n\n/**\n * Modifies source images according to a text prompt.\n * 5 Pro and V4 accept up to 10 source images; 4.5 and 5-Lite accept up to 14.\n */\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Create an edit image task and wait until complete.\n * @param params Edit image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed edit image response.\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 edit image task; returns immediately with a task id.\n * @param params Edit image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result.\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 edit image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current edit image 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","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 CompletedDecomposeLayersResponse,\n DecomposeLayersParams,\n DecomposeLayersResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/seedream/decompose_layers';\n\n/** Separates one image into a base image and independent transparent layers. */\nexport class DecomposeLayers {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: DecomposeLayersParams, options?: RequestOptions & PollingOptions): Promise<CompletedDecomposeLayersResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<DecomposeLayersResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n }) as Promise<CompletedDecomposeLayersResponse>;\n }\n\n async create(params: DecomposeLayersParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['decompose-layers'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, { body, ...options });\n }\n\n async get(id: string, options?: RequestOptions): Promise<DecomposeLayersResponse> {\n return this.http.request<DecomposeLayersResponse>('GET', `${ENDPOINT}/${id}`, { ...options });\n }\n}\n","export { SeedreamClient } from './client';\nexport * from './types';\n\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,oBAAoB;AAAA,IAClB,UAAU;AAAA,MACR;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,sCAAsC;AAAA,QACpC,aAAa;AAAA,UACX,YAAY;AAAA,QACd;AAAA,QACA,iBAAiB;AAAA,UACf,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,UAAU;AAAA,UACR,OAAO;AAAA,UACP,UAAU;AAAA,QACZ;AAAA,QACA,QAAQ;AAAA,UACN,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,cAAc;AAAA,IACZ,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,qBAAqB;AAAA,QACnB,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UACA,YAAY;AAAA,QACd;AAAA,QACA,gBAAgB;AAAA,UACd,QAAQ;AAAA,QACV;AAAA,QACA,kBAAkB;AAAA,UAChB,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AAAA,UACA,YAAY;AAAA,QACd;AAAA,QACA,QAAQ;A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ACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","validateParams","pollUntilComplete","ENDPOINT","pollUntilComplete","compactParams","validateParams","compactParams","validateParams","pollUntilComplete","ENDPOINT","pollUntilComplete","compactParams","validateParams"]}
1
+ {"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/resources/edit-image.ts","../src/resources/decompose-layers.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';\nimport { DecomposeLayers } from './resources/decompose-layers';\n\n/**\n * Seedream image generation and editing API client.\n *\n * Three model families with different field requirements:\n * - **4.5**: requires `aspect_ratio` and `output_quality`\n * - **5-lite**: same required fields as 4.5, faster generation\n * - **V4**: uses `output_resolution` instead; supports `seed` and batch `output_count`\n *\n * @example\n * ```typescript\n * const client = new SeedreamClient({ apiKey: 'your-api-key' });\n *\n * // Seedream 4.5\n * const result = await client.textToImage.run({\n * model: 'seedream-4.5-text-to-image',\n * prompt: 'A beautiful product render',\n * aspect_ratio: '16:9',\n * output_quality: 'high',\n * });\n *\n * // Seedream V4 with batch output\n * const batch = await client.textToImage.run({\n * model: 'seedream-v4-text-to-image',\n * prompt: 'Minimalist logo design',\n * output_count: 4,\n * });\n * ```\n */\nexport class SeedreamClient extends BaseClient {\n /** Text-to-image generation across Seedream model versions. */\n public readonly textToImage: TextToImage;\n /** Edit source images according to a text prompt. */\n public readonly editImage: EditImage;\n /** Separate an image into a base image and independent layers. */\n public readonly decomposeLayers: DecomposeLayers;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.editImage = new EditImage(this.http);\n this.decomposeLayers = new DecomposeLayers(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/seedream/text_to_image';\n\n/**\n * Generates images from text prompts across Seedream model versions.\n * Field requirements vary by model family: 4.5/5-Lite/5 Pro require\n * `aspect_ratio` and `output_quality`; V4 uses `output_resolution` and supports\n * `seed`/`output_count`.\n */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Create a text to image task and wait until complete.\n * @param params Text to image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed text to image response.\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 a text to image task; returns immediately with a task id.\n * @param params Text to image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text to image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text to image 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 {\n CompletedEditImageResponse,\n EditImageParams,\n EditImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/seedream/edit_image';\n\n/**\n * Modifies source images according to a text prompt.\n * 5 Pro and V4 accept up to 10 source images; 4.5 and 5-Lite accept up to 14.\n */\nexport class EditImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Create an edit image task and wait until complete.\n * @param params Edit image parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed edit image response.\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 edit image task; returns immediately with a task id.\n * @param params Edit image parameters.\n * @param options Per-request overrides.\n * @returns The task creation result.\n */\n async create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an edit image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current edit image 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","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 CompletedDecomposeLayersResponse,\n DecomposeLayersParams,\n DecomposeLayersResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/seedream/decompose_layers';\n\n/** Separates one image into a base image and independent transparent layers. */\nexport class DecomposeLayers {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: DecomposeLayersParams, options?: RequestOptions & PollingOptions): Promise<CompletedDecomposeLayersResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<DecomposeLayersResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n }) as Promise<CompletedDecomposeLayersResponse>;\n }\n\n async create(params: DecomposeLayersParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, { body, ...options });\n }\n\n async get(id: string, options?: RequestOptions): Promise<DecomposeLayersResponse> {\n return this.http.request<DecomposeLayersResponse>('GET', `${ENDPOINT}/${id}`, { ...options });\n }\n}\n","export { SeedreamClient } from './client';\nexport * from './types';\n\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;AAQV,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,UAAM,OAAO,cAAc,MAAM;AACjC,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAA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AQ,OAAO;AAChD,WAAOD,mBAA2C,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MAC7E,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OAAO,QAA+B,SAAuD;AACjG,UAAM,OAAOD,eAAc,MAAM;AACjC,WAAO,KAAK,KAAK,QAA4B,QAAQE,WAAU,EAAE,MAAM,GAAG,QAAQ,CAAC;AAAA,EACrF;AAAA,EAEA,MAAM,IAAI,IAAY,SAA4D;AAChF,WAAO,KAAK,KAAK,QAAiC,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;AAAA,EAC9F;AACF;;;AHCO,IAAM,iBAAN,cAA6B,WAAW;AAAA;AAAA,EAE7B;AAAA;AAAA,EAEA;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;AACxC,SAAK,kBAAkB,IAAI,gBAAgB,KAAK,IAAI;AAAA,EACtD;AACF;;;AI5CA;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","compactParams","pollUntilComplete","ENDPOINT"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "runapi": {
4
4
  "slug": "seedream"
5
5
  },
6
- "version": "0.3.1",
6
+ "version": "0.4.0",
7
7
  "description": "RunAPI Seedream SDK for text-to-image and edit-image workflows in JavaScript, Python, Ruby, Go, Java, and PHP",
8
8
  "main": "./dist/index.js",
9
9
  "module": "./dist/index.mjs",
@@ -31,7 +31,7 @@
31
31
  "clean": "rm -rf dist"
32
32
  },
33
33
  "dependencies": {
34
- "@runapi.ai/core": "^0.4.3"
34
+ "@runapi.ai/core": "^0.5.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^20.0.0",