@runapi.ai/gpt-4o-image 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,25 +1,25 @@
1
- # GPT-4o Image API JavaScript SDK for RunAPI
1
+ # GPT-4o Image JavaScript SDK for RunAPI
2
2
 
3
- The gpt-4o image api JavaScript SDK is the language-specific package for GPT-4o Image on RunAPI. Use this gpt-4o image api package for text-to-image, image editing, and creative production flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in JavaScript.
3
+ The GPT-4o Image JavaScript SDK is the language-specific package for GPT-4o Image 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 gpt-4o image api README is the JavaScript package guide inside the public `gpt4o-image-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/gpt-4o-image; for API reference, use https://runapi.ai/docs#gpt-4o-image; for SDK docs, use https://runapi.ai/docs#sdk-gpt-4o-image.
5
+ This README is the JavaScript package guide inside the public `gpt-4o-image-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/gpt-4o-image; for API reference, use https://runapi.ai/docs#gpt-4o-image; for SDK docs, use https://runapi.ai/docs#sdk-gpt-4o-image.
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install @runapi.ai/gpt4o-image
10
+ npm install @runapi.ai/gpt-4o-image
11
11
  ```
12
12
 
13
13
  ## Quick start
14
14
 
15
15
  ```typescript
16
- import { Gpt4oImageClient } from '@runapi.ai/gpt4o-image';
16
+ import { Gpt4oImageClient } from '@runapi.ai/gpt-4o-image';
17
17
 
18
18
  const client = new Gpt4oImageClient();
