Blog
AI Image & Video API Guides
Hands-on model tests, production tutorials, prompt techniques, and current API pricing for generative media teams.

Happyhorse Image to Video API: Working curl and Python Examples (hiapi)
Animate one still image into a 720p or 1080p MP4 with `happyhorse-1.1/image-to-video` on the hiapi tasks endpoint. Working curl and Python examples that pass schema validation today, with the actual field names and value ranges the API enforces. Production callback pattern (`callback.url` + `when: "final"`) plus the exact error strings you will hit, so you can match on them in your handler. Guidance on downloading the output URL before its `expireAt` timestamp drops it from temp storage.

When a hiapi /v1/tasks Job Hangs or Times Out: Diagnosis and Retry
Tasks that sit in `pending` or hit `timeout` almost always trace back to four causes: queue backlog, an underlying model failure, oversized inputs, or an unreachable callback URL. Diagnose by polling `GET /v1/tasks/{id}` and reading `status` + `error.code` before you retry anything. Retry with exponential backoff (e.g. 5s → 15s → 45s, max 3 tries) and always create a **new** task — never POST the same idempotency body twice without a key. If a task stays in `pending` for over 90 seconds with no `error`, it's almost always a queue backlog — back off, don't hammer. For callback delivery issues, verify the URL is publicly reachable and returns 2xx within 10s; the hiapi platform does not retry indefinitely.

HappyHorse 1.1 Text-to-Video API via HiAPI: a working curl + Python tutorial
Call Alibaba's HappyHorse 1.1 text-to-video model through HiAPI's unified /v1/tasks endpoint with a working curl request, a Python polling client, and a production-ready callback pattern. The exact input schema (prompt, resolution, aspect_ratio, duration) plus the two non-obvious 400s — audio and seed are not accepted — are spelled out so the first request actually goes through.

HappyHorse 1.1 reference-to-video API: a working curl + Python tutorial
HappyHorse 1.1 R2V turns 1-9 reference images plus a text prompt into a short video over the unified async task endpoint on HiAPI. Point at each reference image inside the prompt as [Image 1], [Image 2] ... so the model knows which face, costume or setting comes from where. Resolution is 720p or 1080p, aspect_ratio is one of 9 fixed values, duration is an integer 3-15 seconds; everything else is rejected. Switch from GET polling to callback.url + callback.when="final" once you ship, and dedupe terminal events by taskId. Catch 401 permission_denied (bad key), 400 INVALID_REQUEST (the message names the bad field), and task-level status="fail" with error.code/error.message.

Happyhorse 1.1 text-to-video API: a working curl and Python tutorial
happyhorse-1.1/text-to-video is served on the unified async /v1/tasks endpoint — submit, get a taskId, then poll or receive a callback. The only required input field is `prompt`. Optional: `aspect_ratio` (9 ratios), `resolution` (720p|1080p), `duration` (3–15 seconds). Fields that look obvious but are rejected today: `size`, `audio`, `seed`, `negative_prompt` — the schema is strict, not loose. Pricing is per second of generated video, so `duration` is the cost lever; `resolution` is not. Use `callback.when="final"` in production to skip polling; only `final` is supported. Keep polling as a fallback sweeper for missed callbacks.

hiapi 'model not available' / 'model not found' errors: causes and fixes
A rejected /v1/tasks request can come from an unavailable model name, an invalid input field, a route mismatch, or a separate authentication problem. HiAPI model names do not share one naming pattern; copy the exact fixed value from the current model documentation. GPT Image 2 text-to-image requests use gpt-image-2/text-to-image, including the modality suffix. A minimal POST /v1/tasks request confirms whether the model and input shape are accepted before you add polling or callbacks. Treat 400 request validation separately from 401 invalid-key and 403 permission errors.

Why your hiapi task callback isn't firing, and how to fix it
If your task reached a terminal status but your endpoint never got a POST, the problem is almost always in the delivery path — not in hiapi. The big 5 causes: unreachable URL, TLS chain issues, your handler returning slow/non-2xx, missing Webhook Sign Key vs. strict verification, and forgetting to include the callback object at submission. Test the callback URL from outside your network first; it must accept an HTTPS POST and return 2xx within the timeout. Generate a Webhook Sign Key under /en/dashboard/settings and align your verification — don't sign with one key and verify with another. Always pair callbacks with polling GET /v1/tasks/{taskId} as the source of truth; the callback is a notification, the GET is the contract.

Runway ML Text-to-Video API in Python: A Working Example and Migrating to hiapi
The async task shape (POST → poll → download output URL) is identical across Runway-style providers and hiapi — write the loop once. Migrating Runway Gen-3 Python code to hiapi wan2.7-video/text-to-video@pro is a two-line change: API_BASE and model id. Use callbacks (callback.url + when:'final') in web apps; polling stays simpler for scripts and cron jobs. output[].url is signed and short-lived — download bytes immediately and serve from your own storage.

OpenAI API Proxy in Python: How to Build One (and When to Use HiAPI Instead)
An OpenAI API proxy is a thin server you put between your app and the model provider — it adds auth, rate limits, logging, and key rotation in one place, so your client code stays clean. A minimal FastAPI proxy is ~60 lines: validate a per-tenant key, forward the request to the upstream, stream the response back. Async (`httpx.AsyncClient`) lets one worker handle thousands of in-flight requests. The catch: this only proxies OpenAI. Add Google Veo, Qwen Image, Seedance, or any non-OpenAI model and you are now rewriting your proxy per provider. When you need many providers behind one endpoint, swap your custom proxy for HiAPI — one Bearer key, one `POST /v1/tasks`, and the provider routing is on our side.

How to Use gpt-image-2 Image-to-Image via the hiapi API
Call gpt-image-2 image-to-image via POST /v1/tasks with model + input.{prompt, image, aspect_ratio, resolution}. Reference image can be an HTTPS URL or a base64 data URL; output[0].url is short-lived — download immediately. Polling works for scripts; prefer callbacks (callback.url + when:final) in real backends and treat the webhook as idempotent. Handle 401 permission_denied, 400 additional properties not allowed, and status: fail separately — they mean different things.
Build with the models you just read about.
Compare image, video, and audio models, then use the same API workflow in production.