Happy Pony API Get an API key →

Single-generation jobs

Pricing: all features

Single generations are plain asynchronous batch calls: create a request, poll its status, fetch the result. There is no agent in the loop, so a job renders exactly the parameters you send, on the same render queues as the website. Each job is charged to your credits when it is created, refunded automatically if it fails or is cancelled, and listed in your History on www.happypony.io.

Endpoints (quick reference)

Base URL: https://api.happypony.io. Every request needs Authorization: Bearer hp_….

Method Path Purpose
POST /api/v1/jobs/text-to-image Create a text-to-image request
POST /api/v1/jobs/text-to-video Create a text-to-video request
POST /api/v1/jobs/image-to-video Create an image-to-video request
POST /api/v1/jobs/reference-to-video Create a reference-to-video request
POST /api/v1/jobs/image-edit Create an image-edit request
POST /api/v1/jobs/multi-angle Create a multi-angle request
POST /api/v1/jobs/face-swap Create a face-swap request
POST /api/v1/jobs/human-portrait Create a human-portrait request
POST /api/v1/jobs/voice-design Create a voice-design request
POST /api/v1/jobs/character-swap Create a character-swap request
POST /api/v1/jobs/background-replace Create a background-replace request
POST /api/v1/jobs/uploads Upload a local image, video or audio file
POST /api/v1/jobs/enrich-prompt Enrich a video prompt without rendering
GET /api/v1/jobs/:requestId/status Check status
GET /api/v1/jobs/:requestId Fetch the result
PUT /api/v1/jobs/:requestId/cancel Cancel a queued request

Request lifecycle

  1. POST the request body to the feature's endpoint. The answer is 202 with a request_id and the status_url, response_url and cancel_url to use next. The credits are taken now.
  2. GET the status_url every 3–10 s until status is COMPLETED, FAILED or CANCELLED. There are no webhooks.
  3. GET the response_url for the result: presigned download URLs plus the parameters the job ran with.
status Meaning
IN_QUEUE Waiting for a worker. queue_position and eta_seconds when known. Can be cancelled.
IN_PROGRESS A worker is rendering it. eta_seconds when known.
COMPLETED Done. Fetch the result.
FAILED It did not finish. error says why; the credits are refunded.
CANCELLED Cancelled by you while queued; the credits are refunded.

Adult content and nsfw. Every create endpoint except uploads and enrich-prompt takes an optional boolean nsfw. The content check runs on every job either way and still refuses anything involving minors (422 content_rejected, reason: "minor").

nsfw What happens
left out (default) The content check looks at the prompt and images and picks the model: explicit content is detected automatically and rendered on the adult-content model, everything else on the general one.
true Always render on the adult-content model. Same as Optimize for NSFW on the website.
false Always render on the general model.

Any other value is 400 invalid_request. On a site that does not allow adult content, nsfw: true is 400 invalid_request and explicit content is refused with 422 content_rejected, reason: "explicit"; leave nsfw out there. Nano Banana models are third-party and ignore nsfw.

Create response

Every create endpoint answers 202 Accepted with the same shape:

{
  "request_id": "48213",
  "type": "text-to-image",
  "status": "IN_QUEUE",
  "credits": 4,
  "status_url": "https://api.happypony.io/api/v1/jobs/48213/status",
  "response_url": "https://api.happypony.io/api/v1/jobs/48213",
  "cancel_url": "https://api.happypony.io/api/v1/jobs/48213/cancel"
}
Field Type Description
request_id string Your handle for the job. Use it in the status, result and cancel paths.
type string text-to-image, text-to-video, image-to-video, reference-to-video, image-edit, multi-angle, face-swap, human-portrait, voice-design or character-swap.
status string Always IN_QUEUE here.
credits integer What the job costs, already taken from your balance. Rarely missing, when the charge could not be read back at once; the status response always has it.
status_url string Poll this for progress.
response_url string Fetch the result here.
cancel_url string PUT here to cancel while IN_QUEUE.

Status response

GET /api/v1/jobs/:requestId/status

