@runapi.ai/seedream 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,6 +28,8 @@ const status = await client.textToImage.get(task.id);
28
28
 
29
29
  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.
30
30
 
31
+ 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.
32
+
31
33
  ## Language notes
32
34
 
33
35
  Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The package exposes `textToImage` for text models and `editImage` for editing models. 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,44 @@
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
+ /** Union of all Seedream model identifiers across text-to-image and edit endpoints. */
4
5
  type SeedreamModel = 'seedream-4.5-text-to-image' | 'seedream-4.5-edit' | 'seedream-5-lite-text-to-image' | 'seedream-5-lite-edit' | 'seedream-v4-text-to-image' | 'seedream-v4-edit';
6
+ /** Models accepted by the text-to-image endpoint. */
5
7
  type TextToImageModel = 'seedream-4.5-text-to-image' | 'seedream-5-lite-text-to-image' | 'seedream-v4-text-to-image';
8
+ /** Models accepted by the edit-image endpoint. */
6
9
  type EditImageModel = 'seedream-4.5-edit' | 'seedream-5-lite-edit' | 'seedream-v4-edit';
7
10
  type AspectRatio = '1:1' | '4:3' | '3:4' | '16:9' | '9:16' | '2:3' | '3:2' | '21:9';
11
+ /** Quality preset for 4.5 and 5-lite models. */
8
12
  type OutputQuality = 'basic' | 'high';
13
+ /** Pixel resolution tier for V4 models. */
9
14
  type V4OutputResolution = '1k' | '2k' | '4k';
15
+ /**
16
+ * Shared parameters for 4.5 and 5-lite models.
17
+ * Both `aspect_ratio` and `output_quality` are required for these model families.
18
+ */
10
19
  interface ImageGenerationBaseParams {
11
20
  prompt: string;
12
21
  aspect_ratio: AspectRatio;
13
22
  output_quality: OutputQuality;
23
+ /** Toggle content safety filtering. */
14
24
  enable_safety_checker?: boolean;
15
25
  callback_url?: string;
16
26
  }
27
+ /**
28
+ * Shared parameters for V4 models.
29
+ * Uses `output_resolution` instead of `output_quality`, and supports
30
+ * reproducible generation via `seed` and batch output via `output_count`.
31
+ */
17
32
  interface V4GenerationBaseParams {
18
33
  prompt: string;
19
34
  aspect_ratio?: AspectRatio;
35
+ /** Output resolution tier (default: "1k"). */
20
36
  output_resolution?: V4OutputResolution;
37
+ /** Number of images to generate (default: 1). */
21
38
  output_count?: number;
39
+ /** Fixed seed for reproducible generation. */
22
40
  seed?: number;
41
+ /** Toggle content safety filtering. */
23
42
  enable_safety_checker?: boolean;
24
43
  callback_url?: string;
25
44
  }
@@ -28,6 +47,7 @@ interface Generation45TextParams extends ImageGenerationBaseParams {
28
47
  }
29
48
  interface Generation45EditImageParams extends ImageGenerationBaseParams {
30
49
  model: 'seedream-4.5-edit';
50
+ /** Source image URLs to edit (up to 14 for 4.5 models). */
31
51
  source_image_urls: string[];
32
52
  }
