Happy Pony API Get an API key →

Image edit

Pricing: Image edit

One to three images and an instruction in, one edited image out. The same job as a generation on www.happypony.io/image-edit.

POST https://api.happypony.io/api/v1/jobs/image-edit
GET  https://api.happypony.io/api/v1/jobs/:requestId/status
GET  https://api.happypony.io/api/v1/jobs/:requestId
PUT  https://api.happypony.io/api/v1/jobs/:requestId/cancel

1) Create a request

POST https://api.happypony.io/api/v1/jobs/image-edit with Content-Type: application/json.

Field Type Required Default Description
prompt string yes — The edit. Refer to the inputs as image 1, 2 and 3. With minimax-h3-image-edit, write them as <Picture 1>, <Picture 2>, <Picture 3> and say what to keep ("Put the cat from <Picture 1> on the sofa in <Picture 2>; keep the room unchanged"); the prompt is used exactly as written.
image_urls string[] yes — 1 to 3 images, in order. See Image inputs.
model string no "qwen-image-edit" "qwen-image-edit", "nano-banana-edit", "nano-banana-2-edit" or "minimax-h3-image-edit" (MiniMax-H3-Image: up to 16 megapixels).
aspect_ratio string no "1:1" "auto", "16:9", "4:3", "1:1", "3:4" or "9:16". With qwen-image-edit, "auto" gives a square; the nano-banana models follow the input.
short_edge integer no 1080 1080, 1440 or 2048. With qwen-image-edit, the shorter side in pixels, sized as for text to image (16:9 at 1080 is 1920×1080; 2048 is 2048×2048 pixels in all, 2720×1536 at 16:9); the nano-banana models size the output themselves. With minimax-h3-image-edit: 2048 (the default) or 4096 (16 megapixels: 4096×4096 at 1:1, 5472×3072 at 16:9), and aspect_ratio "auto" means 1:1.

Request body:

{
  "prompt": "Put her on a rainy Tokyo street at night; keep her face, hair and clothes",
  "image_urls": ["https://resource.pipelet.net/images/test/selfie3.png"],
  "model": "qwen-image-edit",
  "aspect_ratio": "3:4",
  "short_edge": 1080
}
curl -X POST https://api.happypony.io/api/v1/jobs/image-edit \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"prompt": "Put her on a rainy Tokyo street at night; keep her face, hair and clothes", "image_urls": ["https://resource.pipelet.net/images/test/selfie3.png"], "model": "qwen-image-edit", "aspect_ratio": "3:4", "short_edge": 1080}'

Response 202 (fields: Create response):

{
  "request_id": "48301",
  "type": "image-edit",
  "status": "IN_QUEUE",
  "credits": 6,
  "status_url": "https://api.happypony.io/api/v1/jobs/48301/status",
  "response_url": "https://api.happypony.io/api/v1/jobs/48301",
  "cancel_url": "https://api.happypony.io/api/v1/jobs/48301/cancel"
}

2) Poll for status

Poll the status_url until status is COMPLETED, FAILED or CANCELLED (fields: Status response). A queued job can be cancelled with PUT on the cancel_url (Cancel a request).

curl https://api.happypony.io/api/v1/jobs/48301/status -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48301",
  "type": "image-edit",
  "status": "IN_PROGRESS",
  "created_at": "2026-10-05T10:00:00.000Z",
  "completed_at": null,
  "credits": 6,
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}

3) Fetch the result

When status is COMPLETED, fetch the response_url (common fields: Result response):

curl https://api.happypony.io/api/v1/jobs/48301 -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48301",
  "type": "image-edit",
  "status": "COMPLETED",
  "created_at": "2026-10-05T10:00:00.000Z",
  "completed_at": "2026-10-05T10:00:48.000Z",
  "credits": 6,
  "images": [{ "url": "https://…signed…", "format": "png" }],
  "expires_in": 259200,
  "parameters": { "prompt": "Put her on a rainy Tokyo street at night; keep her face, hair and clothes",
                  "model": "qwen-image-edit", "aspect_ratio": "3:4", "short_edge": 1080 },
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}
Field Type Description
images object[] The edited image.
parameters object prompt, model, aspect_ratio, short_edge.

Full example

Create, poll until done, download:

curl (bash)

# Needs curl and jq. Usage: HP_KEY=hp_… ./edit.sh
JOB=$(curl -s -X POST https://api.happypony.io/api/v1/jobs/image-edit \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"prompt": "Put her on a rainy Tokyo street at night; keep her face, hair and clothes",
       "image_urls": ["https://resource.pipelet.net/images/test/selfie3.png"]}')
