Text to image
Pricing: Text to image
One prompt in, one image out. The same job as a generation on www.happypony.io/text-to-image.
POST https://api.happypony.io/api/v1/jobs/text-to-image
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/text-to-image with Content-Type: application/json.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
prompt |
string | yes | — | What to draw. |
aspect_ratio |
string | no | "1:1" |
"16:9", "4:3", "1:1", "3:4" or "9:16". |
short_edge |
integer | no | 1080 |
1080, 1440 or 2048: the shorter side in pixels (16:9 at 1080 is 1920×1080, at 1440 2560×1440). An image is at most 2048×2048 pixels in all, so 2048 is 2048×2048 at 1:1, 2336×1760 at 4:3 and 2720×1536 at 16:9. With minimax-h3-image: 2048 (the default; the same sizes) or 4096, which is 16 megapixels: 4096×4096 at 1:1, 4736×3552 at 4:3, 5472×3072 at 16:9. |
model |
string | no | "z-image-text-to-image" |
"z-image-text-to-image" or "minimax-h3-image" (MiniMax-H3-Image: finer detail and legible text, up to 16 megapixels; slower). A prompt under 400 characters is expanded into a detailed description before it is drawn, in either model. |
Request body:
{
"prompt": "A red fox in fresh snow at dawn, telephoto",
"aspect_ratio": "16:9",
"short_edge": 1080
}
curl -X POST https://api.happypony.io/api/v1/jobs/text-to-image \
-H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
-d '{"prompt": "A red fox in fresh snow at dawn, telephoto", "aspect_ratio": "16:9", "short_edge": 1080}'
Response 202 (fields: Create response):
{
"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"
}
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/48213/status -H "Authorization: Bearer $HP_KEY"
{
"request_id": "48213",
"type": "text-to-image",
"status": "IN_PROGRESS",
"created_at": "2026-10-05T10:00:00.000Z",
"completed_at": null,
"credits": 4,
"eta_seconds": 12,
"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/48213 -H "Authorization: Bearer $HP_KEY"
{
"request_id": "48213",
"type": "text-to-image",
"status": "COMPLETED",
"created_at": "2026-10-05T10:00:00.000Z",
"completed_at": "2026-10-05T10:00:31.000Z",
"credits": 4,
"images": [{ "url": "https://…signed…", "format": "png" }],
"expires_in": 259200,
"parameters": { "prompt": "A red fox in fresh snow at dawn, telephoto", "model": "z-image-text-to-image",
"aspect_ratio": "16:9", "short_edge": 1080 },
"status_url": "…", "response_url": "…", "cancel_url": "…"
}
| Field | Type | Description |
|---|---|---|
images |
object[] | One 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_… ./t2i.sh
JOB=$(curl -s -X POST https://api.happypony.io/api/v1/jobs/text-to-image \
-H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
-d '{"prompt": "A red fox in fresh snow at dawn, telephoto", "aspect_ratio": "16:9", "short_edge": 1080}')
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 "image-$((++i)).$FORMAT" "$URL"; done
Python
# pip install requests | HP_KEY=hp_… python t2i.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}/text-to-image", headers=H, json={
"prompt": "A red fox in fresh snow at dawn, telephoto",
"aspect_ratio": "16:9",
"short_edge": 1080,
}).json()
print("job", job["request_id"], "costs", job["credits"], "credits")
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"image-{job['request_id']}-{i}.{image['format']}", "wb") as f:
f.write(requests.get(image["url"]).content)
TypeScript
// Node 18+ (global fetch). HP_KEY=hp_… npx tsx t2i.ts
import { writeFile } from 'node:fs/promises';
const BASE = 'https://api.happypony.io/api/v1/jobs';
const H = { Authorization: `Bearer ${process.env.HP_KEY}`, 'Content-Type': 'application/json' };
const job = await (await fetch(`${BASE}/text-to-image`, {
method: 'POST', headers: H,
body: JSON.stringify({ prompt: 'A red fox in fresh snow at dawn, telephoto', aspect_ratio: '16:9', short_edge: 1080 }),
})).json();
let status = 'IN_QUEUE';
while (status === 'IN_QUEUE' || status === 'IN_PROGRESS') {
await new Promise((r) => setTimeout(r, 5000));
status = (await (await fetch(job.status_url, { headers: H })).json()).status;
}
const result = await (await fetch(job.response_url, { headers: H })).json();
if (result.status !== 'COMPLETED') throw new Error(`${result.status}: ${result.error ?? ''}`);
for (const [i, image] of result.images.entries()) {
await writeFile(`image-${job.request_id}-${i}.${image.format}`, Buffer.from(await (await fetch(image.url)).arrayBuffer()));
}