curl https://api.happypony.io/api/v1/jobs/48213/status -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48213",
  "type": "text-to-image",
  "status": "IN_QUEUE",
  "created_at": "2026-10-05T10:00:00.000Z",
  "completed_at": null,
  "credits": 4,
  "queue_position": 2,
  "eta_seconds": 20,
  "status_url": "https://api.happypony.io/api/v1/jobs/48213/status",
  "response_url": "https://api.happypony.io/api/v1/jobs/48213",
  "cancel_url": "https://api.happypony.io/api/v1/jobs/48213/cancel"
}
Field Type Description
request_id string As in the create response.
type string The feature.
status string See Request lifecycle.
created_at string ISO 8601 time the job was created.
completed_at string | null ISO 8601 time it finished; null until then.
credits integer What the job cost.
queue_position integer Only while IN_QUEUE, when known. 0 is next.
eta_seconds integer Only while IN_QUEUE or IN_PROGRESS, when known: estimated seconds to completion.
error string Only when FAILED: why.
error_code, reason string Only when FAILED because the content check refused a video job after it was accepted (see Errors): error_code is content_rejected and reason is minor or explicit, as on the 422.
credits_refunded boolean Only when FAILED or CANCELLED: true when the job had a price (those credits are refunded), false for a job that cost nothing.
status_url, response_url, cancel_url string As in the create response.

Result response

GET /api/v1/jobs/:requestId. It answers in any state; the files are there once status is COMPLETED.

curl https://api.happypony.io/api/v1/jobs/48213 -H "Authorization: Bearer $HP_KEY"

All the status fields except queue_position and eta_seconds, plus:

Field Type Description
images object[] Image features. One { "url", "format" } per output image; empty until COMPLETED.
videos object[] text-to-video, image-to-video, reference-to-video and character-swap only, in place of images. One { "url", "format" }; empty until COMPLETED.
audio object[] voice-design only, in place of images. One { "url", "format" } (mp3) per take; empty until COMPLETED.
images[].url / videos[].url string Presigned download link, valid for expires_in seconds (72 hours). Only the link expires, not the file: fetch the job again at any time for a fresh one. null in the rare case the link could not be signed; fetch again.
images[].format / videos[].format string File type: png, jpg, webp, mp4, …
expires_in integer Only when there are files: link lifetime in seconds (259200).
parameters object The settings the job ran with, in the request's field names. Per feature below.
files, dry_run, mask_preview, mask_stats Character swap only, see its result. Background replace has stats in place of mask_stats.

Cancel a request

PUT /api/v1/jobs/:requestId/cancel

curl -X PUT https://api.happypony.io/api/v1/jobs/48213/cancel -H "Authorization: Bearer $HP_KEY"
{ "request_id": "48213", "status": "CANCELLED", "credits_refunded": true }

Only a job still IN_QUEUE can be cancelled; its credits are refunded. Once a worker has picked it up, or the job has already completed or failed, the answer is 409 not_cancellable with the job's status (IN_PROGRESS when the queue refused because rendering had started) and the job finishes normally. Cancelling a job that is already cancelled returns 200 again, with request_id and status only.

Image inputs

Every image field takes a URL:

Images are downloaded and copied into your private storage when the request is created, so a link only has to work until then; the download must finish within 30 s (45 s for audio, 120 s for video). A URL that can't be used is rejected at once with 400 invalid_media (see Errors) and nothing is charged.

image-to-video and reference-to-video are the exception, so that they answer quickly: the create call only checks each URL (its form, and that the host is public: 400 invalid_media with code invalid_url, blocked or unreachable) and the job reads your URL when it renders. Keep the link working until the job has finished. A file that cannot be downloaded, or is of the wrong type or too large, fails the job (FAILED, credits refunded) instead of the create call.

Upload an image

POST /api/v1/jobs/uploads (multipart/form-data)

Form field Required Description
file yes The file: an image (at most 20 MB), or a video (200 MB) or audio clip (30 MB) for reference to video and character swap.
kind no image, video or audio. Inferred from the content type (or the extension) when left out or not one of the three.
curl -X POST https://api.happypony.io/api/v1/jobs/uploads \
  -H "Authorization: Bearer $HP_KEY" -F file=@me.png

Response 201:

{ "url": "https://…signed…", "kind": "image", "expires_in": 259200 }

Pass url in any image field (or a reference field of the same kind) within expires_in seconds (72 hours).