echo "$JOB" | jq .
STATUS_URL=$(echo "$JOB" | jq -r .status_url)
RESPONSE_URL=$(echo "$JOB" | jq -r .response_url)

while :; do
  STATUS=$(curl -s "$STATUS_URL" -H "Authorization: Bearer $HP_KEY" | jq -r .status)
  [ "$STATUS" = IN_QUEUE ] || [ "$STATUS" = IN_PROGRESS ] || break
  sleep 5
done
echo "$STATUS"
curl -s "$RESPONSE_URL" -H "Authorization: Bearer $HP_KEY" | jq -r '.images[] | "\(.format) \(.url)"' |
  while read -r FORMAT URL; do curl -s -o "edit-$((++i)).$FORMAT" "$URL"; done

Python

# pip install requests   |   HP_KEY=hp_… python edit.py
import os, time, requests

BASE = "https://api.happypony.io/api/v1/jobs"
H = {"Authorization": f"Bearer {os.environ['HP_KEY']}"}

job = requests.post(f"{BASE}/image-edit", headers=H, json={
    "prompt": "Dress the woman in image 1 in the jacket from image 2",
    "image_urls": [
        "https://resource.pipelet.net/images/test/selfie3.png",
        # a local file: requests.post(f"{BASE}/uploads", headers=H, files={"file": open("jacket.png", "rb")}).json()["url"]
        "https://example.com/jacket.png",
    ],
    "model": "nano-banana-edit",
    "aspect_ratio": "auto",
})
job.raise_for_status()
job = job.json()

while (s := requests.get(job["status_url"], headers=H).json())["status"] in ("IN_QUEUE", "IN_PROGRESS"):
    time.sleep(5)
result = requests.get(job["response_url"], headers=H).json()
if result["status"] != "COMPLETED":
    raise SystemExit(f"{result['status']}: {result.get('error', '')}")
for i, image in enumerate(result["images"]):
    with open(f"edit-{job['request_id']}-{i}.{image['format']}", "wb") as f:
        f.write(requests.get(image["url"]).content)

图片编辑

价格:图片编辑

传入 1 到 3 张图片和一条修改指令,输出一张编辑后的图片。与在 www.happypony.io/image-edit 上生成的任务完全相同。

POST https://api.happypony.io/api/v1/jobs/image-edit
GET  https://api.happypony.io/api/v1/jobs/:requestId/status
GET  https://api.happypony.io/api/v1/jobs/:requestId
PUT  https://api.happypony.io/api/v1/jobs/:requestId/cancel

1) 创建请求

POST https://api.happypony.io/api/v1/jobs/image-edit,Content-Type: application/json。

字段 类型 必填 默认值 说明
prompt string 是 — 要做的修改。用 image 1、2、3 指代输入图片。使用 minimax-h3-image-edit 时请写成 <Picture 1>、<Picture 2>、<Picture 3>,并说明需要保留的内容(例如 "Put the cat from <Picture 1> on the sofa in <Picture 2>; keep the room unchanged");提示词会原样使用。
image_urls string[] 是 — 1 到 3 张图片,按顺序排列。见图片输入。
model string 否 "qwen-image-edit" "qwen-image-edit"、"nano-banana-edit"、"nano-banana-2-edit" 或 "minimax-h3-image-edit"(MiniMax-H3-Image:最高 1600 万像素)。
aspect_ratio string 否 "1:1" "auto"、"16:9"、"4:3"、"1:1"、"3:4" 或 "9:16"。使用 qwen-image-edit 时 "auto" 输出正方形;nano-banana 模型会跟随输入图片。
short_edge integer 否 1080 1080、1440 或 2048。使用 qwen-image-edit 时为短边像素数,尺寸规则与文生图相同(16:9 配 1080 即 1920×1080;2048 为总像素 2048×2048,16:9 下为 2720×1536);nano-banana 模型自行决定尺寸。使用 minimax-h3-image-edit 时:2048(默认)或 4096(1600 万像素:1:1 下为 4096×4096,16:9 下为 5472×3072),aspect_ratio 为 "auto" 时按 1:1 处理。

请求体:

