@runapi.ai/flux-2 0.2.7 → 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/dist/index.js CHANGED
@@ -73,7 +73,9 @@ var contract = {
73
73
  "required": true
74
74
  },
75
75
  "source_image_urls": {
76
- "required": true
76
+ "required": true,
77
+ "min_items": 1,
78
+ "max_items": 8
77
79
  }
78
80
  },
79
81
  "flux-2-pro-remix-image": {
@@ -99,7 +101,9 @@ var contract = {
99
101
  "required": true
100
102
  },
101
103
  "source_image_urls": {
102
- "required": true
104
+ "required": true,
105
+ "min_items": 1,
106
+ "max_items": 8
103
107
  }
104
108
  }
105
109
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.ts","../src/resources/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;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K,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,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"]}
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,UACR,YAAY;AAAA,QACd;AAAA,QACA,qBAAqB;AAAA,UACnB,YAAY;AAAA,UACZ,aAAa;AAAA,UACb,aAAa;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,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0B,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
@@ -36,7 +36,9 @@ var contract = {
36
36
  "required": true
37
37
  },
38
38
  "source_image_urls": {
39
- "required": true
39
+ "required": true,
40
+ "min_items": 1,
41
+ "max_items": 8
40
42
  }
41
43
  },
42
44
  "flux-2-pro-remix-image": {
@@ -62,7 +64,9 @@ var contract = {
62
64
  "required": true
63
65
  },
64
66
  "source_image_urls": {
65
- "required": true
67
+ "required": true,
68
+ "min_items": 1,
69
+ "max_items": 8
66
70
  }
67
71
  }
68
72
  }
@@ -1 +1 @@
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,U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M,IAAI,QAA0B,SAAiF;AACnH,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,UAAM,WAAW,MAAMC,mBAAsC,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"]}
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,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,UACR,YAAY;AAAA,QACd;AAAA,QACA,qB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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
@@ -3,8 +3,8 @@
3
3
  "runapi": {
4
4
  "slug": "flux-2"
5
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",
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",
8
8
  "main": "./dist/index.js",
9
9
  "module": "./dist/index.mjs",
10
10
  "types": "./dist/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "clean": "rm -rf dist"
32
32
  },
33
33
  "dependencies": {
34
- "@runapi.ai/core": "^0.2.7"
34
+ "@runapi.ai/core": "^0.2.14"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^20.0.0",
@@ -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