@acedatacloud/piece-gpt-image 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ace Data Cloud
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,50 @@
1
- # Temporary Holding Version
1
+ # GPT Image for Activepieces
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Create a GPT Image task and retrieve the **same task ID** through Ace Data Cloud. The Piece has two actions: **Create GPT Image task** and **Get GPT Image task**. Submission returns an ID; the image is ready only after the lookup reports `succeeded`.
4
+
5
+ **Distribution:** Install `@acedatacloud/piece-gpt-image@0.1.1` as a custom Piece in your Activepieces instance. A public npm package does not automatically enter the shared Activepieces catalog. [中文指南](README.zh-CN.md)
6
+
7
+ ## Install and connect
8
+
9
+ In Activepieces 0.92.2+, open **Platform Admin → Catalogue → Pieces → Install Piece → NPM Registry**. Enter `@acedatacloud/piece-gpt-image` and version `0.1.1`, then install it. Search for **GPT Image by Ace Data Cloud** when adding a flow action. Confirm the Ace Data Cloud logo and both actions.
10
+
11
+ 1. Register or sign in at [Ace Data Cloud Applications](https://platform.acedata.cloud/console/applications?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen&utm_content=gpt_image_activepieces_readme_api_key). If you have no General application, choose **Initialize General Application**.
12
+ 2. Open a General application or an application with **GPT Image** access. A General key can access the services your account is entitled to use; a service-specific key is limited to that service.
13
+ 3. Use the application's copy button, or choose **Manage Keys → Create** to create a separate key named `Activepieces GPT Image`. Set expiry and usage limits as needed. If you restrict **Allowed APIs**, include both `/openai/images/generations` and `/openai/tasks`, then copy the key.
14
+ 4. Create an Activepieces connection and enter only the API key, without `Bearer `. A `platform-...` management token is not a generation API key. Keep the key in the connection, never in a flow export. Check current [pricing](https://platform.acedata.cloud/models?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen&utm_content=gpt_image_activepieces_readme_pricing) and balance before generation.
15
+
16
+ ## First flow
17
+
18
+ 1. Add **Create GPT Image task**. Enter a prompt, choose `gpt-image-2`, quality `low`, size `1024x1024`, and image count `1`.
19
+ 2. Run creation **once** and save its `task_id`. The action uses `callback_url` to submit asynchronously and has no HTTP retry. If a timeout or 5xx occurs, inspect [request history](https://platform.acedata.cloud/console/usages?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen&utm_content=gpt_image_activepieces_readme_request_history) before submitting again: the task may already exist.
20
+ 3. Add **Get GPT Image task**. Map its **Task ID** from the creation output. Query this same ID until `status=succeeded` or `failed`. Pending media is never returned as final output.
21
+ 4. Open a URL from `media_urls` only after `success=true`. The lookup can alternatively use a trace ID if the original request supplied a custom trace ID and its task ID was lost. This creation action does not set a custom trace ID.
22
+
23
+ The [credential-free quickstart flow](https://raw.githubusercontent.com/AceDataCloud/GPTImageActivepieces/main/examples/gpt-image-quickstart.json) imports with both connections empty and the task-ID mapping intact. Add your own connection before running it. Its creation action has automatic retries disabled.
24
+
25
+ Image count is 1–10 and each successful image can incur a charge. `size` must use `WIDTHxHEIGHT`; the GPT Image 2 public guide gives current custom-size limits. A task lookup does not create or bill another image.
26
+
27
+ An isolated Activepieces CE 0.92.2 instance accepted the build archive and ran **Get GPT Image task** against an existing completed task. The flow returned `succeeded` and one final image URL. The creation action has not been used to submit a new paid image in this validation.
28
+
29
+ ## Troubleshoot
30
+
31
+ | Result | Action |
32
+ | --- | --- |
33
+ | 401 or 403 | Check the API key, GPT Image access, and Allowed APIs for both paths. |
34
+ | 400 | Check the prompt, model, `WIDTHxHEIGHT` size, and image count. |
35
+ | `pending` | Wait and query the same task ID. Do not rerun creation. |
36
+ | 429 | Reduce concurrency and wait; do not automatically retry paid creation. |
37
+ | Creation timeout or 5xx | Inspect request history before another submission. |
38
+ | `failed` or missing task | Check the task or trace ID and retention window. |
39
+
40
+ The Piece sends chosen inputs and the API key only to `https://api.acedata.cloud`. It returns final media URLs and removes internal routing fields from task results. [Source](https://github.com/AceDataCloud/GPTImageActivepieces) · [Support](https://github.com/AceDataCloud/GPTImageActivepieces/issues) · dev@acedata.cloud.
41
+
42
+ API requests verify HTTPS certificates and stay on `api.acedata.cloud`. Transport failures and HTTP errors are not retried automatically; inspect request history before resubmitting a creation. HTTPS proxy configuration is not supported by this transport.
43
+
44
+ ## Visual setup references
45
+
46
+ ![Copy a key or open Manage Keys: real redacted Ace console](docs/screenshots/get-api-key-en.png)
47
+ ![Create a dedicated key: real redacted Ace console](docs/screenshots/create-api-key-en.png)
48
+ ![Official Activepieces generic installation dialog](docs/screenshots/install-piece.png)
49
+
50
+ References reused on 2026-10-18; [fixed sources and limits](docs/screenshots/onboarding-source.json). The installation picture is an official generic reference, not proof this Piece is in the shared catalog. After administrator installation, search the service name, select **by Ace Data Cloud**, and keep the raw API key in the action connection. Source PR, immutable npm release, official shared-catalog acceptance and first use are separate stages.
@@ -0,0 +1,50 @@
1
+ # GPT Image for Activepieces
2
+
3
+ 通过 Ace Data Cloud 创建 GPT Image 任务,并按**同一个任务 ID**查询结果。Piece 提供 **Create GPT Image task** 和 **Get GPT Image task** 两个动作。提交返回 ID 并不代表图片已完成;查询到 `succeeded` 后才可使用成品。[English](README.md)
4
+
5
+ **分发方式:**在 Activepieces 实例中将 `@acedatacloud/piece-gpt-image@0.1.1` 作为自定义 Piece 安装。公开 npm 包不会自动进入 Activepieces 共享目录。
6
+
7
+ ## 安装与连接
8
+
9
+ Activepieces 0.92.2+ 中进入 **Platform Admin → Catalogue → Pieces → Install Piece → NPM Registry**,填写 `@acedatacloud/piece-gpt-image` 和版本 `0.1.1`。在流程中搜索 **GPT Image by Ace Data Cloud**,核对 Ace Data Cloud Logo 和两个动作。
10
+
11
+ 1. 在 [Ace Data Cloud Applications](https://platform.acedata.cloud/console/applications?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen&utm_content=gpt_image_activepieces_readme_api_key) 注册或登录。若没有通用应用,点击 **Initialize General Application**。
12
+ 2. 打开通用应用或具备 **GPT Image** 权限的应用。通用 Key 可访问账号已获授权的服务;专用 Key 仅限对应服务。
13
+ 3. 使用应用卡片的复制按钮,或通过 **Manage Keys → Create** 创建名为 `Activepieces GPT Image` 的独立 Key,按需设置有效期与用量限制。若启用 **Allowed APIs**,应同时包含 `/openai/images/generations` 与 `/openai/tasks`,创建后复制 Key。
14
+ 4. 创建 Activepieces 连接,只填写 API Key 本身,不加 `Bearer `。`platform-...` 管理 Token 不是生成 API Key。Key 留在连接中,不写入流程导出。生成前查看当前[价格](https://platform.acedata.cloud/models?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen&utm_content=gpt_image_activepieces_readme_pricing)与余额。
15
+
16
+ ## 首次流程
17
+
18
+ 1. 添加 **Create GPT Image task**,填写提示词,选择 `gpt-image-2`、`low`、`1024x1024` 和图片数量 `1`。
19
+ 2. **只运行一次**创建动作,保存输出的 `task_id`。动作使用 `callback_url` 异步提交,不设置 HTTP 重试。若超时或返回 5xx,先查[请求历史](https://platform.acedata.cloud/console/usages?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen&utm_content=gpt_image_activepieces_readme_request_history)再考虑重提,任务可能已被接收。
20
+ 3. 添加 **Get GPT Image task**,把 **Task ID** 映射为创建动作的输出。只查询同一个 ID,直至 `status=succeeded` 或 `failed`。pending 时不会把预览当作最终媒体。
21
+ 4. 仅当 `success=true` 时打开 `media_urls`。若原始请求自带自定义 Trace ID 且丢失任务 ID,也可按 Trace ID 查询;本 Piece 的创建动作不设置自定义 Trace ID。
22
+
23
+ [无密钥首跑流程](https://raw.githubusercontent.com/AceDataCloud/GPTImageActivepieces/main/examples/gpt-image-quickstart.json) 导入后两个连接均为空,任务 ID 映射保留。运行前请配置自己的连接;创建动作已关闭自动重试。
24
+
25
+ 图片数量为 1–10;每张成功图片可能单独计费。`size` 使用 `WIDTHxHEIGHT`,自定义尺寸限制以 GPT Image 2 公开指南为准。查询任务不会再次生成或计费。
26
+
27
+ 隔离的 Activepieces CE 0.92.2 实例已接受构建归档,并通过 **Get GPT Image task** 查询一条既有完成任务;流程返回 `succeeded` 和 1 个最终图片 URL。本轮未通过创建动作提交新的付费图片任务。
28
+
29
+ ## 排障
30
+
31
+ | 现象 | 处理 |
32
+ | --- | --- |
33
+ | 401 / 403 | 核对 Key、GPT Image 权限和两个路径的 Allowed APIs。 |
34
+ | 400 | 核对提示词、模型、`WIDTHxHEIGHT` 尺寸和图片数量。 |
35
+ | `pending` | 等待并查询同一任务 ID,不重跑创建。 |
36
+ | 429 | 降低并发,避免自动重试付费创建。 |
37
+ | 创建超时或 5xx | 先检查请求历史,再考虑再次提交。 |
38
+ | `failed` 或任务不存在 | 检查任务或 Trace ID 及保留期限。 |
39
+
40
+ Piece 只向 `https://api.acedata.cloud` 发送所选输入和 API Key,仅在终态返回媒体 URL,并过滤内部路由字段。[源码](https://github.com/AceDataCloud/GPTImageActivepieces) · [支持](https://github.com/AceDataCloud/GPTImageActivepieces/issues) · dev@acedata.cloud。
41
+
42
+ API 请求验证 HTTPS 证书,且仅访问 `api.acedata.cloud`。网络失败与 HTTP 错误不自动重试;重新创建前先查请求历史。此传输方式不支持 HTTPS 代理配置。
43
+
44
+ ## 图文配置参考
45
+
46
+ ![复制 Key 或管理密钥:真实脱敏 Ace 控制台](docs/screenshots/get-api-key-en.png)
47
+ ![创建独立 Key:真实脱敏 Ace 控制台](docs/screenshots/create-api-key-en.png)
48
+ ![官方 Activepieces 通用安装弹窗](docs/screenshots/install-piece.png)
49
+
50
+ 2026-10-18 复用的真实/官方参考图,[固定来源与边界](docs/screenshots/onboarding-source.json)保留。安装图不是本 Piece 已被官方共享目录收录的证明。管理员安装后按服务名搜索并核对 **by Ace Data Cloud**;Key 只放动作连接。源码 PR、npm 发版、官方目录收录与真实首用分别验收。
@@ -0,0 +1 @@
1
+ export declare const gptImage: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gptImage = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const generate_image_1 = require("./lib/actions/generate-image");
6
+ const get_task_1 = require("./lib/actions/get-task");
7
+ const auth_1 = require("./lib/auth");
8
+ exports.gptImage = (0, pieces_framework_1.createPiece)({
9
+ displayName: 'GPT Image by Ace Data Cloud',
10
+ description: 'Create GPT Image tasks and retrieve the same task through Ace Data Cloud.',
11
+ logoUrl: 'https://cdn.acedata.cloud/assets/logo.png',
12
+ authors: ['Ace Data Cloud'],
13
+ minimumSupportedRelease: '0.92.2',
14
+ auth: auth_1.gptImageAuth,
15
+ actions: [generate_image_1.generateImage, get_task_1.getTask],
16
+ triggers: [],
17
+ });
@@ -0,0 +1,7 @@
1
+ export declare const generateImage: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ prompt: import("@activepieces/pieces-framework").LongTextProperty<true>;
3
+ model: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
4
+ quality: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
5
+ size: import("@activepieces/pieces-framework").ShortTextProperty<true>;
6
+ count: import("@activepieces/pieces-framework").NumberProperty<true>;
7
+ }>;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateImage = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const auth_1 = require("../auth");
6
+ const client_1 = require("../common/client");
7
+ exports.generateImage = (0, pieces_framework_1.createAction)({
8
+ name: 'generate_image',
9
+ displayName: 'Create GPT Image task',
10
+ description: 'Submit one image generation and return its task ID. This action does not wait for the final image.',
11
+ auth: auth_1.gptImageAuth,
12
+ props: {
13
+ prompt: pieces_framework_1.Property.LongText({
14
+ displayName: 'Image description',
15
+ description: 'Describe the image. Use Get GPT Image task with the returned task ID to check the result.',
16
+ required: true,
17
+ }),
18
+ model: pieces_framework_1.Property.StaticDropdown({
19
+ displayName: 'Model',
20
+ required: true,
21
+ defaultValue: 'gpt-image-2',
22
+ options: { options: [{ label: 'GPT Image 2', value: 'gpt-image-2' }] },
23
+ }),
24
+ quality: pieces_framework_1.Property.StaticDropdown({
25
+ displayName: 'Quality',
26
+ required: true,
27
+ defaultValue: 'low',
28
+ options: {
29
+ options: [
30
+ { label: 'Low', value: 'low' },
31
+ { label: 'Medium', value: 'medium' },
32
+ { label: 'High', value: 'high' },
33
+ { label: 'Auto', value: 'auto' },
34
+ ],
35
+ },
36
+ }),
37
+ size: pieces_framework_1.Property.ShortText({
38
+ displayName: 'Size',
39
+ description: 'WIDTHxHEIGHT, such as 1024x1024. Read current model limits before using a custom size.',
40
+ required: true,
41
+ defaultValue: '1024x1024',
42
+ }),
43
+ count: pieces_framework_1.Property.Number({
44
+ displayName: 'Image count',
45
+ description: 'Each generated image is billed. Choose a whole number from 1 to 10.',
46
+ required: true,
47
+ defaultValue: 1,
48
+ }),
49
+ },
50
+ async run(context) {
51
+ const { prompt, model, quality, size, count } = context.propsValue;
52
+ if (!prompt.trim()) {
53
+ throw new Error('An image description is required.');
54
+ }
55
+ if (!/^\d+x\d+$/.test(size)) {
56
+ throw new Error('Size must use WIDTHxHEIGHT, such as 1024x1024.');
57
+ }
58
+ if (!Number.isInteger(count) || count < 1 || count > 10) {
59
+ throw new Error('Image count must be a whole number from 1 to 10.');
60
+ }
61
+ const response = await client_1.gptImageClient.post({
62
+ token: context.auth.secret_text,
63
+ path: '/openai/images/generations',
64
+ body: {
65
+ model,
66
+ prompt,
67
+ quality,
68
+ size,
69
+ n: count,
70
+ callback_url: 'https://api.acedata.cloud/health',
71
+ },
72
+ });
73
+ const taskId = client_1.gptImageClient.taskIdFromSubmission(response);
74
+ if (!taskId) {
75
+ throw new Error('No task ID was returned. Inspect request history before submitting again.');
76
+ }
77
+ return { task_id: taskId, status: 'pending', success: false };
78
+ },
79
+ });
@@ -0,0 +1,4 @@
1
+ export declare const getTask: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ taskId: import("@activepieces/pieces-framework").ShortTextProperty<false>;
3
+ traceId: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ }>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTask = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const auth_1 = require("../auth");
6
+ const client_1 = require("../common/client");
7
+ exports.getTask = (0, pieces_framework_1.createAction)({
8
+ name: 'get_task',
9
+ displayName: 'Get GPT Image task',
10
+ description: 'Query one existing task ID, or a trace ID supplied on the original request. Pending data is not final media.',
11
+ auth: auth_1.gptImageAuth,
12
+ props: {
13
+ taskId: pieces_framework_1.Property.ShortText({
14
+ displayName: 'Task ID',
15
+ description: 'Map task_id from Create GPT Image task. Query this same ID until completion.',
16
+ required: false,
17
+ }),
18
+ traceId: pieces_framework_1.Property.ShortText({
19
+ displayName: 'Trace ID',
20
+ description: 'Optional recovery lookup when a prior request supplied a custom trace ID but timed out before returning task_id.',
21
+ required: false,
22
+ }),
23
+ },
24
+ async run(context) {
25
+ const taskId = context.propsValue.taskId?.trim() ?? '';
26
+ const traceId = context.propsValue.traceId?.trim() ?? '';
27
+ if (!taskId && !traceId) {
28
+ throw new Error('A task ID or trace ID is required.');
29
+ }
30
+ const response = await client_1.gptImageClient.post({
31
+ token: context.auth.secret_text,
32
+ path: '/openai/tasks',
33
+ body: { action: 'retrieve', ...(taskId ? { id: taskId } : { trace_id: traceId }) },
34
+ });
35
+ return client_1.gptImageClient.normalizeTask({ body: response, taskId, traceId });
36
+ },
37
+ });
@@ -0,0 +1 @@
1
+ export declare const gptImageAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gptImageAuth = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ exports.gptImageAuth = pieces_framework_1.PieceAuth.SecretText({
6
+ displayName: 'Ace Data Cloud API key',
7
+ description: 'Register or sign in at [Applications](https://platform.acedata.cloud/console/applications?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen&utm_content=gpt_image_activepieces_connection_api_key). If needed choose Initialize General Application, then copy the key or use Manage Keys → Create for a dedicated Activepieces key. Check service permissions, balance, current pricing and Allowed APIs in the guide. Paste only the API key without Bearer; a platform management token is not a generation key.',
8
+ required: true,
9
+ });
@@ -0,0 +1,25 @@
1
+ declare function post({ token, path, body, }: {
2
+ token: string;
3
+ path: '/openai/images/generations' | '/openai/tasks';
4
+ body: Record<string, unknown>;
5
+ }): Promise<unknown>;
6
+ declare function normalizeTask({ body, taskId, traceId }: {
7
+ body: unknown;
8
+ taskId: string;
9
+ traceId?: string;
10
+ }): TaskResult;
11
+ declare function taskIdFromSubmission(body: unknown): string;
12
+ export declare const gptImageClient: {
13
+ post: typeof post;
14
+ normalizeTask: typeof normalizeTask;
15
+ taskIdFromSubmission: typeof taskIdFromSubmission;
16
+ };
17
+ export type TaskResult = {
18
+ task_id: string;
19
+ status: 'pending' | 'succeeded' | 'failed';
20
+ success: boolean;
21
+ trace_id: string;
22
+ media_urls: string[];
23
+ result: unknown;
24
+ };
25
+ export {};
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gptImageClient = void 0;
4
+ const pieces_common_1 = require("@activepieces/pieces-common");
5
+ const secure_http_1 = require("../secure-http");
6
+ async function post({ token, path, body, }) {
7
+ const response = await secure_http_1.httpClient.sendRequest({
8
+ method: pieces_common_1.HttpMethod.POST,
9
+ url: `https://api.acedata.cloud${path}`,
10
+ headers: {
11
+ Authorization: `Bearer ${token}`,
12
+ 'Content-Type': 'application/json',
13
+ },
14
+ body,
15
+ retries: 0,
16
+ });
17
+ return response.body;
18
+ }
19
+ function normalizeTask({ body, taskId, traceId }) {
20
+ const envelope = record(body);
21
+ if (Object.keys(envelope).length === 0) {
22
+ throw new Error('Task not found. Check the task or trace ID and its retention window.');
23
+ }
24
+ const payload = parsePayload('response' in envelope ? envelope.response : body);
25
+ const values = record(payload);
26
+ const states = collectStates(payload);
27
+ const failed = states.some((state) => FAILED_STATES.has(state)) || hasFailure(payload) || Boolean(envelope.error);
28
+ const unfinished = 'finished_at' in envelope && envelope.finished_at === null;
29
+ const finished = !unfinished &&
30
+ !failed &&
31
+ ((states.length > 0 && states.every((state) => COMPLETE_STATES.has(state))) ||
32
+ Boolean(envelope.finished_at && hasContent(payload)));
33
+ const foundTraceId = stringValue(values.trace_id) || stringValue(envelope.trace_id) || traceId || '';
34
+ return {
35
+ task_id: stringValue(envelope.id) || taskId,
36
+ status: failed ? 'failed' : finished ? 'succeeded' : 'pending',
37
+ success: finished,
38
+ trace_id: foundTraceId,
39
+ media_urls: finished ? collectMediaUrls(payload) : [],
40
+ result: sanitize(payload),
41
+ };
42
+ }
43
+ function taskIdFromSubmission(body) {
44
+ const value = record(body);
45
+ const nestedTask = record(value.task);
46
+ return stringValue(value.task_id) || stringValue(nestedTask.id);
47
+ }
48
+ function parsePayload(value) {
49
+ if (typeof value !== 'string') {
50
+ return value;
51
+ }
52
+ try {
53
+ return JSON.parse(value);
54
+ }
55
+ catch {
56
+ return {};
57
+ }
58
+ }
59
+ function record(value) {
60
+ return value !== null && typeof value === 'object' && !Array.isArray(value)
61
+ ? Object.fromEntries(Object.entries(value))
62
+ : {};
63
+ }
64
+ function stringValue(value) {
65
+ return typeof value === 'string' ? value : '';
66
+ }
67
+ function collectStates(value) {
68
+ if (Array.isArray(value)) {
69
+ return value.flatMap(collectStates);
70
+ }
71
+ if (value === null || typeof value !== 'object') {
72
+ return [];
73
+ }
74
+ const item = record(value);
75
+ return [
76
+ ...['state', 'status'].flatMap((key) => {
77
+ const state = stringValue(item[key]);
78
+ return state ? [state.toLowerCase()] : [];
79
+ }),
80
+ ...['data', 'content', 'task'].flatMap((key) => collectStates(item[key])),
81
+ ];
82
+ }
83
+ function hasFailure(value) {
84
+ if (Array.isArray(value)) {
85
+ return value.some(hasFailure);
86
+ }
87
+ if (value === null || typeof value !== 'object') {
88
+ return false;
89
+ }
90
+ const item = record(value);
91
+ return Boolean(item.error) ||
92
+ (item.success === false && !['pending', 'running', 'processing'].includes(stringValue(item.status || item.state).toLowerCase())) ||
93
+ ['data', 'content', 'task'].some((key) => hasFailure(item[key]));
94
+ }
95
+ function collectMediaUrls(value) {
96
+ if (Array.isArray(value)) {
97
+ return [...new Set(value.flatMap(collectMediaUrls))];
98
+ }
99
+ if (value === null || typeof value !== 'object') {
100
+ return [];
101
+ }
102
+ const item = record(value);
103
+ const urls = Object.entries(item).flatMap(([key, child]) => {
104
+ if (['url', 'image_url'].includes(key) && typeof child === 'string') {
105
+ return child.startsWith('https://') ? [child] : [];
106
+ }
107
+ return collectMediaUrls(child);
108
+ });
109
+ return [...new Set(urls)];
110
+ }
111
+ function hasContent(value) {
112
+ return Array.isArray(value) ? value.length > 0 : Object.keys(record(value)).length > 0;
113
+ }
114
+ function sanitize(value) {
115
+ if (Array.isArray(value)) {
116
+ return value.map(sanitize);
117
+ }
118
+ if (value === null || typeof value !== 'object') {
119
+ return value;
120
+ }
121
+ return Object.fromEntries(Object.entries(value)
122
+ .filter(([key]) => !SENSITIVE_KEYS.has(key.toLowerCase()) && !SENSITIVE_KEY_PATTERN.test(key))
123
+ .map(([key, child]) => [key, key === 'error' ? 'Task failed; inspect its task or trace ID.' : sanitize(child)]));
124
+ }
125
+ exports.gptImageClient = { post, normalizeTask, taskIdFromSubmission };
126
+ const COMPLETE_STATES = new Set(['complete', 'completed', 'succeeded', 'succeed', 'success', 'finished']);
127
+ const FAILED_STATES = new Set(['failed', 'error', 'cancelled', 'canceled', 'rejected']);
128
+ const SENSITIVE_KEYS = new Set([
129
+ 'request', 'request_body', 'user_id', 'actor_user_id', 'credential_id', 'authorization_id',
130
+ 'application_id', 'api_key', 'access_token', 'refresh_token', 'authorization', 'headers',
131
+ 'supplier', 'supplier_id', 'provider_route', 'upstream', 'upstream_model', 'actual_model', 'secret',
132
+ ]);
133
+ const SENSITIVE_KEY_PATTERN = /(^internal(?:_|$)|supplier|upstream|(?:^|_)secret(?:_|$))/i;
@@ -0,0 +1,14 @@
1
+ type Request = {
2
+ method: string;
3
+ url: string;
4
+ headers?: Record<string, string>;
5
+ body?: unknown;
6
+ retries?: number;
7
+ };
8
+ export declare const httpClient: {
9
+ sendRequest<T>(request: Request): Promise<{
10
+ status: number;
11
+ body: T;
12
+ }>;
13
+ };
14
+ export {};
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.httpClient = void 0;
37
+ const https = __importStar(require("node:https"));
38
+ // Keep credentials on the documented API host and verify TLS even if the host
39
+ // process or an unrelated Piece has changed NODE_TLS_REJECT_UNAUTHORIZED.
40
+ exports.httpClient = {
41
+ async sendRequest(request) {
42
+ const url = new URL(request.url);
43
+ if (url.protocol !== 'https:' || url.hostname !== 'api.acedata.cloud' || url.port) {
44
+ throw new Error('Unsupported Ace Data Cloud API host.');
45
+ }
46
+ const payload = request.body === undefined ? undefined : JSON.stringify(request.body);
47
+ return new Promise((resolve, reject) => {
48
+ const pending = https.request(url, {
49
+ method: request.method,
50
+ rejectUnauthorized: true,
51
+ headers: {
52
+ ...request.headers,
53
+ ...(payload === undefined ? {} : { 'Content-Length': String(Buffer.byteLength(payload)) }),
54
+ },
55
+ }, (response) => {
56
+ let body = '';
57
+ response.setEncoding('utf8');
58
+ response.on('data', (chunk) => { body += chunk; });
59
+ response.on('error', () => reject(new Error('Ace Data Cloud response interrupted. Inspect request history before resubmitting.')));
60
+ response.on('end', () => {
61
+ const status = response.statusCode ?? 0;
62
+ if (status < 200 || status >= 300) {
63
+ const error = new Error(`Ace Data Cloud HTTP ${status}. Inspect request history before resubmitting.`);
64
+ Object.assign(error, { response: { status } });
65
+ reject(error);
66
+ return;
67
+ }
68
+ try {
69
+ resolve({ status, body: JSON.parse(body) });
70
+ }
71
+ catch {
72
+ reject(new Error('Ace Data Cloud returned invalid JSON. Inspect request history before resubmitting.'));
73
+ }
74
+ });
75
+ });
76
+ pending.setTimeout(120_000, () => pending.destroy(new Error('Request timeout')));
77
+ pending.on('error', () => reject(new Error('Ace Data Cloud network or TLS error. Inspect request history before resubmitting.')));
78
+ pending.end(payload);
79
+ });
80
+ },
81
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "checked_on": "2026-10-18 Asia/Shanghai",
3
+ "key_image_source": "https://github.com/AceDataCloud/SunoDify/tree/8d3d03570e73324220f111f7fe343da0792a8071/_assets/tutorial",
4
+ "installation_reference": "https://github.com/activepieces/activepieces/blob/860ce5b87c43856549586ee7b44007ba0937efdf/docs/resources/screenshots/install-piece.png",
5
+ "limits": "Real redacted Ace console references and official Activepieces generic install dialog. Not proof this service is in the official catalog or the current PR is published."
6
+ }
@@ -0,0 +1,126 @@
1
+ {
2
+ "name": "GPT Image quickstart",
3
+ "type": "SHARED",
4
+ "summary": "",
5
+ "description": "",
6
+ "tags": [],
7
+ "blogUrl": "",
8
+ "metadata": {
9
+ "externalId": "gpt-image-quickstart-20261012"
10
+ },
11
+ "author": "Ace Data Cloud",
12
+ "categories": [],
13
+ "pieces": [
14
+ "@activepieces/piece-manual-trigger",
15
+ "@acedatacloud/piece-gpt-image"
16
+ ],
17
+ "flows": [
18
+ {
19
+ "displayName": "GPT Image quickstart",
20
+ "trigger": {
21
+ "name": "trigger",
22
+ "valid": true,
23
+ "displayName": "Manual Trigger",
24
+ "nextAction": {
25
+ "name": "step_1",
26
+ "skip": false,
27
+ "type": "PIECE",
28
+ "valid": false,
29
+ "settings": {
30
+ "input": {
31
+ "auth": "",
32
+ "prompt": "A small red kite above a green meadow, watercolor illustration.",
33
+ "model": "gpt-image-2",
34
+ "quality": "low",
35
+ "size": "1024x1024",
36
+ "count": 1
37
+ },
38
+ "pieceName": "@acedatacloud/piece-gpt-image",
39
+ "actionName": "generate_image",
40
+ "sampleData": {},
41
+ "pieceVersion": "0.1.1",
42
+ "propertySettings": {
43
+ "prompt": {
44
+ "type": "MANUAL"
45
+ },
46
+ "model": {
47
+ "type": "MANUAL"
48
+ },
49
+ "quality": {
50
+ "type": "MANUAL"
51
+ },
52
+ "size": {
53
+ "type": "MANUAL"
54
+ },
55
+ "count": {
56
+ "type": "MANUAL"
57
+ }
58
+ },
59
+ "errorHandlingOptions": {
60
+ "retryOnFailure": {
61
+ "value": false
62
+ },
63
+ "continueOnFailure": {
64
+ "value": false
65
+ }
66
+ }
67
+ },
68
+ "nextAction": {
69
+ "name": "step_2",
70
+ "skip": false,
71
+ "type": "PIECE",
72
+ "valid": false,
73
+ "settings": {
74
+ "input": {
75
+ "auth": "",
76
+ "taskId": "{{step_1['output']['task_id']}}",
77
+ "traceId": ""
78
+ },
79
+ "pieceName": "@acedatacloud/piece-gpt-image",
80
+ "actionName": "get_task",
81
+ "sampleData": {},
82
+ "pieceVersion": "0.1.1",
83
+ "propertySettings": {
84
+ "taskId": {
85
+ "type": "MANUAL"
86
+ },
87
+ "traceId": {
88
+ "type": "MANUAL"
89
+ }
90
+ },
91
+ "errorHandlingOptions": {
92
+ "retryOnFailure": {
93
+ "value": false
94
+ },
95
+ "continueOnFailure": {
96
+ "value": false
97
+ }
98
+ }
99
+ },
100
+ "displayName": "Get GPT Image task",
101
+ "lastUpdatedDate": "2026-10-11T15:59:36.284Z"
102
+ },
103
+ "displayName": "Create GPT Image task",
104
+ "lastUpdatedDate": "2026-10-11T15:40:03.227Z"
105
+ },
106
+ "type": "PIECE_TRIGGER",
107
+ "settings": {
108
+ "propertySettings": {
109
+ "markdown": {
110
+ "type": "MANUAL"
111
+ }
112
+ },
113
+ "pieceName": "@activepieces/piece-manual-trigger",
114
+ "pieceVersion": "0.0.8",
115
+ "triggerName": "manual_trigger",
116
+ "input": {}
117
+ },
118
+ "lastUpdatedDate": "2026-10-11T15:29:17.786Z"
119
+ },
120
+ "valid": true,
121
+ "schemaVersion": "27",
122
+ "notes": []
123
+ }
124
+ ],
125
+ "status": "PUBLISHED"
126
+ }
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@acedatacloud/piece-gpt-image",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "GPT Image generation and task lookup through Ace Data Cloud for Activepieces",
5
+ "type": "commonjs",
6
+ "main": "./dist/src/index.js",
7
+ "types": "./dist/src/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.zh-CN.md",
11
+ "examples",
12
+ "docs/screenshots"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.json",
16
+ "test": "npm run build && node --test test/*.test.cjs",
17
+ "pack:check": "npm pack --dry-run"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/AceDataCloud/GPTImageActivepieces.git"
22
+ },
23
+ "homepage": "https://github.com/AceDataCloud/GPTImageActivepieces#readme",
24
+ "bugs": "https://github.com/AceDataCloud/GPTImageActivepieces/issues",
25
+ "license": "MIT",
26
+ "dependencies": {
27
+ "@activepieces/pieces-common": "0.12.5",
28
+ "@activepieces/pieces-framework": "0.32.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "24.11.0",
32
+ "typescript": "5.9.3"
33
+ },
34
+ "keywords": [
35
+ "activepieces",
36
+ "piece",
37
+ "acedatacloud",
38
+ "gpt-image",
39
+ "gpt",
40
+ "image"
41
+ ]
42
+ }