@runapi.ai/flux-2 0.2.6 → 0.2.8

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,7 +27,7 @@ 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
  ```
@@ -38,7 +38,7 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
38
38
 
39
39
  ## Language notes
40
40
 
41
- 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.
42
42
 
43
43
  ## Links
44
44
 
package/dist/index.js CHANGED
@@ -41,6 +41,128 @@ 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
+ "min_items": 1,
78
+ "max_items": 8
79
+ }
80
+ },
81
+ "flux-2-pro-remix-image": {
82
+ "aspect_ratio": {
83
+ "enum": [
84
+ "1:1",
85
+ "4:3",
86
+ "3:4",
87
+ "16:9",
88
+ "9:16",
89
+ "3:2",
90
+ "2:3",
91
+ "auto"
92
+ ]
93
+ },
94
+ "output_resolution": {
95
+ "enum": [
96
+ "1k",
97
+ "2k"
98
+ ]
99
+ },
100
+ "prompt": {
101
+ "required": true
102
+ },
103
+ "source_image_urls": {
104
+ "required": true,
105
+ "min_items": 1,
106
+ "max_items": 8
107
+ }
108
+ }
109
+ }
110
+ },
111
+ "text-to-image": {
112
+ "models": [
113
+ "flux-2-flex-text-to-image",
114
+ "flux-2-pro-text-to-image"
115
+ ],
116
+ "fields_by_model": {
117
+ "flux-2-flex-text-to-image": {
118
+ "aspect_ratio": {
119
+ "enum": [
120
+ "1:1",
121
+ "4:3",
122
+ "3:4",
123
+ "16:9",
124
+ "9:16",
125
+ "3:2",
126
+ "2:3"
127
+ ]
128
+ },
129
+ "output_resolution": {
130
+ "enum": [
131
+ "1k",
132
+ "2k"
133
+ ]
134
+ },
135
+ "prompt": {
136
+ "required": true
137
+ }
138
+ },
139
+ "flux-2-pro-text-to-image": {
140
+ "aspect_ratio": {
141
+ "enum": [
142
+ "1:1",
143
+ "4:3",
144
+ "3:4",
145
+ "16:9",
146
+ "9:16",
147
+ "3:2",
148
+ "2:3"
149
+ ]
150
+ },
151
+ "output_resolution": {
152
+ "enum": [
153
+ "1k",
154
+ "2k"
155
+ ]
156
+ },
157
+ "prompt": {
158
+ "required": true
159
+ }
160
+ }
161
+ }
162
+ }
163
+ };
164
+
165
+ // src/resources/text-to-image.ts
44
166
  var ENDPOINT = "/api/v1/flux_2/text_to_image";
45
167
  var TextToImage = class {
46
168
  constructor(http) {
@@ -68,8 +190,10 @@ var TextToImage = class {
68
190
  * @returns The task creation result with id.
69
191
  */
70
192
  async create(params, options) {
193
+ const body = (0, import_core.compactParams)(params);
194
+ (0, import_core.validateParams)(contract["text-to-image"], body);
71
195
  return this.http.request("POST", ENDPOINT, {
72
- body: (0, import_core.compactParams)(params),
196
+ body,
73
197
  ...options
74
198
  });
75
199
  }
@@ -116,8 +240,10 @@ var RemixImage = class {
116
240
  * @returns The task creation result with id.
117
241
  */
118
242
  async create(params, options) {
243
+ const body = (0, import_core2.compactParams)(params);
244
+ (0, import_core2.validateParams)(contract["remix-image"], body);
119
245
  return this.http.request("POST", ENDPOINT2, {
120
- body: (0, import_core2.compactParams)(params),
246
+ body,
121
247
  ...options
122
248
  });
123
249
  }
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 { 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 } 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\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 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 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 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 return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image 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,kBAA8B;AAC9B,sBAAkC;AAQlC,IAAM,WAAW;AAGV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,UAAM,mCAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,UAAM,2BAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ACtDA,IAAAC,eAA8B;AAC9B,IAAAC,mBAAkC;AAQlC,IAAMC,YAAW;AAGV,IAAM,aAAN,MAAiB;AAAA,EACtB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,IAAI,QAA0B,SAAiF;AACnH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,UAAM,oCAAsC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACxF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAA0B,SAAuD;AAC5F,WAAO,KAAK,KAAK,QAA4B,QAAQA,WAAU;AAAA,MAC7D,UAAM,4BAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAuD;AAC3E,WAAO,KAAK,KAAK,QAA4B,OAAO,GAAGA,SAAQ,IAAI,EAAE,IAAI;AAAA,MACvE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AFhCO,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"]}
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 \"min_items\": 1,\n \"max_items\": 8\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 \"min_items\": 1,\n \"max_items\": 8\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;AAAA,UACZ,aAAa;AAAA,UACb,aAAa;AAAA,QACf;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,UAC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,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
@@ -2,8 +2,130 @@
2
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
+ "min_items": 1,
41
+ "max_items": 8
42
+ }
43
+ },
44
+ "flux-2-pro-remix-image": {
45
+ "aspect_ratio": {
46
+ "enum": [
47
+ "1:1",
48
+ "4:3",
49
+ "3:4",
50
+ "16:9",
51
+ "9:16",
52
+ "3:2",
53
+ "2:3",
54
+ "auto"
55
+ ]
56
+ },
57
+ "output_resolution": {
58
+ "enum": [
59
+ "1k",
60
+ "2k"
61
+ ]
62
+ },
63
+ "prompt": {
64
+ "required": true
65
+ },
66
+ "source_image_urls": {
67
+ "required": true,
68
+ "min_items": 1,
69
+ "max_items": 8
70
+ }
71
+ }
72
+ }
73
+ },
74
+ "text-to-image": {
75
+ "models": [
76
+ "flux-2-flex-text-to-image",
77
+ "flux-2-pro-text-to-image"
78
+ ],
79
+ "fields_by_model": {
80
+ "flux-2-flex-text-to-image": {
81
+ "aspect_ratio": {
82
+ "enum": [
83
+ "1:1",
84
+ "4:3",
85
+ "3:4",
86
+ "16:9",
87
+ "9:16",
88
+ "3:2",
89
+ "2:3"
90
+ ]
91
+ },
92
+ "output_resolution": {
93
+ "enum": [
94
+ "1k",
95
+ "2k"
96
+ ]
97
+ },
98
+ "prompt": {
99
+ "required": true
100
+ }
101
+ },
102
+ "flux-2-pro-text-to-image": {
103
+ "aspect_ratio": {
104
+ "enum": [
105
+ "1:1",
106
+ "4:3",
107
+ "3:4",
108
+ "16:9",
109
+ "9:16",
110
+ "3:2",
111
+ "2:3"
112
+ ]
113
+ },
114
+ "output_resolution": {
115
+ "enum": [
116
+ "1k",
117
+ "2k"
118
+ ]
119
+ },
120
+ "prompt": {
121
+ "required": true
122
+ }
123
+ }
124
+ }
125
+ }
126
+ };
127
+
128
+ // src/resources/text-to-image.ts
7
129
  var ENDPOINT = "/api/v1/flux_2/text_to_image";
8
130
  var TextToImage = class {
9
131
  constructor(http) {
@@ -31,8 +153,10 @@ var TextToImage = class {
31
153
  * @returns The task creation result with id.
32
154
  */
33
155
  async create(params, options) {
156
+ const body = compactParams(params);
157
+ validateParams(contract["text-to-image"], body);
34
158
  return this.http.request("POST", ENDPOINT, {
35
- body: compactParams(params),
159
+ body,
36
160
  ...options
37
161
  });
38
162
  }
@@ -50,7 +174,7 @@ var TextToImage = class {
50
174
  };
51
175
 
52
176
  // src/resources/remix-image.ts
53
- import { compactParams as compactParams2 } from "@runapi.ai/core";
177
+ import { compactParams as compactParams2, validateParams as validateParams2 } from "@runapi.ai/core";
54
178
  import { pollUntilComplete as pollUntilComplete2 } from "@runapi.ai/core/internal";
55
179
  var ENDPOINT2 = "/api/v1/flux_2/remix_image";
56
180
  var RemixImage = class {
@@ -79,8 +203,10 @@ var RemixImage = class {
79
203
  * @returns The task creation result with id.
80
204
  */
81
205
  async create(params, options) {
206
+ const body = compactParams2(params);
207
+ validateParams2(contract["remix-image"], body);
82
208
  return this.http.request("POST", ENDPOINT2, {
83
- body: compactParams2(params),
209
+ body,
84
210
  ...options
85
211
  });
86
212
  }
@@ -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 { 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 } 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\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 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 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 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 return this.http.request<TaskCreateResponse>('POST', ENDPOINT, {\n body: compactParams(params),\n ...options,\n });\n }\n\n /**\n * Fetch the current status of an image 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,qBAAqB;AAC9B,SAAS,yBAAyB;AAQlC,IAAM,WAAW;AAGV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,IAAI,QAA2B,SAAkF;AACrH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAM,kBAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAA2B,SAAu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E1B;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;;;AG9BA;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 \"min_items\": 1,\n \"max_items\": 8\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 \"min_items\": 1,\n \"max_items\": 8\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,UAC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MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACxF,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AACD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAA0B,SAAuD;AAC5F,UAAM,OAAOC,eAAc,MAAM;AACjC,IAAAC,gBAAe,SAAS,aAAa,GAAmB,IAA+B;AACvF,WAAO,KAAK,KAAK,QAA4B,QAAQH,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,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.6",
4
- "description": "RunAPI Flux 2 SDK for JavaScript, Ruby, and Go",
3
+ "runapi": {
4
+ "slug": "flux-2"
5
+ },
6
+ "version": "0.2.8",
7
+ "description": "RunAPI Flux 2 SDK for text-to-image and remix-image workflows in JavaScript, Python, Ruby, Go, Java, and PHP",
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.6"
34
+ "@runapi.ai/core": "^0.2.14"
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
  ```
@@ -87,7 +87,7 @@ const remix = await client.remixImage.run({
87
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.
88
88
  - Keep API keys in `RUNAPI_API_KEY` or RunAPI CLI config; never commit secrets.
89
89
  - Prefer `create`, `get`, and `run` JSON passthrough patterns instead of inventing flags for every model parameter.
90
- - 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.
91
91
 
92
92
  ## License
93
93
 
@@ -36,7 +36,7 @@ Generate and remix images with Flux 2 through RunAPI. The default path for one-o
36
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
37
 
38
38
  - JavaScript / TypeScript: `@runapi.ai/flux-2`
39
- - Ruby: `runapi-flux_2`
39
+ - Ruby: `runapi-flux-2`
40
40
  - Go: `github.com/runapi-ai/flux-2-sdk/go`
41
41
 
42
42
  ## CLI path