A missing or malformed file part is 400 invalid_request; a file of another type or over its size cap is 400 invalid_media with field: "file" and code bad_type or too_large; 502 media_failed means storage refused it, retry.

Errors

Errors are JSON with an error code and a human-readable message; some add fields:

{
  "error": "invalid_request",
  "message": "duration must be a whole number of seconds from 5 to 15 for short_edge 768 and aspect_ratio 16:9",
  "details": ["duration must be a whole number of seconds from 5 to 15 for short_edge 768 and aspect_ratio 16:9"]
}
Status error When Extra fields
400 invalid_request Bad JSON, unknown field, missing or out-of-range value. Values are never silently replaced by defaults. details: every problem (absent for bad JSON and upload errors)
400 invalid_media An image URL or upload can't be used. field (e.g. image_urls[1]), code: invalid_url, blocked, unreachable, http_error, bad_type, too_large
401 unauthorized Missing, wrong or revoked API key.
402 insufficient_credits Balance below the job's price. required, available
404 not_found No such job, or it is not yours.
409 not_cancellable Cancel on a job that is already running or finished. status
422 content_rejected The content check refused the prompt or images. Nothing is charged. The video endpoints (text-to-video, image-to-video, reference-to-video) run the check after the create call has answered 202: there a refusal is the job ending FAILED with error_code: "content_rejected" and the same reason in its status, and the credits are refunded. reason: minor or explicit
502 gateway_submit_failed The job could not be queued, or no price is configured for it. Nothing is charged (or the charge is refunded); retry.
502 media_failed An image could not be stored. Nothing is charged; retry.

单次生成任务

价格:所有功能

单次生成是标准的异步批处理调用:创建请求、轮询状态、获取结果。不经过 agent,任务严格按你发送的参数渲染,与网站使用同一套渲染队列。每个任务在创建时扣除积分,失败或被取消时自动退还,并会出现在 www.happypony.io 的历史记录中。

接口一览

Base URL:https://api.happypony.io。每个请求都需要 Authorization: Bearer hp_…。

方法 路径 用途
POST /api/v1/jobs/text-to-image 创建文生图请求
POST /api/v1/jobs/text-to-video 创建文生视频请求
POST /api/v1/jobs/image-to-video 创建图生视频请求
POST /api/v1/jobs/reference-to-video 创建参考生视频请求
POST /api/v1/jobs/image-edit 创建图片编辑请求
POST /api/v1/jobs/multi-angle 创建多角度请求
POST /api/v1/jobs/face-swap 创建换脸请求
POST /api/v1/jobs/human-portrait 创建虚拟人像请求
POST /api/v1/jobs/voice-design 创建语音设计请求
POST /api/v1/jobs/character-swap 创建角色替换请求
POST /api/v1/jobs/background-replace 创建换背景请求
POST /api/v1/jobs/uploads 上传本地图片、视频或音频
POST /api/v1/jobs/enrich-prompt 只增强视频提示词,不渲染
GET /api/v1/jobs/:requestId/status 查询状态
GET /api/v1/jobs/:requestId 获取结果
PUT /api/v1/jobs/:requestId/cancel 取消排队中的请求

请求生命周期

  1. 向功能对应的接口 POST 请求体。返回 202,包含 request_id 以及后续使用的 status_url、response_url 和 cancel_url。此时扣除积分。
  2. 每 3–10 秒 GET 一次 status_url,直到 status 变为 COMPLETED、FAILED 或 CANCELLED。暂不支持 webhook。
  3. GET response_url 获取结果:预签名下载链接以及任务实际使用的参数。
status 含义
IN_QUEUE 等待 worker 处理。已知时返回 queue_position 和 eta_seconds。可以取消。
IN_PROGRESS worker 正在渲染。已知时返回 eta_seconds。
COMPLETED 已完成,可获取结果。
FAILED 未能完成。error 说明原因;积分已退还。
CANCELLED 你在排队时取消了它;积分已退还。

成人内容与 nsfw。 除 uploads 和 enrich-prompt 外,所有创建接口都接受可选的布尔字段 nsfw。无论取值如何,每个任务都会经过内容审核,涉及未成年人的内容一律拒绝(422 content_rejected,reason: "minor")。