19
- const task = await client.generations.create({
19
+ const task = await client.textToImage.create({
20
20
  // Pass the GPT-4o Image JSON request body from https://runapi.ai/docs#gpt-4o-image.
21
21
  });
22
- const status = await client.generations.get(task.id);
22
+ const status = await client.textToImage.get(task.id);
23
23
  ```
24
24
 
25
25
  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.
@@ -28,7 +28,7 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
28
28
 
29
29
  ## Language notes
30
30
 
31
- Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The available resources include generations. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
31
+ Use the TypeScript types in `src/types.ts` and the resource classes under `src/resources` when building image applications. The available resources are `textToImage`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
32
32
 
33
33
  ## Links
34
34
 
package/dist/index.d.mts CHANGED
@@ -101,7 +101,7 @@ declare class TextToImage {
101
101
  * model: 'gpt-4o-image',
102
102
  * prompt: 'Add a rainbow',
103
103
  * aspect_ratio: '3:2',
104
- * source_image_urls: ['https://example.com/photo.jpg'],
104
+ * source_image_urls: ['https://cdn.runapi.ai/public/samples/image.jpg'],
105
105
  * });
106
106
  * ```
107
107
  */
package/dist/index.d.ts CHANGED
@@ -101,7 +101,7 @@ declare class TextToImage {
101
101
  * model: 'gpt-4o-image',
102
102
  * prompt: 'Add a rainbow',
103
103
  * aspect_ratio: '3:2',
104
- * source_image_urls: ['https://example.com/photo.jpg'],
104
+ * source_image_urls: ['https://cdn.runapi.ai/public/samples/image.jpg'],
105
105
  * });
106
106
  * ```
107
107
  */
package/dist/index.js CHANGED
@@ -41,6 +41,40 @@ var import_core2 = 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
+ "text-to-image": {
48
+ "models": [
49
+ "gpt-4o-image"
50
+ ],
51
+ "fields_by_model": {
52
+ "gpt-4o-image": {
53
+ "aspect_ratio": {
54
+ "enum": [
55
+ "1:1",
56
+ "3:2",
57
+ "2:3"
58
+ ],
59
+ "required": true
60
+ },
61
+ "output_count": {
62
+ "enum": [
63
+ 1,
64
+ 2,
65
+ 4
66
+ ],
67
+ "type": "integer"
68
+ },
69
+ "source_image_urls": {
70
+ "max_items": 5
71
+ }
72
+ }
73
+ }
74
+ }
75
+ };
76
+
77
+ // src/resources/text-to-image.ts
44
78
  var ENDPOINT = "/api/v1/gpt_4o_image/text_to_image";
45
79
  var TextToImage = class {
46
80
  constructor(http) {
@@ -67,8 +101,10 @@ var TextToImage = class {
67
101
  * @returns The task creation result with id.
68
102
  */
69
103
  async create(params, options) {
104
+ const body = (0, import_core.compactParams)(params);
105
+ (0, import_core.validateParams)(contract["text-to-image"], body);
70
106
  return this.http.request("POST", ENDPOINT, {
71
- body: (0, import_core.compactParams)(params),
107
+ body,
72
108
  ...options
73
109
  });
74
110
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/resources/text-to-image.ts"],"sourcesContent":["export { Gpt4oImageClient } 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';\n\n/**\n * GPT-4o Image generation and editing API client.\n *\n * Supports pure text-to-image generation, image editing with source images,\n * and inpainting with an optional mask. At least one of `prompt` or\n * `source_image_urls` must be provided.\n *\n * @example\n * ```typescript\n * const client = new Gpt4oImageClient({ apiKey: 'your-api-key' });\n *\n * // Pure generation\n * const result = await client.textToImage.run({\n * model: 'gpt-4o-image',\n * prompt: 'A watercolor painting of a sunset',\n * aspect_ratio: '3:2',\n * });\n *\n * // Edit with source images\n * const edited = await client.textToImage.run({\n * model: 'gpt-4o-image',\n * prompt: 'Add a rainbow',\n * aspect_ratio: '3:2',\n * source_image_urls: ['https://example.com/photo.jpg'],\n * });\n * ```\n */\nexport class Gpt4oImageClient extends BaseClient {\n /** Image generation, editing, and inpainting operations. */\n public readonly textToImage: TextToImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n }\n}\n","import type { HttpClient, PollingOptions, RequestOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type { TextToImageParams, TextToImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/gpt_4o_image/text_to_image';\n\n/**\n * Generates images from a text prompt, optionally guided by source images and a mask.\n * For pure generation, provide a prompt. For editing, provide source_image_urls\n * (and optionally mask_url) to modify specific regions of the source.\n */\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<TextToImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\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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ts","../src/contract_gen.ts"],"sourcesContent":["export { Gpt4oImageClient } 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';\n\n/**\n * GPT-4o Image generation and editing API client.\n *\n * Supports pure text-to-image generation, image editing with source images,\n * and inpainting with an optional mask. At least one of `prompt` or\n * `source_image_urls` must be provided.\n *\n * @example\n * ```typescript\n * const client = new Gpt4oImageClient({ apiKey: 'your-api-key' });\n *\n * // Pure generation\n * const result = await client.textToImage.run({\n * model: 'gpt-4o-image',\n * prompt: 'A watercolor painting of a sunset',\n * aspect_ratio: '3:2',\n * });\n *\n * // Edit with source images\n * const edited = await client.textToImage.run({\n * model: 'gpt-4o-image',\n * prompt: 'Add a rainbow',\n * aspect_ratio: '3:2',\n * source_image_urls: ['https://cdn.runapi.ai/public/samples/image.jpg'],\n * });\n * ```\n */\nexport class Gpt4oImageClient extends BaseClient {\n /** Image generation, editing, and inpainting operations. */\n public readonly textToImage: TextToImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n }\n}\n","import type { HttpClient, PollingOptions, RequestOptions, 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 { TextToImageParams, TextToImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/gpt_4o_image/text_to_image';\n\n/**\n * Generates images from a text prompt, optionally guided by source images and a mask.\n * For pure generation, provide a prompt. For editing, provide source_image_urls\n * (and optionally mask_url) to modify specific regions of the source.\n */\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<TextToImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\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 \"text-to-image\": {\n \"models\": [\n \"gpt-4o-image\"\n ],\n \"fields_by_model\": {\n \"gpt-4o-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"3:2\",\n \"2:3\"\n ],\n \"required\": true\n },\n \"output_count\": {\n \"enum\": [\n 1,\n 2,\n 4\n ],\n \"type\": \"integer\"\n },\n \"source_image_urls\": {\n \"max_items\": 5\n }\n }\n }\n }\n} as const;\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,iBAAiB;AAAA,IACf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AW;AAAA;AAAA,EAE/B;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAAA,EAC9C;AACF;;;ADlCA,IAAAC,eAYO;","names":["import_core","import_core"]}
package/dist/index.mjs CHANGED
@@ -2,8 +2,42 @@
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
+ "text-to-image": {
11
+ "models": [
12
+ "gpt-4o-image"
13
+ ],
14
+ "fields_by_model": {
15
+ "gpt-4o-image": {
16
+ "aspect_ratio": {
17
+ "enum": [
18
+ "1:1",
19
+ "3:2",
20
+ "2:3"
21
+ ],
22
+ "required": true
23
+ },
24
+ "output_count": {
25
+ "enum": [
26
+ 1,
27
+ 2,
28
+ 4
29
+ ],
30
+ "type": "integer"
31
+ },
32
+ "source_image_urls": {
33
+ "max_items": 5
34
+ }
35
+ }
36
+ }
37
+ }
38
+ };
39
+
40
+ // src/resources/text-to-image.ts
7
41
  var ENDPOINT = "/api/v1/gpt_4o_image/text_to_image";