{
  "prompt": "Put her on a rainy Tokyo street at night; keep her face, hair and clothes",
  "image_urls": ["https://resource.pipelet.net/images/test/selfie3.png"],
  "model": "qwen-image-edit",
  "aspect_ratio": "3:4",
  "short_edge": 1080
}
curl -X POST https://api.happypony.io/api/v1/jobs/image-edit \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"prompt": "Put her on a rainy Tokyo street at night; keep her face, hair and clothes", "image_urls": ["https://resource.pipelet.net/images/test/selfie3.png"], "model": "qwen-image-edit", "aspect_ratio": "3:4", "short_edge": 1080}'

响应 202(字段见创建响应):

{
  "request_id": "48301",
  "type": "image-edit",
  "status": "IN_QUEUE",
  "credits": 6,
  "status_url": "https://api.happypony.io/api/v1/jobs/48301/status",
  "response_url": "https://api.happypony.io/api/v1/jobs/48301",
  "cancel_url": "https://api.happypony.io/api/v1/jobs/48301/cancel"
}

2) 轮询状态

轮询 status_url,直到 status 变为 COMPLETED、FAILED 或 CANCELLED(字段见状态响应)。排队中的任务可以向 cancel_url 发送 PUT 取消(见取消请求)。

curl https://api.happypony.io/api/v1/jobs/48301/status -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48301",
  "type": "image-edit",
  "status": "IN_PROGRESS",
  "created_at": "2026-10-05T10:00:00.000Z",
  "completed_at": null,
  "credits": 6,
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}

3) 获取结果

status 为 COMPLETED 后,获取 response_url(通用字段见结果响应):

curl https://api.happypony.io/api/v1/jobs/48301 -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48301",
  "type": "image-edit",
  "status": "COMPLETED",
  "created_at": "2026-10-05T10:00:00.000Z",
  "completed_at": "2026-10-05T10:00:48.000Z",
  "credits": 6,
  "images": [{ "url": "https://…signed…", "format": "png" }],
  "expires_in": 259200,
  "parameters": { "prompt": "Put her on a rainy Tokyo street at night; keep her face, hair and clothes",
                  "model": "qwen-image-edit", "aspect_ratio": "3:4", "short_edge": 1080 },
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}
字段 类型 说明
images object[] 编辑后的图片。
parameters object prompt、model、aspect_ratio、short_edge。

完整示例

创建、轮询直到完成、下载:

curl (bash)

# Needs curl and jq. Usage: HP_KEY=hp_… ./edit.sh
JOB=$(curl -s -X POST https://api.happypony.io/api/v1/jobs/image-edit \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"prompt": "Put her on a rainy Tokyo street at night; keep her face, hair and clothes",
       "image_urls": ["https://resource.pipelet.net/images/test/selfie3.png"]}')
echo "$JOB" | jq .
STATUS_URL=$(echo "$JOB" | jq -r .status_url)
RESPONSE_URL=$(echo "$JOB" | jq -r .response_url)

while :; do
  STATUS=$(curl -s "$STATUS_URL" -H "Authorization: Bearer $HP_KEY" | jq -r .status)
  [ "$STATUS" = IN_QUEUE ] || [ "$STATUS" = IN_PROGRESS ] || break
  sleep 5
done
echo "$STATUS"
curl -s "$RESPONSE_URL" -H "Authorization: Bearer $HP_KEY" | jq -r '.images[] | "\(.format) \(.url)"' |
  while read -r FORMAT URL; do curl -s -o "edit-$((++i)).$FORMAT" "$URL"; done

Python

# pip install requests   |   HP_KEY=hp_… python edit.py
import os, time, requests

BASE = "https://api.happypony.io/api/v1/jobs"
H = {"Authorization": f"Bearer {os.environ['HP_KEY']}"}

job = requests.post(f"{BASE}/image-edit", headers=H, json={
    "prompt": "Dress the woman in image 1 in the jacket from image 2",
    "image_urls": [
        "https://resource.pipelet.net/images/test/selfie3.png",
        # a local file: requests.post(f"{BASE}/uploads", headers=H, files={"file": open("jacket.png", "rb")}).json()["url"]
        "https://example.com/jacket.png",
    ],
    "model": "nano-banana-edit",
    "aspect_ratio": "auto",
})
job.raise_for_status()
job = job.json()

while (s := requests.get(job["status_url"], headers=H).json())["status"] in ("IN_QUEUE", "IN_PROGRESS"):
    time.sleep(5)
result = requests.get(job["response_url"], headers=H).json()
if result["status"] != "COMPLETED":
    raise SystemExit(f"{result['status']}: {result.get('error', '')}")
for i, image in enumerate(result["images"]):
    with open(f"edit-{job['request_id']}-{i}.{image['format']}", "wb") as f:
        f.write(requests.get(image["url"]).content)