nsfw 效果
不传(默认) 内容审核根据提示词和图片选择模型:自动识别露骨内容并使用成人内容模型,其他内容使用通用模型。
true 始终使用成人内容模型,等同于网站上的 针对 NSFW 内容优化。
false 始终使用通用模型。

其他取值返回 400 invalid_request。在不允许成人内容的站点上,nsfw: true 返回 400 invalid_request,露骨内容会被拒绝(422 content_rejected,reason: "explicit");在这类站点上请不要传 nsfw。Nano Banana 系列是第三方模型,会忽略 nsfw。

创建响应

所有创建接口都返回 202 Accepted,格式相同:

{
  "request_id": "48213",
  "type": "text-to-image",
  "status": "IN_QUEUE",
  "credits": 4,
  "status_url": "https://api.happypony.io/api/v1/jobs/48213/status",
  "response_url": "https://api.happypony.io/api/v1/jobs/48213",
  "cancel_url": "https://api.happypony.io/api/v1/jobs/48213/cancel"
}
字段 类型 说明
request_id string 任务的标识,用于状态、结果和取消接口的路径。
type string text-to-image、text-to-video、image-to-video、reference-to-video、image-edit、multi-angle、face-swap、human-portrait、voice-design 或 character-swap。
status string 此处始终为 IN_QUEUE。
credits integer 任务价格,已从余额中扣除。极少数情况下(扣费记录暂时读不到时)会缺失;状态响应中总会返回。
status_url string 轮询此地址查看进度。
response_url string 在此获取结果。
cancel_url string 在 IN_QUEUE 时向此地址 PUT 以取消。

状态响应

GET /api/v1/jobs/:requestId/status

curl https://api.happypony.io/api/v1/jobs/48213/status -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48213",
  "type": "text-to-image",
  "status": "IN_QUEUE",
  "created_at": "2026-10-05T10:00:00.000Z",
  "completed_at": null,
  "credits": 4,
  "queue_position": 2,
  "eta_seconds": 20,
  "status_url": "https://api.happypony.io/api/v1/jobs/48213/status",
  "response_url": "https://api.happypony.io/api/v1/jobs/48213",
  "cancel_url": "https://api.happypony.io/api/v1/jobs/48213/cancel"
}
字段 类型 说明
request_id string 与创建响应相同。
type string 功能名称。
status string 见请求生命周期。
created_at string 任务创建时间(ISO 8601)。
completed_at string | null 任务结束时间(ISO 8601);结束前为 null。
credits integer 任务价格。
queue_position integer 仅在 IN_QUEUE 且已知时返回。0 表示下一个。
eta_seconds integer 仅在 IN_QUEUE 或 IN_PROGRESS 且已知时返回:预计完成所需秒数。
error string 仅在 FAILED 时返回:失败原因。
error_code、reason string 仅当视频任务在被接受之后被内容审核拒绝而 FAILED 时返回(见错误):error_code 为 content_rejected,reason 为 minor 或 explicit,与 422 相同。
credits_refunded boolean 仅在 FAILED 或 CANCELLED 时返回:任务有价格(积分已退还)时为 true,零价格任务为 false。
status_url、response_url、cancel_url string 与创建响应相同。

结果响应

GET /api/v1/jobs/:requestId。任何状态下都可调用;status 为 COMPLETED 后才有文件。

curl https://api.happypony.io/api/v1/jobs/48213 -H "Authorization: Bearer $HP_KEY"

包含状态响应中除 queue_position 和 eta_seconds 外的全部字段,另加:

字段 类型 说明
images object[] 图片类功能。每张输出图片一个 { "url", "format" };COMPLETED 之前为空。
videos object[] 仅 text-to-video、image-to-video、reference-to-video 和 character-swap,代替 images。一个 { "url", "format" };COMPLETED 之前为空。
audio object[] 仅 voice-design,代替 images。每个版本一个 { "url", "format" }(mp3);COMPLETED 之前为空。
images[].url / videos[].url string 预签名下载链接,有效期 expires_in 秒(72 小时)。过期的只是链接,文件不会被删除:随时重新获取任务即可得到新链接。极少数签名失败时为 null,重新请求即可。
images[].format / videos[].format string 文件类型:png、jpg、webp、mp4 等。
expires_in integer 仅在有文件时返回:链接有效期,单位秒(259200)。
parameters object 任务实际使用的参数,字段名与请求一致。各功能见下文。
files、dry_run、mask_preview、mask_stats 仅角色替换,见其结果。换背景用 stats 代替 mask_stats。