8
42
  var TextToImage = class {
9
43
  constructor(http) {
@@ -30,8 +64,10 @@ var TextToImage = class {
30
64
  * @returns The task creation result with id.
31
65
  */
32
66
  async create(params, options) {
67
+ const body = compactParams(params);
68
+ validateParams(contract["text-to-image"], body);
33
69
  return this.http.request("POST", ENDPOINT, {
34
- body: compactParams(params),
70
+ body,
35
71
  ...options
36
72
  });
37
73
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/index.ts"],"sourcesContent":["import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\n\n/**\n * GPT-4o Image generation and editing API client.\n *\n * Supports pure text-to-image generation, image editing with source images,\n * and inpainting with an optional mask. At least one of `prompt` or\n * `source_image_urls` must be provided.\n *\n * @example\n * ```typescript\n * const client = new Gpt4oImageClient({ apiKey: 'your-api-key' });\n *\n * // Pure generation\n * const result = await client.textToImage.run({\n * model: 'gpt-4o-image',\n * prompt: 'A watercolor painting of a sunset',\n * aspect_ratio: '3:2',\n * });\n *\n * // Edit with source images\n * const edited = await client.textToImage.run({\n * model: 'gpt-4o-image',\n * prompt: 'Add a rainbow',\n * aspect_ratio: '3:2',\n * source_image_urls: ['https://example.com/photo.jpg'],\n * });\n * ```\n */\nexport class Gpt4oImageClient extends BaseClient {\n /** Image generation, editing, and inpainting operations. */\n public readonly textToImage: TextToImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n }\n}\n","import type { HttpClient, PollingOptions, RequestOptions } from '@runapi.ai/core';\nimport { compactParams } from '@runapi.ai/core';\nimport { pollUntilComplete } from '@runapi.ai/core/internal';\nimport type { TextToImageParams, TextToImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/gpt_4o_image/text_to_image';\n\n/**\n * Generates images from a text prompt, optionally guided by source images and a mask.\n * For pure generation, provide a prompt. For editing, provide source_image_urls\n * (and optionally mask_url) to modify specific regions of the source.\n */\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<TextToImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\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","export { Gpt4oImageClient } 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;AAGlC,IAAM,WAAW;AAOV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,IAAI,QAA2B,SAAyE;AAC5G,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,WAAO,kBAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzE,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D,MAAM,cAAc,MAAM;AAAA,MAC1B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;ADvBO,IAAM,mBAAN,cAA+B,WAAW;AAAA;AAAA,EAE/B;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAAA,EAC9C;AACF;;;AElCA;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":[]}
1
+ {"version":3,"sources":["../src/client.ts","../src/resources/text-to-image.ts","../src/contract_gen.ts","../src/index.ts"],"sourcesContent":["import { BaseClient, type ClientOptions } from '@runapi.ai/core';\nimport { TextToImage } from './resources/text-to-image';\n\n/**\n * GPT-4o Image generation and editing API client.\n *\n * Supports pure text-to-image generation, image editing with source images,\n * and inpainting with an optional mask. At least one of `prompt` or\n * `source_image_urls` must be provided.\n *\n * @example\n * ```typescript\n * const client = new Gpt4oImageClient({ apiKey: 'your-api-key' });\n *\n * // Pure generation\n * const result = await client.textToImage.run({\n * model: 'gpt-4o-image',\n * prompt: 'A watercolor painting of a sunset',\n * aspect_ratio: '3:2',\n * });\n *\n * // Edit with source images\n * const edited = await client.textToImage.run({\n * model: 'gpt-4o-image',\n * prompt: 'Add a rainbow',\n * aspect_ratio: '3:2',\n * source_image_urls: ['https://cdn.runapi.ai/public/samples/image.jpg'],\n * });\n * ```\n */\nexport class Gpt4oImageClient extends BaseClient {\n /** Image generation, editing, and inpainting operations. */\n public readonly textToImage: TextToImage;\n\n constructor(options: ClientOptions = {}) {\n super(options);\n this.textToImage = new TextToImage(this.http);\n }\n}\n","import type { HttpClient, PollingOptions, RequestOptions, 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 { TextToImageParams, TextToImageResponse, TaskCreateResponse } from '../types';\n\nconst ENDPOINT = '/api/v1/gpt_4o_image/text_to_image';\n\n/**\n * Generates images from a text prompt, optionally guided by source images and a mask.\n * For pure generation, provide a prompt. For editing, provide source_image_urls\n * (and optionally mask_url) to modify specific regions of the source.\n */\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<TextToImageResponse> {\n const { id } = await this.create(params, options);\n return pollUntilComplete<TextToImageResponse>(() => this.get(id, options), {\n maxWaitMs: options?.maxWaitMs,\n pollIntervalMs: options?.pollIntervalMs,\n });\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 \"text-to-image\": {\n \"models\": [\n \"gpt-4o-image\"\n ],\n \"fields_by_model\": {\n \"gpt-4o-image\": {\n \"aspect_ratio\": {\n \"enum\": [\n \"1:1\",\n \"3:2\",\n \"2:3\"\n ],\n \"required\": true\n },\n \"output_count\": {\n \"enum\": [\n 1,\n 2,\n 4\n ],\n \"type\": \"integer\"\n },\n \"source_image_urls\": {\n \"max_items\": 5\n }\n }\n }\n }\n} as const;\n","export { Gpt4oImageClient } 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,iBAAiB;AAAA,IACf,UAAU;AAAA,MACR;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB,gBAAgB;AAAA,QACd,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UACA,YAAY;AAAA,QACd;AAAA,QACA,gBAAgB;AAAA,UACd,QAAQ;AAAA,YACN;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UACA,QAAQ;AAAA,QACV;AAAA,QACA,qBAAqB;AAAA,UACnB,aAAa;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;;;ADvBA,IAAM,WAAW;AAOV,IAAM,cAAN,MAAkB;AAAA,EACvB,YAA6B,MAAkB;AAAlB;AAAA,EAAmB;AAAA,EAAnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,IAAI,QAA2B,SAAyE;AAC5G,UAAM,EAAE,GAAG,IAAI,MAAM,KAAK,OAAO,QAAQ,OAAO;AAChD,WAAO,kBAAuC,MAAM,KAAK,IAAI,IAAI,OAAO,GAAG;AAAA,MACzE,WAAW,SAAS;AAAA,MACpB,gBAAgB,SAAS;AAAA,IAC3B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,QAA2B,SAAuD;AAC7F,UAAM,OAAO,cAAc,MAAM;AACjC,mBAAe,SAAS,eAAe,GAAmB,IAA+B;AACzF,WAAO,KAAK,KAAK,QAA4B,QAAQ,UAAU;AAAA,MAC7D;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,IAAY,SAAwD;AAC5E,WAAO,KAAK,KAAK,QAA6B,OAAO,GAAG,QAAQ,IAAI,EAAE,IAAI;AAAA,MACxE,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACF;;;AD1BO,IAAM,mBAAN,cAA+B,WAAW;AAAA;AAAA,EAE/B;AAAA,EAEhB,YAAY,UAAyB,CAAC,GAAG;AACvC,UAAM,OAAO;AACb,SAAK,cAAc,IAAI,YAAY,KAAK,IAAI;AAAA,EAC9C;AACF;;;AGlCA;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":[]}
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@runapi.ai/gpt-4o-image",
3
- "version": "0.2.6",
4
- "description": "RunAPI GPT-4o Image SDK for JavaScript, Ruby, and Go",
3
+ "runapi": {
4
+ "slug": "gpt-4o-image"
5
+ },
6
+ "version": "0.2.8",
7
+ "description": "RunAPI GPT-4o Image SDK for text-to-image generation 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",
@@ -27,7 +30,7 @@
27
30
  "clean": "rm -rf dist"
28
31
  },
29
32
  "dependencies": {
30
- "@runapi.ai/core": "^0.2.6"
33
+ "@runapi.ai/core": "^0.2.14"
31
34
  },
32
35
  "devDependencies": {
33
36
  "@types/node": "^20.0.0",
@@ -46,8 +49,16 @@
46
49
  "api",
47
50
  "sdk",
48
51
  "typescript",
52
+ "python",
49
53
  "ruby",
50
- "golang"
54
+ "golang",
55
+ "java",
56
+ "maven",
57
+ "gradle",
58
+ "image-generation",
59
+ "text-to-image",
60
+ "image-api",
61
+ "gpt-4o-image-api"
51
62
  ],
52
63
  "author": "RunAPI",
53
64
  "license": "Apache-2.0",
@@ -55,5 +66,8 @@
55
66
  "repository": {
56
67
  "type": "git",
57
68
  "url": "git+https://github.com/runapi-ai/gpt-4o-image-sdk.git"
69
+ },
70
+ "bugs": {
71
+ "url": "https://github.com/runapi-ai/gpt-4o-image-sdk/issues"
58
72
  }
59
73
  }