@runapi.ai/flux-2 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Flux API JavaScript SDK for RunAPI
1
+ # Flux 2 API JavaScript SDK for RunAPI
2
2
 
3
- The flux api JavaScript SDK is the language-specific package for Flux 2 on RunAPI. Use this flux api package for text-to-image, remix-image, and creative production flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
3
+ The Flux 2 JavaScript SDK is the language-specific package for Flux 2 on RunAPI. Use this package for image generation, image editing, and creative production workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
4
4
 
5
- This flux api README is the JavaScript package guide inside the public `flux-2-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/flux-2; for API reference, use https://runapi.ai/docs#flux-2; for SDK docs, use https://runapi.ai/docs#sdk-flux-2.
5
+ This README is the JavaScript package guide inside the public `flux-2-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/flux-2; for API reference, use https://runapi.ai/docs#flux-2; for SDK docs, use https://runapi.ai/docs#sdk-flux-2.
6
6
 
7
7
  ## Install
8
8
 
@@ -27,16 +27,18 @@ const status = await client.textToImage.get(task.id);
27
27
  const remix = await client.remixImage.create({
28
28
  model: 'flux-2-pro-remix-image',
29
29
  prompt: 'Turn this product shot into a warm editorial photo',
30
- source_image_urls: ['https://example.com/source.jpg'],
30
+ source_image_urls: ['https://cdn.runapi.ai/public/samples/image.jpg'],
31
31
  aspect_ratio: 'auto',
32
32
  });
33
33
  ```
34
34
 
35
35
  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.
36
36
 
37
+ 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.
38
+
37
39
  ## Language notes
38
40
 
39
- Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The available resources include `textToImage` and `remixImage`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
41
+ Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The available resources are `textToImage` and `remixImage`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
40
42
 
41
43
  ## Links
42
44
 
package/dist/index.d.mts CHANGED
@@ -1,34 +1,63 @@
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
+ /**
5
+ * All Flux 2 model slugs. Each operation has pro (higher fidelity) and
6
+ * flex (faster, lower cost) tiers.
7
+ */
4
8
  type Flux2Model = 'flux-2-pro-text-to-image' | 'flux-2-pro-remix-image' | 'flux-2-flex-text-to-image' | 'flux-2-flex-remix-image';
9
+ /** Output aspect ratio for text-to-image generation. */
5
10
  type AspectRatio = '1:1' | '4:3' | '3:4' | '16:9' | '9:16' | '3:2' | '2:3';
11
+ /** Aspect ratios for remix, including 'auto' to preserve the source image ratio. */
6
12
  type RemixAspectRatio = AspectRatio | 'auto';
13
+ /** Output resolution tier for Flux 2 generation (max 2k). */
7
14
  type OutputResolution = '1k' | '2k';
15
+ /** Parameters for Flux 2 text-to-image generation (pro or flex tier). */
8
16
  interface GenerationT2IParams {
9
17
  model: 'flux-2-pro-text-to-image' | 'flux-2-flex-text-to-image';
18
+ /** Text description of desired image, 3-5000 characters. */
10
19
  prompt: string;
20
+ /** URL for completion callback notifications. */
11
21
  callback_url?: string;
22
+ /** Default: 1k. */
12
23
  output_resolution?: OutputResolution;
24
+ /** Content safety check toggle. */
13
25
  enable_safety_checker?: boolean;
26
+ /** Default: 1:1. */
14
27
  aspect_ratio?: AspectRatio;
15
28
  }
29
+ /**
30
+ * Parameters for Flux 2 image remix (pro or flex tier).
31
+ * Transforms source images guided by a text prompt.
32
+ */
16
33
  interface RemixImageParams {
17
34
  model: 'flux-2-pro-remix-image' | 'flux-2-flex-remix-image';
35
+ /** Text description guiding the transformation, 3-5000 characters. */
18
36
  prompt: string;
37
+ /** Source image URLs to remix (1-8). */
19
38
  source_image_urls: string[];
39
+ /** URL for completion callback notifications. */
20
40
  callback_url?: string;
41
+ /** Default: 1k. */
21
42
  output_resolution?: OutputResolution;
43
+ /** Content safety check toggle. */
22
44
  enable_safety_checker?: boolean;
45
+ /** 'auto' preserves the source image aspect ratio. */
23
46
  aspect_ratio?: RemixAspectRatio;
24
47
  }
25
48
  type TextToImageParams = GenerationT2IParams;
49
+ /** Acknowledged task with its server-assigned ID. */
26
50
  interface TaskCreateResponse {
27
51
  id: string;
28
52
  }
53
+ /** A single generated image with its CDN URL. */
29
54
  interface Image {
30
55
  url: string;
31
56
  }
57
+ /**
58
+ * Generation result for a Flux 2 task.
59
+ * `images` is populated once `status` reaches `'completed'`.
60
+ */
32
61
  interface TextToImageResponse {
33
62
  id: string;
34
63
  status: AsyncTaskStatus;
@@ -45,27 +74,69 @@ type CompletedTextToImageResponse = TextToImageResponse & {
45
74
  status: 'completed';
46
75
  images: Image[];
47
76
  };
77
+ /** Remix response -- same shape as generation. */
48
78
  type RemixImageResponse = TextToImageResponse;
49
79
  type CompletedRemixImageResponse = CompletedTextToImageResponse;
50
80
 
81
+ /** Flux 2 text-to-image generation resource. */
51
82
  declare class TextToImage {
52
83
  private readonly http;
53
84
  constructor(http: HttpClient);
85
+ /**
86
+ * Generate an image and wait until complete.
87
+ * @param params Text-to-image parameters.
88
+ * @param options Per-request and polling overrides.
89
+ * @returns The completed text-to-image result.
90
+ */
54
91
  run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse>;
92
+ /**
93
+ * Create a text-to-image task; returns immediately with a task id.
94
+ * @param params Text-to-image parameters.
95
+ * @param options Per-request overrides.
96
+ * @returns The task creation result with id.
97
+ */
55
98
  create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
99
+ /**
100
+ * Fetch the current status of a text-to-image task.
101
+ * @param id The task id.
102
+ * @param options Per-request overrides.
103
+ * @returns The current text-to-image status.
104
+ */
56
105
  get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
57
106
  }
58
107
 
108
+ /** Flux 2 image remix: transform source images with text-guided prompts. */
59
109
  declare class RemixImage {
60
110
  private readonly http;
61
111
  constructor(http: HttpClient);
112
+ /**
113
+ * Remix an image and wait until complete.
114
+ * @param params Image remix parameters.
115
+ * @param options Per-request and polling overrides.
116
+ * @returns The completed remix result with images.
117
+ */
62
118
  run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedRemixImageResponse>;
119
+ /**
120
+ * Create an image remix task; returns immediately with a task id.
121
+ * @param params Image remix parameters.
122
+ * @param options Per-request overrides.
123
+ * @returns The task creation result with id.
124
+ */
63
125
  create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
126
+ /**
127
+ * Fetch the current status of an image remix task.
128
+ * @param id The task id.
129
+ * @param options Per-request overrides.
130
+ * @returns The current remix status.
131
+ */
64
132
  get(id: string, options?: RequestOptions): Promise<RemixImageResponse>;
65
133
  }
66
134
 
67
135
  /**
68
- * Flux 2 text-to-image API client.
136
+ * Flux 2 text-to-image and remix API client.
137
+ *
138
+ * Pro and flex tiers for both text-to-image generation and
139
+ * text-guided image remixing from source images.
69
140
  *
70
141
  * @example
71
142
  * ```typescript