取消请求

PUT /api/v1/jobs/:requestId/cancel

curl -X PUT https://api.happypony.io/api/v1/jobs/48213/cancel -H "Authorization: Bearer $HP_KEY"
{ "request_id": "48213", "status": "CANCELLED", "credits_refunded": true }

只有仍处于 IN_QUEUE 的任务可以取消,积分会退还。一旦 worker 开始处理,或任务已经完成或失败,会返回 409 not_cancellable 并带上任务的 status(队列因已开始渲染而拒绝时为 IN_PROGRESS),任务会正常结束。对已取消的任务再次取消同样返回 200,但只包含 request_id 和 status。

图片输入

所有图片字段都接受 URL:

图片在创建请求时就会被下载并复制到你的私有存储,因此链接只需在创建前有效;下载须在 30 秒内完成(音频 45 秒,视频 120 秒)。无法使用的 URL 会立即返回 400 invalid_media(见错误),不扣积分。

image-to-video 和 reference-to-video 是例外,这样它们可以更快返回:创建请求只检查每个 URL(格式,以及主机是否为公网地址:400 invalid_media,code 为 invalid_url、blocked 或 unreachable),任务在渲染时直接读取你的 URL。请保证链接在任务完成前一直有效。无法下载、类型不对或过大的文件会让任务失败(FAILED,积分退还),而不是让创建请求失败。

上传图片

POST /api/v1/jobs/uploads(multipart/form-data)

表单字段 必填 说明
file 是 文件:图片(最大 20 MB);用于参考生视频和角色替换时也可以是视频(200 MB)或音频(30 MB)。
kind 否 image、video 或 audio。不填或不是这三个值时根据文件类型(或扩展名)推断。
curl -X POST https://api.happypony.io/api/v1/jobs/uploads \
  -H "Authorization: Bearer $HP_KEY" -F file=@me.png

响应 201:

{ "url": "https://…signed…", "kind": "image", "expires_in": 259200 }

请在 expires_in 秒(72 小时)内将 url 填入任意图片字段(或同类型的参考字段)。

缺少或格式错误的 file 返回 400 invalid_request;类型不支持或超过大小上限返回 400 invalid_media,field 为 "file",code 为 bad_type 或 too_large;502 media_failed 表示存储未能保存,请重试。

错误

错误以 JSON 返回,包含 error 代码和可读的 message;部分错误带有额外字段:

{
  "error": "invalid_request",
  "message": "duration must be a whole number of seconds from 5 to 15 for short_edge 768 and aspect_ratio 16:9",
  "details": ["duration must be a whole number of seconds from 5 to 15 for short_edge 768 and aspect_ratio 16:9"]
}
状态码 error 何时出现 额外字段
400 invalid_request JSON 无效、未知字段、缺少字段或取值超出范围。不会被悄悄替换为默认值。 details:所有问题(JSON 无效或上传错误时没有)
400 invalid_media 图片 URL 或上传的文件无法使用。 field(如 image_urls[1])、code:invalid_url、blocked、unreachable、http_error、bad_type、too_large
401 unauthorized API key 缺失、错误或已吊销。
402 insufficient_credits 余额低于任务价格。 required、available
404 not_found 任务不存在,或不属于你。
409 not_cancellable 取消一个已在运行或已结束的任务。 status
422 content_rejected 提示词或图片被内容审核拒绝。不扣积分。视频接口(text-to-video、image-to-video、reference-to-video)在创建请求返回 202 之后才进行审核:被拒绝时任务以 FAILED 结束,其状态中带有 error_code: "content_rejected" 和相同的 reason,积分退还。 reason:minor 或 explicit
502 gateway_submit_failed 任务未能入队,或没有为它配置价格。不扣积分(已扣的会退还);请重试。
502 media_failed 图片未能保存。不扣积分;请重试。