33
53
  interface Generation5LiteTextParams extends ImageGenerationBaseParams {
@@ -35,6 +55,7 @@ interface Generation5LiteTextParams extends ImageGenerationBaseParams {
35
55
  }
36
56
  interface Generation5LiteEditParams extends ImageGenerationBaseParams {
37
57
  model: 'seedream-5-lite-edit';
58
+ /** Source image URLs to edit (up to 14 for 5-lite models). */
38
59
  source_image_urls: string[];
39
60
  }
40
61
  interface GenerationV4TextParams extends V4GenerationBaseParams {
@@ -42,6 +63,7 @@ interface GenerationV4TextParams extends V4GenerationBaseParams {
42
63
  }
43
64
  interface GenerationV4EditParams extends V4GenerationBaseParams {
44
65
  model: 'seedream-v4-edit';
66
+ /** Source image URLs to edit (up to 10 for V4 models). */
45
67
  source_image_urls: string[];
46
68
  }
47
69
  type TextToImageParams = Generation45TextParams | Generation5LiteTextParams | GenerationV4TextParams;
@@ -49,6 +71,7 @@ type EditImageParams = Generation45EditImageParams | Generation5LiteEditParams |
49
71
  interface TaskCreateResponse {
50
72
  id: string;
51
73
  }
74
+ /** A generated image with its CDN URL. */
52
75
  interface Image {
53
76
  url: string;
54
77
  }
@@ -74,24 +97,99 @@ type CompletedEditImageResponse = EditImageResponse & {
74
97
  images: Image[];
75
98
  };
76
99
 
100
+ /**
101
+ * Generates images from text prompts across Seedream model versions.
102
+ * Field requirements vary by model family: 4.5/5-lite require `aspect_ratio`
103
+ * and `output_quality`; V4 uses `output_resolution` and supports `seed`/`output_count`.
104
+ */
77
105
  declare class TextToImage {
78
106
  private readonly http;
79
107
  constructor(http: HttpClient);
108
+ /**
109
+ * Create a text to image task and wait until complete.
110
+ * @param params Text to image parameters.
111
+ * @param options Per-request and polling overrides.
112
+ * @returns The completed text to image response.
113
+ */
80
114
  run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse>;
115
+ /**
116
+ * Create a text to image task; returns immediately with a task id.
117
+ * @param params Text to image parameters.
118
+ * @param options Per-request overrides.
119
+ * @returns The task creation result.
120
+ */
81
121
  create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
122
+ /**
123
+ * Fetch the current status of a text to image task.
124
+ * @param id The task id.
125
+ * @param options Per-request overrides.
126
+ * @returns The current text to image task status.
127
+ */
82
128
  get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
83
129
  }
84
130
 
131
+ /**
132
+ * Modifies source images according to a text prompt.
133
+ * V4 models accept up to 10 source images; 4.5 and 5-lite accept up to 14.
134
+ */
85
135
  declare class EditImage {
86
136
  private readonly http;
87
137
  constructor(http: HttpClient);
138
+ /**
139
+ * Create an edit image task and wait until complete.
140
+ * @param params Edit image parameters.
141
+ * @param options Per-request and polling overrides.
142
+ * @returns The completed edit image response.
143
+ */
88
144
  run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse>;
145
+ /**
146
+ * Create an edit image task; returns immediately with a task id.
147
+ * @param params Edit image parameters.
148
+ * @param options Per-request overrides.
149
+ * @returns The task creation result.
150
+ */
89
151
  create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
152
+ /**
153
+ * Fetch the current status of an edit image task.
154
+ * @param id The task id.
155
+ * @param options Per-request overrides.
156
+ * @returns The current edit image task status.
157
+ */
90
158
  get(id: string, options?: RequestOptions): Promise<EditImageResponse>;
91
159
  }
92
160
 
93
- declare class SeedreamClient {
161
+ /**
162
+ * Seedream image generation and editing API client.
163
+ *
164
+ * Three model families with different field requirements:
165
+ * - **4.5**: requires `aspect_ratio` and `output_quality`
166
+ * - **5-lite**: same required fields as 4.5, faster generation
167
+ * - **V4**: uses `output_resolution` instead; supports `seed` and batch `output_count`
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const client = new SeedreamClient({ apiKey: 'your-api-key' });
172
+ *
173
+ * // Seedream 4.5
174
+ * const result = await client.textToImage.run({
175
+ * model: 'seedream-4.5-text-to-image',
176
+ * prompt: 'A beautiful product render',
177
+ * aspect_ratio: '16:9',
178
+ * output_quality: 'high',
179
+ * });
180
+ *
181
+ * // Seedream V4 with batch output
182
+ * const batch = await client.textToImage.run({
183
+ * model: 'seedream-v4-text-to-image',
184
+ * prompt: 'Minimalist logo design',
185
+ * output_count: 4,
186
+ * });
187
+ * ```
188
+ */
189
+ declare class SeedreamClient extends BaseClient {
190
+ /** Text-to-image generation across Seedream model versions. */
94
191
  readonly textToImage: TextToImage;
192
+ /** Edit source images according to a text prompt. */
95
193
  readonly editImage: EditImage;
96
194
  constructor(options?: ClientOptions);
97
195
  }
package/dist/index.d.ts CHANGED
@@ -1,25 +1,44 @@
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
+ /** Union of all Seedream model identifiers across text-to-image and edit endpoints. */
4
5
  type SeedreamModel = 'seedream-4.5-text-to-image' | 'seedream-4.5-edit' | 'seedream-5-lite-text-to-image' | 'seedream-5-lite-edit' | 'seedream-v4-text-to-image' | 'seedream-v4-edit';
6
+ /** Models accepted by the text-to-image endpoint. */
5
7
  type TextToImageModel = 'seedream-4.5-text-to-image' | 'seedream-5-lite-text-to-image' | 'seedream-v4-text-to-image';
8
+ /** Models accepted by the edit-image endpoint. */
6
9
  type EditImageModel = 'seedream-4.5-edit' | 'seedream-5-lite-edit' | 'seedream-v4-edit';
7
10
  type AspectRatio = '1:1' | '4:3' | '3:4' | '16:9' | '9:16' | '2:3' | '3:2' | '21:9';
11
+ /** Quality preset for 4.5 and 5-lite models. */
8
12
  type OutputQuality = 'basic' | 'high';
13
+ /** Pixel resolution tier for V4 models. */
9
14
  type V4OutputResolution = '1k' | '2k' | '4k';
15
+ /**
16
+ * Shared parameters for 4.5 and 5-lite models.
17
+ * Both `aspect_ratio` and `output_quality` are required for these model families.
18
+ */
10
19
  interface ImageGenerationBaseParams {
11
20
  prompt: string;
12
21
  aspect_ratio: AspectRatio;
13
22
  output_quality: OutputQuality;
23
+ /** Toggle content safety filtering. */
14
24
  enable_safety_checker?: boolean;
15
25
  callback_url?: string;
16
26
  }
27
+ /**
28
+ * Shared parameters for V4 models.
29
+ * Uses `output_resolution` instead of `output_quality`, and supports
30
+ * reproducible generation via `seed` and batch output via `output_count`.
31
+ */
17
32
  interface V4GenerationBaseParams {
18
33
  prompt: string;
19
34
  aspect_ratio?: AspectRatio;
35
+ /** Output resolution tier (default: "1k"). */
20
36
  output_resolution?: V4OutputResolution;
37
+ /** Number of images to generate (default: 1). */
21
38
  output_count?: number;
39
+ /** Fixed seed for reproducible generation. */
22
40
  seed?: number;
41
+ /** Toggle content safety filtering. */
23
42
  enable_safety_checker?: boolean;
24
43
  callback_url?: string;
25
44
  }
@@ -28,6 +47,7 @@ interface Generation45TextParams extends ImageGenerationBaseParams {
28
47
  }
29
48
  interface Generation45EditImageParams extends ImageGenerationBaseParams {
30
49
  model: 'seedream-4.5-edit';
50
+ /** Source image URLs to edit (up to 14 for 4.5 models). */
31
51
  source_image_urls: string[];
32
52
  }
33
53
  interface Generation5LiteTextParams extends ImageGenerationBaseParams {
@@ -35,6 +55,7 @@ interface Generation5LiteTextParams extends ImageGenerationBaseParams {
35
55
  }
36
56
  interface Generation5LiteEditParams extends ImageGenerationBaseParams {
37
57
  model: 'seedream-5-lite-edit';
58
+ /** Source image URLs to edit (up to 14 for 5-lite models). */
38
59
  source_image_urls: string[];
39
60
  }
40
61
  interface GenerationV4TextParams extends V4GenerationBaseParams {
@@ -42,6 +63,7 @@ interface GenerationV4TextParams extends V4GenerationBaseParams {
42
63
  }
43
64
  interface GenerationV4EditParams extends V4GenerationBaseParams {
44
65
  model: 'seedream-v4-edit';
66
+ /** Source image URLs to edit (up to 10 for V4 models). */
45
67
  source_image_urls: string[];
46
68
  }
47
69
  type TextToImageParams = Generation45TextParams | Generation5LiteTextParams | GenerationV4TextParams;
@@ -49,6 +71,7 @@ type EditImageParams = Generation45EditImageParams | Generation5LiteEditParams |
49
71
  interface TaskCreateResponse {
50
72
  id: string;
51
73
  }
74
+ /** A generated image with its CDN URL. */
52
75
  interface Image {
53
76
  url: string;
54
77
  }
@@ -74,24 +97,99 @@ type CompletedEditImageResponse = EditImageResponse & {
74
97
  images: Image[];
75
98
  };
76
99
 
100
+ /**
101
+ * Generates images from text prompts across Seedream model versions.
102
+ * Field requirements vary by model family: 4.5/5-lite require `aspect_ratio`
103
+ * and `output_quality`; V4 uses `output_resolution` and supports `seed`/`output_count`.
104
+ */
77
105
  declare class TextToImage {
78
106
  private readonly http;
79
107
  constructor(http: HttpClient);
108
+ /**
109
+ * Create a text to image task and wait until complete.
110
+ * @param params Text to image parameters.
111
+ * @param options Per-request and polling overrides.
112
+ * @returns The completed text to image response.
113
+ */
80
114
  run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse>;
115
+ /**
116
+ * Create a text to image task; returns immediately with a task id.
117
+ * @param params Text to image parameters.
118
+ * @param options Per-request overrides.
119
+ * @returns The task creation result.
120
+ */
81
121
  create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
122
+ /**
123
+ * Fetch the current status of a text to image task.
124
+ * @param id The task id.
125
+ * @param options Per-request overrides.
126
+ * @returns The current text to image task status.
127
+ */
82
128
  get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
83
129
  }
84
130
 
131
+ /**
132
+ * Modifies source images according to a text prompt.
133
+ * V4 models accept up to 10 source images; 4.5 and 5-lite accept up to 14.
134
+ */
85
135
  declare class EditImage {
86
136
  private readonly http;
87
137
  constructor(http: HttpClient);
138
+ /**
139
+ * Create an edit image task and wait until complete.
140
+ * @param params Edit image parameters.
141
+ * @param options Per-request and polling overrides.
142
+ * @returns The completed edit image response.
143
+ */
88
144
  run(params: EditImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedEditImageResponse>;
145
+ /**
146
+ * Create an edit image task; returns immediately with a task id.
147
+ * @param params Edit image parameters.
148
+ * @param options Per-request overrides.
149
+ * @returns The task creation result.
150
+ */
89
151
  create(params: EditImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
152
+ /**
153
+ * Fetch the current status of an edit image task.
154
+ * @param id The task id.
155
+ * @param options Per-request overrides.
156
+ * @returns The current edit image task status.
157
+ */
90
158
  get(id: string, options?: RequestOptions): Promise<EditImageResponse>;
91
159
  }
92
160
 
93
- declare class SeedreamClient {
161
+ /**
162
+ * Seedream image generation and editing API client.
163
+ *
164
+ * Three model families with different field requirements:
165
+ * - **4.5**: requires `aspect_ratio` and `output_quality`
166
+ * - **5-lite**: same required fields as 4.5, faster generation
167
+ * - **V4**: uses `output_resolution` instead; supports `seed` and batch `output_count`
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const client = new SeedreamClient({ apiKey: 'your-api-key' });
172
+ *
173
+ * // Seedream 4.5
174
+ * const result = await client.textToImage.run({
175
+ * model: 'seedream-4.5-text-to-image',
176
+ * prompt: 'A beautiful product render',
177
+ * aspect_ratio: '16:9',
178
+ * output_quality: 'high',
179
+ * });
180
+ *
181
+ * // Seedream V4 with batch output
182
+ * const batch = await client.textToImage.run({
183
+ * model: 'seedream-v4-text-to-image',
184
+ * prompt: 'Minimalist logo design',
185
+ * output_count: 4,
186
+ * });
187
+ * ```
188
+ */
189
+ declare class SeedreamClient extends BaseClient {
190
+ /** Text-to-image generation across Seedream model versions. */
94
191
  readonly textToImage: TextToImage;
192
+ /** Edit source images according to a text prompt. */
95
193
  readonly editImage: EditImage;
96
194
  constructor(options?: ClientOptions);
97
195
  }
package/dist/index.js CHANGED
@@ -47,6 +47,12 @@ var TextToImage = class {
47
47
  this.http = http;
48
48
  }
49
49
  http;
50
+ /**
51
+ * Create a text to image task and wait until complete.
52
+ * @param params Text to image parameters.
53
+ * @param options Per-request and polling overrides.
54
+ * @returns The completed text to image response.
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 a text to image task; returns immediately with a task id.
66
+ * @param params Text to image parameters.
67
+ * @param options Per-request overrides.
68
+ * @returns The task creation result.
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 a text to image task.
78
+ * @param id The task id.
79
+ * @param options Per-request overrides.
80
+ * @returns The current text to image 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
+ * Create an edit image task and wait until complete.
100
+ * @param params Edit image parameters.
101
+ * @param options Per-request and polling overrides.
102
+ * @returns The completed edit image response.
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 edit image task; returns immediately with a task id.
114
+ * @param params Edit image parameters.
115
+ * @param options Per-request overrides.
116
+ * @returns The task creation result.
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 edit image task.
126
+ * @param id The task id.
127
+ * @param options Per-request overrides.
128
+ * @returns The current edit image task status.
129
+ */
94
130
  async get(id, options) {
95
131
  return this.http.request("GET", `${ENDPOINT2}/${id}`, {
96
132
  ...options
@@ -99,13 +135,15 @@ var EditImage = class {
99
135
  };
100
136
 
101
137
  // src/client.ts
102
- var SeedreamClient = class {
138
+ var SeedreamClient = class extends import_core3.BaseClient {
139
+ /** Text-to-image generation across Seedream model versions. */
103
140
  textToImage;
141
+ /** Edit source images according to a text prompt. */
104
142
  editImage;
105
143
  constructor(options = {}) {
106
- const http = (0, import_core3.createHttpClient)(options);
107
- this.textToImage = new TextToImage(http);
108
- this.editImage = new EditImage(http);
144
+ super(options);
145
+ this.textToImage = new TextToImage(this.http);
146
+ this.editImage = new EditImage(this.http);
109
147
  }
110
148
  };
111
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 { 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 { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { EditImage } from './resources/edit-image';\n\nexport class SeedreamClient {\n public readonly textToImage: TextToImage;\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/seedream/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 {\n CompletedEditImageResponse,\n EditImageParams,\n EditImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/seedream/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,I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AAY,UAAyB,CAAC,GAAG;AACvC,UAAM,WAAO,+BAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,YAAY,IAAI,UAAU,IAAI;AAAA,EACrC;AACF;;;ADVA,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 { 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';\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\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/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 require `aspect_ratio`\n * and `output_quality`; V4 uses `output_resolution` and supports `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 return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\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 * V4 models 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 return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\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"],"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;AAOV,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,mCAAu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I,IAAY,SAAsD;AAC1E,WAAO,KAAK,KAAK,QAA2B,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI;AAAA,MACtE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AF1BO,IAAM,iBAAN,cAA6B,wBAAW;AAAA;AAAA,EAE7B;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;;;ADxCA,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
+ * Create a text to image task and wait until complete.
15
+ * @param params Text to image parameters.
16
+ * @param options Per-request and polling overrides.
17
+ * @returns The completed text to image response.
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 a text to image task; returns immediately with a task id.
29
+ * @param params Text to image parameters.
30
+ * @param options Per-request overrides.
31
+ * @returns The task creation result.
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 a text to image task.
41
+ * @param id The task id.
42
+ * @param options Per-request overrides.
43
+ * @returns The current text to image 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
+ * Create an edit image task and wait until complete.
63
+ * @param params Edit image parameters.
64
+ * @param options Per-request and polling overrides.
65
+ * @returns The completed edit image response.
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 edit image task; returns immediately with a task id.
77
+ * @param params Edit image parameters.
78
+ * @param options Per-request overrides.
79
+ * @returns The task creation result.
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 edit image task.
89
+ * @param id The task id.
90
+ * @param options Per-request overrides.
91
+ * @returns The current edit image task status.
92
+ */
57
93
  async get(id, options) {
58
94
  return this.http.request("GET", `${ENDPOINT2}/${id}`, {
59
95
  ...options
@@ -62,13 +98,15 @@ var EditImage = class {
62
98
  };
63
99
 
64
100
  // src/client.ts
65
- var SeedreamClient = class {
101
+ var SeedreamClient = class extends BaseClient {
102
+ /** Text-to-image generation across Seedream model versions. */
66
103
  textToImage;
104
+ /** Edit source images according to a text prompt. */
67
105
  editImage;
68
106
  constructor(options = {}) {
69
- const http = createHttpClient(options);
70
- this.textToImage = new TextToImage(http);
71
- this.editImage = new EditImage(http);
107
+ super(options);
108
+ this.textToImage = new TextToImage(this.http);
109
+ this.editImage = new EditImage(this.http);
72
110
  }
73
111
  };
74
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\nexport class SeedreamClient {\n public readonly textToImage: TextToImage;\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/seedream/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 {\n CompletedEditImageResponse,\n EditImageParams,\n EditImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/seedream/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 { 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,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;AAQlC,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;;;AFhCO,IAAM,iBAAN,MAAqB;AAAA,EACV;AAAA,EACA;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;;;AGVA;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 * 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\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/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 require `aspect_ratio`\n * and `output_quality`; V4 uses `output_resolution` and supports `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 return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\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 * V4 models 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 return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\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","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;AAOV,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,IAA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A;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/seedream",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "RunAPI Seedream 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",
@@ -80,6 +80,8 @@ const url = result.images[0].url;
80
80
 
81
81
  ## Agent rules
82
82
 
83
+ - 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
84
+ - 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.
83
85
  - Keep API keys in `RUNAPI_API_KEY` or RunAPI CLI config; never commit secrets.
84
86
  - Prefer `create`, `get`, and `run` JSON passthrough patterns instead of inventing flags for every model parameter.
85
87
  - For seedream 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 Seedream 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 Seedream 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/seedream`
39
+ - Ruby: `runapi-seedream`
40
+ - Go: `github.com/runapi-ai/seedream-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
 
@@ -81,13 +90,9 @@ Common request shapes:
81
90
  }
82
91
  ```
83
92
 
84
- ## SDK integration path
85
-
86
- When integrating Seedream into an app, backend, worker, or library — not for one-off tasks — use a RunAPI SDK package:
93
+ ## Generated file storage
87
94
 
88
- - JavaScript / TypeScript: `@runapi.ai/seedream`
89
- - Ruby: `runapi-seedream`
90
- - Go: `github.com/runapi-ai/seedream-sdk/go`
95
+ 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.
91
96
 
92
97
  ## References
93
98