@@ -80,10 +151,10 @@ declare class RemixImage {
80
151
  * });
81
152
  * ```
82
153
  */
83
- declare class Flux2Client {
84
- /** Text-to-image operations. */
154
+ declare class Flux2Client extends BaseClient {
155
+ /** Text-to-image generation. */
85
156
  readonly textToImage: TextToImage;
86
- /** Remix-image operations. */
157
+ /** Transform source images with text-guided prompts. */
87
158
  readonly remixImage: RemixImage;
88
159
  constructor(options?: ClientOptions);
89
160
  }
package/dist/index.d.ts CHANGED
@@ -1,34 +1,63 @@
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
+ /**
5
+ * All Flux 2 model slugs. Each operation has pro (higher fidelity) and
6
+ * flex (faster, lower cost) tiers.
7
+ */
4
8
  type Flux2Model = 'flux-2-pro-text-to-image' | 'flux-2-pro-remix-image' | 'flux-2-flex-text-to-image' | 'flux-2-flex-remix-image';
9
+ /** Output aspect ratio for text-to-image generation. */
5
10
  type AspectRatio = '1:1' | '4:3' | '3:4' | '16:9' | '9:16' | '3:2' | '2:3';
11
+ /** Aspect ratios for remix, including 'auto' to preserve the source image ratio. */
6
12
  type RemixAspectRatio = AspectRatio | 'auto';
13
+ /** Output resolution tier for Flux 2 generation (max 2k). */
7
14
  type OutputResolution = '1k' | '2k';
15
+ /** Parameters for Flux 2 text-to-image generation (pro or flex tier). */
8
16
  interface GenerationT2IParams {
9
17
  model: 'flux-2-pro-text-to-image' | 'flux-2-flex-text-to-image';
18
+ /** Text description of desired image, 3-5000 characters. */
10
19
  prompt: string;
20
+ /** URL for completion callback notifications. */
11
21
  callback_url?: string;
22
+ /** Default: 1k. */
12
23
  output_resolution?: OutputResolution;
24
+ /** Content safety check toggle. */
13
25
  enable_safety_checker?: boolean;
26
+ /** Default: 1:1. */
14
27
  aspect_ratio?: AspectRatio;
15
28
  }
29
+ /**
30
+ * Parameters for Flux 2 image remix (pro or flex tier).
31
+ * Transforms source images guided by a text prompt.
32
+ */
16
33
  interface RemixImageParams {
17
34
  model: 'flux-2-pro-remix-image' | 'flux-2-flex-remix-image';
35
+ /** Text description guiding the transformation, 3-5000 characters. */
18
36
  prompt: string;
37
+ /** Source image URLs to remix (1-8). */
19
38
  source_image_urls: string[];
39
+ /** URL for completion callback notifications. */
20
40
  callback_url?: string;
41
+ /** Default: 1k. */
21
42
  output_resolution?: OutputResolution;
43
+ /** Content safety check toggle. */
22
44
  enable_safety_checker?: boolean;
45
+ /** 'auto' preserves the source image aspect ratio. */
23
46
  aspect_ratio?: RemixAspectRatio;
24
47
  }
25
48
  type TextToImageParams = GenerationT2IParams;
49
+ /** Acknowledged task with its server-assigned ID. */
26
50
  interface TaskCreateResponse {
27
51
  id: string;
28
52
  }
53
+ /** A single generated image with its CDN URL. */
29
54
  interface Image {
30
55
  url: string;
31
56
  }
57
+ /**
58
+ * Generation result for a Flux 2 task.
59
+ * `images` is populated once `status` reaches `'completed'`.
60
+ */
32
61
  interface TextToImageResponse {
33
62
  id: string;
34
63
  status: AsyncTaskStatus;
@@ -45,27 +74,69 @@ type CompletedTextToImageResponse = TextToImageResponse & {
45
74
  status: 'completed';
46
75
  images: Image[];
47
76
  };
77
+ /** Remix response -- same shape as generation. */
48
78
  type RemixImageResponse = TextToImageResponse;
49
79
  type CompletedRemixImageResponse = CompletedTextToImageResponse;
50
80
 
81
+ /** Flux 2 text-to-image generation resource. */
51
82
  declare class TextToImage {
52
83
  private readonly http;
53
84
  constructor(http: HttpClient);
85
+ /**
86
+ * Generate an image and wait until complete.
87
+ * @param params Text-to-image parameters.
88
+ * @param options Per-request and polling overrides.
89
+ * @returns The completed text-to-image result.
90
+ */
54
91
  run(params: TextToImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedTextToImageResponse>;
92
+ /**
93
+ * Create a text-to-image task; returns immediately with a task id.
94
+ * @param params Text-to-image parameters.
95
+ * @param options Per-request overrides.
96
+ * @returns The task creation result with id.
97
+ */
55
98
  create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
99
+ /**
100
+ * Fetch the current status of a text-to-image task.
101
+ * @param id The task id.
102
+ * @param options Per-request overrides.
103
+ * @returns The current text-to-image status.
104
+ */
56
105
  get(id: string, options?: RequestOptions): Promise<TextToImageResponse>;
57
106
  }
58
107
 
108
+ /** Flux 2 image remix: transform source images with text-guided prompts. */
59
109
  declare class RemixImage {
60
110
  private readonly http;
61
111
  constructor(http: HttpClient);
112
+ /**
113
+ * Remix an image and wait until complete.
114
+ * @param params Image remix parameters.
115
+ * @param options Per-request and polling overrides.
116
+ * @returns The completed remix result with images.
117
+ */
62
118
  run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedRemixImageResponse>;
119
+ /**
120
+ * Create an image remix task; returns immediately with a task id.
121
+ * @param params Image remix parameters.
122
+ * @param options Per-request overrides.
123
+ * @returns The task creation result with id.
124
+ */
63
125
  create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse>;
126
+ /**
127
+ * Fetch the current status of an image remix task.
128
+ * @param id The task id.
129
+ * @param options Per-request overrides.
130
+ * @returns The current remix status.
131
+ */
64
132
  get(id: string, options?: RequestOptions): Promise<RemixImageResponse>;
65
133
  }
66
134
 
67
135
  /**
68
- * Flux 2 text-to-image API client.
136
+ * Flux 2 text-to-image and remix API client.
137
+ *
138
+ * Pro and flex tiers for both text-to-image generation and
139
+ * text-guided image remixing from source images.
69
140
  *
70
141
  * @example
71
142
  * ```typescript
@@ -80,10 +151,10 @@ declare class RemixImage {
80
151
  * });
81
152
  * ```
82
153
  */
83
- declare class Flux2Client {
84
- /** Text-to-image operations. */
154
+ declare class Flux2Client extends BaseClient {
155
+ /** Text-to-image generation. */
85
156
  readonly textToImage: TextToImage;
86
- /** Remix-image operations. */
157
+ /** Transform source images with text-guided prompts. */
87
158
  readonly remixImage: RemixImage;
88
159
  constructor(options?: ClientOptions);
89
160
  }
package/dist/index.js CHANGED
@@ -41,12 +41,136 @@ var import_core3 = require("@runapi.ai/core");
41
41
  // src/resources/text-to-image.ts
42
42
  var import_core = require("@runapi.ai/core");
43
43
  var import_internal = require("@runapi.ai/core/internal");
44
+
45
+ // src/contract_gen.ts
46
+ var contract = {
47
+ "remix-image": {
48
+ "models": [
49
+ "flux-2-flex-remix-image",
50
+ "flux-2-pro-remix-image"
51
+ ],
52
+ "fields_by_model": {
53
+ "flux-2-flex-remix-image": {
54
+ "aspect_ratio": {
55
+ "enum": [
56
+ "1:1",
57
+ "4:3",
58
+ "3:4",
59
+ "16:9",
60
+ "9:16",
61
+ "3:2",
62
+ "2:3",
63
+ "auto"
64
+ ]
65
+ },
66
+ "output_resolution": {
67
+ "enum": [
68
+ "1k",
69
+ "2k"
70
+ ]
71
+ },
72
+ "prompt": {
73
+ "required": true
74
+ },
75
+ "source_image_urls": {
76
+ "required": true
77
+ }
78
+ },
79
+ "flux-2-pro-remix-image": {
80
+ "aspect_ratio": {
81
+ "enum": [
82
+ "1:1",
83
+ "4:3",
84
+ "3:4",
85
+ "16:9",
86
+ "9:16",
87
+ "3:2",
88
+ "2:3",
89
+ "auto"
90
+ ]
91
+ },
92
+ "output_resolution": {
93
+ "enum": [
94
+ "1k",
95
+ "2k"
96
+ ]
97
+ },
98
+ "prompt": {
99
+ "required": true
100
+ },
101
+ "source_image_urls": {
102
+ "required": true
103
+ }
104
+ }
105
+ }
106
+ },
107
+ "text-to-image": {
108
+ "models": [
109
+ "flux-2-flex-text-to-image",
110
+ "flux-2-pro-text-to-image"
111
+ ],
112
+ "fields_by_model": {
113
+ "flux-2-flex-text-to-image": {
114
+ "aspect_ratio": {
115
+ "enum": [
116
+ "1:1",
117
+ "4:3",
118
+ "3:4",
119
+ "16:9",
120
+ "9:16",
121
+ "3:2",
122
+ "2:3"
123
+ ]
124
+ },
125
+ "output_resolution": {
126
+ "enum": [
127
+ "1k",
128
+ "2k"
129
+ ]
130
+ },
131
+ "prompt": {
132
+ "required": true
133
+ }
134
+ },
135
+ "flux-2-pro-text-to-image": {
136
+ "aspect_ratio": {
137
+ "enum": [
138
+ "1:1",
139
+ "4:3",
140
+ "3:4",
141
+ "16:9",
142
+ "9:16",
143
+ "3:2",
144
+ "2:3"
145
+ ]
146
+ },
147
+ "output_resolution": {
148
+ "enum": [
149
+ "1k",
150
+ "2k"
151
+ ]
152
+ },
153
+ "prompt": {
154
+ "required": true
155
+ }
156
+ }
157
+ }
158
+ }
159
+ };
160
+
161
+ // src/resources/text-to-image.ts
44
162
  var ENDPOINT = "/api/v1/flux_2/text_to_image";
45
163
  var TextToImage = class {
46
164
  constructor(http) {
47
165
  this.http = http;
48
166
  }
49
167
  http;
168
+ /**
169
+ * Generate an image and wait until complete.
170
+ * @param params Text-to-image parameters.
171
+ * @param options Per-request and polling overrides.
172
+ * @returns The completed text-to-image result.
173
+ */
50
174
  async run(params, options) {
51
175
  const { id } = await this.create(params, options);
52
176
  const response = await (0, import_internal.pollUntilComplete)(() => this.get(id, options), {
@@ -55,12 +179,26 @@ var TextToImage = class {
55
179
  });
56
180
  return response;
57
181
  }
182
+ /**
183
+ * Create a text-to-image task; returns immediately with a task id.
184
+ * @param params Text-to-image parameters.
185
+ * @param options Per-request overrides.
186
+ * @returns The task creation result with id.
187
+ */
58
188
  async create(params, options) {
189
+ const body = (0, import_core.compactParams)(params);
190
+ (0, import_core.validateParams)(contract["text-to-image"], body);
59
191
  return this.http.request("POST", ENDPOINT, {
60
- body: (0, import_core.compactParams)(params),
192
+ body,
61
193
  ...options
62
194
  });
63
195
  }
196
+ /**
197
+ * Fetch the current status of a text-to-image task.
198
+ * @param id The task id.
199
+ * @param options Per-request overrides.
200
+ * @returns The current text-to-image status.
201
+ */
64
202
  async get(id, options) {
65
203
  return this.http.request("GET", `${ENDPOINT}/${id}`, {
66
204
  ...options
@@ -77,6 +215,12 @@ var RemixImage = class {
77
215
  this.http = http;
78
216
  }
79
217
  http;
218
+ /**
219
+ * Remix an image and wait until complete.
220
+ * @param params Image remix parameters.
221
+ * @param options Per-request and polling overrides.
222
+ * @returns The completed remix result with images.
223
+ */
80
224
  async run(params, options) {
81
225
  const { id } = await this.create(params, options);
82
226
  const response = await (0, import_internal2.pollUntilComplete)(() => this.get(id, options), {
@@ -85,12 +229,26 @@ var RemixImage = class {
85
229
  });
86
230
  return response;
87
231
  }
232
+ /**
233
+ * Create an image remix task; returns immediately with a task id.
234
+ * @param params Image remix parameters.
235
+ * @param options Per-request overrides.
236
+ * @returns The task creation result with id.
237
+ */
88
238
  async create(params, options) {
239
+ const body = (0, import_core2.compactParams)(params);
240
+ (0, import_core2.validateParams)(contract["remix-image"], body);
89
241
  return this.http.request("POST", ENDPOINT2, {
90
- body: (0, import_core2.compactParams)(params),
242
+ body,
91
243
  ...options
92
244
  });
93
245
  }
246
+ /**
247
+ * Fetch the current status of an image remix task.
248
+ * @param id The task id.
249
+ * @param options Per-request overrides.
250
+ * @returns The current remix status.
251
+ */
94
252
  async get(id, options) {
95
253
  return this.http.request("GET", `${ENDPOINT2}/${id}`, {
96
254
  ...options
@@ -99,15 +257,15 @@ var RemixImage = class {
99
257
  };
100
258
 
101
259
  // src/client.ts
102
- var Flux2Client = class {
103
- /** Text-to-image operations. */
260
+ var Flux2Client = class extends import_core3.BaseClient {
261
+ /** Text-to-image generation. */
104
262
  textToImage;
105
- /** Remix-image operations. */
263
+ /** Transform source images with text-guided prompts. */
106
264
  remixImage;
107
265
  constructor(options = {}) {
108
- const http = (0, import_core3.createHttpClient)(options);
109
- this.textToImage = new TextToImage(http);
110
- this.remixImage = new RemixImage(http);
266
+ super(options);
267
+ this.textToImage = new TextToImage(this.http);
268
+ this.remixImage = new RemixImage(this.http);
111
269
  }
112
270
  };
113
271
 
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/remix-image.ts"],"sourcesContent":["export { Flux2Client } from './client';\nexport * from './types';\n\n// Re-export core errors for convenience\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n","import { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { RemixImage } from './resources/remix-image';\n\n/**\n * Flux 2 text-to-image API client.\n *\n * @example\n * ```typescript\n * const client = new Flux2Client({\n * apiKey: 'your-api-key',\n * baseUrl: 'https://runapi.ai',\n * });\n *\n * const result = await client.textToImage.run({\n * model: 'flux-2-pro-text-to-image',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class Flux2Client {\n /** Text-to-image operations. */\n public readonly textToImage: TextToImage;\n /** Remix-image operations. */\n public readonly remixImage: RemixImage;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToImage = new TextToImage(http);\n this.remixImage = new RemixImage(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/flux_2/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 CompletedRemixImageResponse,\n RemixImageParams,\n RemixImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/flux_2/remix_image';\n\nexport class RemixImage {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedRemixImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<RemixImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedRemixImageResponse;\n }\n\n async create(params: RemixImageParams, 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<RemixImageResponse> {\n return this.http.request<RemixImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAqD;;;ACCrD,kBAA8B;AAC9B,sBAAkC;AAQlC,IAAM,WAAW;AAEV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,UAAM,mCAAuC,MAAM,KAAK,IAAI,IAAI,OAA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hB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,WAAO,+BAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,aAAa,IAAI,WAAW,IAAI;AAAA,EACvC;AACF;;;AD3BA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","import_core"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.ts","../src/resources/remix-image.ts"],"sourcesContent":["export { Flux2Client } from './client';\nexport * from './types';\n\n// Re-export core errors for convenience\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n","import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { RemixImage } from './resources/remix-image';\n\n/**\n * Flux 2 text-to-image and remix API client.\n *\n * Pro and flex tiers for both text-to-image generation and\n * text-guided image remixing from source images.\n *\n * @example\n * ```typescript\n * const client = new Flux2Client({\n * apiKey: 'your-api-key',\n * baseUrl: 'https://runapi.ai',\n * });\n *\n * const result = await client.textToImage.run({\n * model: 'flux-2-pro-text-to-image',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class Flux2Client extends BaseClient {\n /** Text-to-image generation. */\n public readonly textToImage: TextToImage;\n /** Transform source images with text-guided prompts. */\n public readonly remixImage: RemixImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.remixImage = new RemixImage(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/flux_2/text_to_image';\n\n/** Flux 2 text-to-image generation resource. */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an image 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 result.\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 with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['text-to-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text-to-image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text-to-image 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 \"remix-image\": {\n \"models\": [\n \"flux-2-flex-remix-image\",\n \"flux-2-pro-remix-image\"\n ],\n \"fields_by_model\": {\n \"flux-2-flex-remix-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"3:2\",\n \"2:3\",\n \"auto\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\"\n ]\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_image_urls\": {\n \"required\": true\n }\n },\n \"flux-2-pro-remix-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"3:2\",\n \"2:3\",\n \"auto\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\"\n ]\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_image_urls\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-image\": {\n \"models\": [\n \"flux-2-flex-text-to-image\",\n \"flux-2-pro-text-to-image\"\n ],\n \"fields_by_model\": {\n \"flux-2-flex-text-to-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"3:2\",\n \"2:3\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\"\n ]\n },\n \"prompt\": {\n \"required\": true\n }\n },\n \"flux-2-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 \"3:2\",\n \"2:3\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\"\n ]\n },\n \"prompt\": {\n \"required\": true\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 CompletedRemixImageResponse,\n RemixImageParams,\n RemixImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/flux_2/remix_image';\n\n/** Flux 2 image remix: transform source images with text-guided prompts. */\nexport class RemixImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Remix an image and wait until complete.\n * @param params Image remix parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed remix result with images.\n */\n async run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedRemixImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<RemixImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedRemixImageResponse;\n }\n\n /**\n * Create an image remix task; returns immediately with a task id.\n * @param params Image remix parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['remix-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image remix task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current remix status.\n */\n async get(id: string, options?: RequestOptions): Promise<RemixImageResponse> {\n return this.http.request<RemixImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAA+C;;;ACC/C,kBAA8C;AAC9C,sBAAkC;;;ACF3B,IAAM,WAAW;AAAA,EACtB,eAAe;AAAA,IACb,UAAU;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,2BAA2B;AAAA,QACzB,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAAqB;AAAA,UACnB,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,QACA,qBAAqB;AAAA,UACnB,YAAY;AAA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D;AAC5F,UAAM,WAAO,4BAAc,MAAM;AACjC,qCAAe,SAAS,aAAa,GAAmB,IAA+B;AACvF,WAAO,KAAK,KAAK,QAA4B,QAAQA,WAAU;AAAA,MAC7D;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAuD;AAC3E,WAAO,KAAK,KAAK,QAA4B,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI;AAAA,MACvE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AHnCO,IAAM,cAAN,cAA0B,wBAAW;AAAA;AAAA,EAE1B;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAC5C,SAAK,aAAa,IAAI,WAAW,KAAK,IAAI;AAAA,EAC5C;AACF;;;AD9BA,IAAAC,eAYO;","names":["import_core","import_core","import_internal","ENDPOINT","import_core"]}
package/dist/index.mjs CHANGED
@@ -1,15 +1,139 @@
1
1
  // src/client.ts
2
- import { createHttpClient } from "@runapi.ai/core";
2
+ import { BaseClient } from "@runapi.ai/core";
3
3
 
4
4
  // src/resources/text-to-image.ts
5
- import { compactParams } from "@runapi.ai/core";
5
+ import { compactParams, validateParams } from "@runapi.ai/core";
6
6
  import { pollUntilComplete } from "@runapi.ai/core/internal";
7
+
8
+ // src/contract_gen.ts
9
+ var contract = {
10
+ "remix-image": {
11
+ "models": [
12
+ "flux-2-flex-remix-image",
13
+ "flux-2-pro-remix-image"
14
+ ],
15
+ "fields_by_model": {
16
+ "flux-2-flex-remix-image": {
17
+ "aspect_ratio": {
18
+ "enum": [
19
+ "1:1",
20
+ "4:3",
21
+ "3:4",
22
+ "16:9",
23
+ "9:16",
24
+ "3:2",
25
+ "2:3",
26
+ "auto"
27
+ ]
28
+ },
29
+ "output_resolution": {
30
+ "enum": [
31
+ "1k",
32
+ "2k"
33
+ ]
34
+ },
35
+ "prompt": {
36
+ "required": true
37
+ },
38
+ "source_image_urls": {
39
+ "required": true
40
+ }
41
+ },
42
+ "flux-2-pro-remix-image": {
43
+ "aspect_ratio": {
44
+ "enum": [
45
+ "1:1",
46
+ "4:3",
47
+ "3:4",
48
+ "16:9",
49
+ "9:16",
50
+ "3:2",
51
+ "2:3",
52
+ "auto"
53
+ ]
54
+ },
55
+ "output_resolution": {
56
+ "enum": [
57
+ "1k",
58
+ "2k"
59
+ ]
60
+ },
61
+ "prompt": {
62
+ "required": true
63
+ },
64
+ "source_image_urls": {
65
+ "required": true
66
+ }
67
+ }
68
+ }
69
+ },
70
+ "text-to-image": {
71
+ "models": [
72
+ "flux-2-flex-text-to-image",
73
+ "flux-2-pro-text-to-image"
74
+ ],
75
+ "fields_by_model": {
76
+ "flux-2-flex-text-to-image": {
77
+ "aspect_ratio": {
78
+ "enum": [
79
+ "1:1",
80
+ "4:3",
81
+ "3:4",
82
+ "16:9",
83
+ "9:16",
84
+ "3:2",
85
+ "2:3"
86
+ ]
87
+ },
88
+ "output_resolution": {
89
+ "enum": [
90
+ "1k",
91
+ "2k"
92
+ ]
93
+ },
94
+ "prompt": {
95
+ "required": true
96
+ }
97
+ },
98
+ "flux-2-pro-text-to-image": {
99
+ "aspect_ratio": {
100
+ "enum": [
101
+ "1:1",
102
+ "4:3",
103
+ "3:4",
104
+ "16:9",
105
+ "9:16",
106
+ "3:2",
107
+ "2:3"
108
+ ]
109
+ },
110
+ "output_resolution": {
111
+ "enum": [
112
+ "1k",
113
+ "2k"
114
+ ]
115
+ },
116
+ "prompt": {
117
+ "required": true
118
+ }
119
+ }
120
+ }
121
+ }
122
+ };
123
+
124
+ // src/resources/text-to-image.ts
7
125
  var ENDPOINT = "/api/v1/flux_2/text_to_image";
8
126
  var TextToImage = class {
9
127
  constructor(http) {
10
128
  this.http = http;
11
129
  }
12
130
  http;
131
+ /**
132
+ * Generate an image and wait until complete.
133
+ * @param params Text-to-image parameters.
134
+ * @param options Per-request and polling overrides.
135
+ * @returns The completed text-to-image result.
136
+ */
13
137
  async run(params, options) {
14
138
  const { id } = await this.create(params, options);
15
139
  const response = await pollUntilComplete(() => this.get(id, options), {
@@ -18,12 +142,26 @@ var TextToImage = class {
18
142
  });
19
143
  return response;
20
144
  }
145
+ /**
146
+ * Create a text-to-image task; returns immediately with a task id.
147
+ * @param params Text-to-image parameters.
148
+ * @param options Per-request overrides.
149
+ * @returns The task creation result with id.
150
+ */
21
151
  async create(params, options) {
152
+ const body = compactParams(params);
153
+ validateParams(contract["text-to-image"], body);
22
154
  return this.http.request("POST", ENDPOINT, {
23
- body: compactParams(params),
155
+ body,
24
156
  ...options
25
157
  });
26
158
  }
159
+ /**
160
+ * Fetch the current status of a text-to-image task.
161
+ * @param id The task id.
162
+ * @param options Per-request overrides.
163
+ * @returns The current text-to-image status.
164
+ */
27
165
  async get(id, options) {
28
166
  return this.http.request("GET", `${ENDPOINT}/${id}`, {
29
167
  ...options
@@ -32,7 +170,7 @@ var TextToImage = class {
32
170
  };
33
171
 
34
172
  // src/resources/remix-image.ts
35
- import { compactParams as compactParams2 } from "@runapi.ai/core";
173
+ import { compactParams as compactParams2, validateParams as validateParams2 } from "@runapi.ai/core";
36
174
  import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
37
175
  var ENDPOINT2 = "/api/v1/flux_2/remix_image";
38
176
  var RemixImage = class {
@@ -40,6 +178,12 @@ var RemixImage = class {
40
178
  this.http = http;
41
179
  }
42
180
  http;
181
+ /**
182
+ * Remix an image and wait until complete.
183
+ * @param params Image remix parameters.
184
+ * @param options Per-request and polling overrides.
185
+ * @returns The completed remix result with images.
186
+ */
43
187
  async run(params, options) {
44
188
  const { id } = await this.create(params, options);
45
189
  const response = await pollUntilComplete2(() => this.get(id, options), {
@@ -48,12 +192,26 @@ var RemixImage = class {
48
192
  });
49
193
  return response;
50
194
  }
195
+ /**
196
+ * Create an image remix task; returns immediately with a task id.
197
+ * @param params Image remix parameters.
198
+ * @param options Per-request overrides.
199
+ * @returns The task creation result with id.
200
+ */
51
201
  async create(params, options) {
202
+ const body = compactParams2(params);
203
+ validateParams2(contract["remix-image"], body);
52
204
  return this.http.request("POST", ENDPOINT2, {
53
- body: compactParams2(params),
205
+ body,
54
206
  ...options
55
207
  });
56
208
  }
209
+ /**
210
+ * Fetch the current status of an image remix task.
211
+ * @param id The task id.
212
+ * @param options Per-request overrides.
213
+ * @returns The current remix status.
214
+ */
57
215
  async get(id, options) {
58
216
  return this.http.request("GET", `${ENDPOINT2}/${id}`, {
59
217
  ...options
@@ -62,15 +220,15 @@ var RemixImage = class {
62
220
  };
63
221
 
64
222
  // src/client.ts
65
- var Flux2Client = class {
66
- /** Text-to-image operations. */
223
+ var Flux2Client = class extends BaseClient {
224
+ /** Text-to-image generation. */
67
225
  textToImage;
68
- /** Remix-image operations. */
226
+ /** Transform source images with text-guided prompts. */
69
227
  remixImage;
70
228
  constructor(options = {}) {
71
- const http = createHttpClient(options);
72
- this.textToImage = new TextToImage(http);
73
- this.remixImage = new RemixImage(http);
229
+ super(options);
230
+ this.textToImage = new TextToImage(this.http);
231
+ this.remixImage = new RemixImage(this.http);
74
232
  }
75
233
  };
76
234
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/resources/remix-image.ts","../src/index.ts"],"sourcesContent":["import { createHttpClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { RemixImage } from './resources/remix-image';\n\n/**\n * Flux 2 text-to-image API client.\n *\n * @example\n * ```typescript\n * const client = new Flux2Client({\n * apiKey: 'your-api-key',\n * baseUrl: 'https://runapi.ai',\n * });\n *\n * const result = await client.textToImage.run({\n * model: 'flux-2-pro-text-to-image',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class Flux2Client {\n /** Text-to-image operations. */\n public readonly textToImage: TextToImage;\n /** Remix-image operations. */\n public readonly remixImage: RemixImage;\n\n constructor(options: ClientOptions = {}) {\n const http = createHttpClient(options);\n this.textToImage = new TextToImage(http);\n this.remixImage = new RemixImage(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/flux_2/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 CompletedRemixImageResponse,\n RemixImageParams,\n RemixImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/flux_2/remix_image';\n\nexport class RemixImage {\n constructor(private readonly http: HttpClient) {}\n\n async run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedRemixImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<RemixImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedRemixImageResponse;\n }\n\n async create(params: RemixImageParams, 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<RemixImageResponse> {\n return this.http.request<RemixImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export { Flux2Client } from './client';\nexport * from './types';\n\n// Re-export core errors for convenience\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n"],"mappings":";AAAA,SAAS,wBAA4C;;;ACCrD,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAQlC,IAAM,WAAW;AAEV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAM,kBAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,MAAM,cAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ACnCA,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,qBAAAC,0BAAyB;AAQlC,IAAMC,YAAW;AAEV,IAAM,aAAN,MAAiB;AAAA,EACtB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA,EAE7B,MAAM,IAAI,QAA0B,SAAiF;AACnH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAMD,mBAAsC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACxF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,OAAO,QAA0B,SAAuD;AAC5F,WAAO,KAAK,KAAK,QAA4B,QAAQC,WAAU;AAAA,MAC7D,MAAMF,eAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,IAAI,IAAY,SAAuD;AAC3E,WAAO,KAAK,KAAK,QAA4B,OAAO,GAAGE,SAAQ,IAAI,EAAE,IAAI;AAAA,MACvE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AFhBO,IAAM,cAAN,MAAkB;AAAA;AAAA,EAEP;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO,iBAAiB,OAAO;AACrC,SAAK,cAAc,IAAI,YAAY,IAAI;AACvC,SAAK,aAAa,IAAI,WAAW,IAAI;AAAA,EACvC;AACF;;;AG3BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","pollUntilComplete","ENDPOINT"]}
1
+ {"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.ts","../src/resources/remix-image.ts","../src/index.ts"],"sourcesContent":["import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\nimport { RemixImage } from './resources/remix-image';\n\n/**\n * Flux 2 text-to-image and remix API client.\n *\n * Pro and flex tiers for both text-to-image generation and\n * text-guided image remixing from source images.\n *\n * @example\n * ```typescript\n * const client = new Flux2Client({\n * apiKey: 'your-api-key',\n * baseUrl: 'https://runapi.ai',\n * });\n *\n * const result = await client.textToImage.run({\n * model: 'flux-2-pro-text-to-image',\n * prompt: 'A futuristic cityscape at night',\n * });\n * ```\n */\nexport class Flux2Client extends BaseClient {\n /** Text-to-image generation. */\n public readonly textToImage: TextToImage;\n /** Transform source images with text-guided prompts. */\n public readonly remixImage: RemixImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n this.remixImage = new RemixImage(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/flux_2/text_to_image';\n\n/** Flux 2 text-to-image generation resource. */\nexport class TextToImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Generate an image 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 result.\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 with id.\n */\n async create(params: TextToImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['text-to-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of a text-to-image task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current text-to-image 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 \"remix-image\": {\n \"models\": [\n \"flux-2-flex-remix-image\",\n \"flux-2-pro-remix-image\"\n ],\n \"fields_by_model\": {\n \"flux-2-flex-remix-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"3:2\",\n \"2:3\",\n \"auto\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\"\n ]\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_image_urls\": {\n \"required\": true\n }\n },\n \"flux-2-pro-remix-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"3:2\",\n \"2:3\",\n \"auto\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\"\n ]\n },\n \"prompt\": {\n \"required\": true\n },\n \"source_image_urls\": {\n \"required\": true\n }\n }\n }\n },\n \"text-to-image\": {\n \"models\": [\n \"flux-2-flex-text-to-image\",\n \"flux-2-pro-text-to-image\"\n ],\n \"fields_by_model\": {\n \"flux-2-flex-text-to-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"4:3\",\n \"3:4\",\n \"16:9\",\n \"9:16\",\n \"3:2\",\n \"2:3\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\"\n ]\n },\n \"prompt\": {\n \"required\": true\n }\n },\n \"flux-2-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 \"3:2\",\n \"2:3\"\n ]\n },\n \"output_resolution\": {\n \"enum\": [\n \"1k\",\n \"2k\"\n ]\n },\n \"prompt\": {\n \"required\": true\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 CompletedRemixImageResponse,\n RemixImageParams,\n RemixImageResponse,\n TaskCreateResponse,\n} from '../types';\n\nconst ENDPOINT = '/api/v1/flux_2/remix_image';\n\n/** Flux 2 image remix: transform source images with text-guided prompts. */\nexport class RemixImage {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Remix an image and wait until complete.\n * @param params Image remix parameters.\n * @param options Per-request and polling overrides.\n * @returns The completed remix result with images.\n */\n async run(params: RemixImageParams, options?: RequestOptions & PollingOptions): Promise<CompletedRemixImageResponse> {\n const { id } = await this.create(params, options);\n const response = await pollUntilComplete<RemixImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\n return response as CompletedRemixImageResponse;\n }\n\n /**\n * Create an image remix task; returns immediately with a task id.\n * @param params Image remix parameters.\n * @param options Per-request overrides.\n * @returns The task creation result with id.\n */\n async create(params: RemixImageParams, options?: RequestOptions): Promise<TaskCreateResponse> {\n const body = compactParams(params);\n validateParams(contract['remix-image'] as ActionSchema, body as Record<string, unknown>);\n return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body,\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image remix task.\n * @param id The task id.\n * @param options Per-request overrides.\n * @returns The current remix status.\n */\n async get(id: string, options?: RequestOptions): Promise<RemixImageResponse> {\n return this.http.request<RemixImageResponse>('GET', `${ENDPOINT}/${id}`, {\n ...options,\n });\n }\n}\n","export { Flux2Client } from './client';\nexport * from './types';\n\n// Re-export core errors for convenience\nexport {\n RunApiError,\n AuthenticationError,\n InsufficientCreditsError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServiceUnavailableError,\n NetworkError,\n TimeoutError,\n TaskTimeoutError,\n TaskFailedError,\n} from '@runapi.ai/core';\n"],"mappings":";AAAA,SAAS,kBAAsC;;;ACC/C,SAAS,eAAe,sBAAsB;AAC9C,SAAS,yBAAyB;;;ACF3B,IAAM,WAAW;AAAA,EACtB,eAAe;AAAA,IACb,UAAU;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,2BAA2B;AAAA,QACzB,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAAqB;AAAA,UACnB,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,QACA,qBAAqB;AAAA,UACnB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA,0BAA0B;AAAA,QACxB,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,qBAAqB;AAAA,UACnB,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,UAAU;AAAA,UACR,YAAY;AAAA,QACd;AAAA,QACA,qBAAqB;AAAA,UACnB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;A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C;AAAA,EACH;AACF;;;AHnCO,IAAM,cAAN,cAA0B,WAAW;AAAA;AAAA,EAE1B;AAAA;AAAA,EAEA;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAC5C,SAAK,aAAa,IAAI,WAAW,KAAK,IAAI;AAAA,EAC5C;AACF;;;AI9BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["compactParams","validateParams","pollUntilComplete","ENDPOINT","pollUntilComplete","compactParams","validateParams"]}
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@runapi.ai/flux-2",
3
- "version": "0.2.5",
4
- "description": "RunAPI Flux 2 SDK for JavaScript, Ruby, and Go",
3
+ "runapi": {
4
+ "slug": "flux-2"
5
+ },
6
+ "version": "0.2.7",
7
+ "description": "RunAPI Flux 2 SDK for text-to-image and remix-image workflows in JavaScript, Python, Ruby, Go, and Java",
5
8
  "main": "./dist/index.js",
6
9
  "module": "./dist/index.mjs",
7
10
  "types": "./dist/index.d.ts",
@@ -28,7 +31,7 @@
28
31
  "clean": "rm -rf dist"
29
32
  },
30
33
  "dependencies": {
31
- "@runapi.ai/core": "^0.2.5"
34
+ "@runapi.ai/core": "^0.2.7"
32
35
  },
33
36
  "devDependencies": {
34
37
  "@types/node": "^20.0.0",
@@ -47,8 +50,16 @@
47
50
  "api",
48
51
  "sdk",
49
52
  "typescript",
53
+ "python",
50
54
  "ruby",
51
- "golang"
55
+ "golang",
56
+ "java",
57
+ "maven",
58
+ "gradle",
59
+ "image-generation",
60
+ "text-to-image",
61
+ "image-api",
62
+ "flux-api"
52
63
  ],
53
64
  "author": "RunAPI",
54
65
  "license": "Apache-2.0",
@@ -56,5 +67,8 @@
56
67
  "repository": {
57
68
  "type": "git",
58
69
  "url": "git+https://github.com/runapi-ai/flux-2-sdk.git"
70
+ },
71
+ "bugs": {
72
+ "url": "https://github.com/runapi-ai/flux-2-sdk/issues"
59
73
  }
60
74
  }
@@ -59,7 +59,7 @@ const result = await client.textToImage.run({
59
59
  const remix = await client.remixImage.run({
60
60
  model: 'flux-2-pro-remix-image',
61
61
  prompt: 'Make this product shot feel like a warm editorial photo',
62
- source_image_urls: ['https://example.com/source.jpg'],
62
+ source_image_urls: ['https://cdn.runapi.ai/public/samples/image.jpg'],
63
63
  aspect_ratio: 'auto',
64
64
  });
65
65
  ```
@@ -83,9 +83,11 @@ const remix = await client.remixImage.run({
83
83
 
84
84
  ## Agent rules
85
85
 
86
+ - 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
87
+ - 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.
86
88
  - Keep API keys in `RUNAPI_API_KEY` or RunAPI CLI config; never commit secrets.
87
89
  - Prefer `create`, `get`, and `run` JSON passthrough patterns instead of inventing flags for every model parameter.
88
- - For flux api pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
90
+ - For pricing, rate-limit, and commercial-usage answers, link to the variant page rather than the repository README.
89
91
 
90
92
  ## License
91
93
 
@@ -25,14 +25,23 @@ metadata:
25
25
 
26
26
  Generate and remix images with Flux 2 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 or remixing 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 Flux 2 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/flux-2`
39
+ - Ruby: `runapi-flux_2`
40
+ - Go: `github.com/runapi-ai/flux-2-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
 
@@ -60,13 +69,9 @@ runapi wait <task-id> --service flux-2 --action remix-image
60
69
 
61
70
  Available commands: `text-to-image`, `remix-image`.
62
71
 
63
- ## SDK integration path
64
-
65
- When integrating Flux 2 into an app, backend, worker, or library — not for one-off tasks — use a RunAPI SDK package:
72
+ ## Generated file storage
66
73
 
67
- - JavaScript / TypeScript: `@runapi.ai/flux-2`
68
- - Ruby: `runapi-flux_2`
69
- - Go: `github.com/runapi-ai/flux-2-sdk/go`
74
+ 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.
70
75
 
71
76
  ## References
72
77