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

How to Call Multiple Image Models with One API Key
Use one server-side API key for model testing, billing visibility, and production routing. Route model choice through the request body instead of hard-coding separate provider clients. Start prompt iteration on a lower-cost model, then move final assets to a higher-fidelity image model. Use callbacks or task polling depending on your production volume.

The AI Image Prompt Library: 10 Production-Ready Prompts by Use Case
Ten prompts organized by the five use cases that account for most production image work: e-commerce hero shots, social covers, avatars, product display, and editorial illustration. Every prompt is paired with the hiapi model and aspect ratio it was tested at, plus a one-paragraph explanation of why the wording works — so the prompts can be adapted rather than just copied. Pick the model by job: qwen-image-2.0 ($0.025) for volume stylized work, gpt-image-2 ($0.03) for text-heavy layouts, Nano-Banana ($0.05) for portrait consistency, flux-1.1-pro ($0.05) for photorealism.

Adding AI Image Generation to a Next.js App With the hiapi API
Image generation takes 60–120 seconds — too long for a single client request, so the app must split the work across a route handler that creates a task and a polling endpoint that surfaces progress without holding a serverless invocation. Calling hiapi directly from a React component leaks the API key to the browser. A Next.js route handler keeps the key on the server and gives you one auditable place to rate-limit and validate prompts. Output URLs returned by hiapi are signed and short-lived. Apps that store them directly will serve 404s on refresh — mirror every successful result to R2 (or S3 / Supabase Storage) before persisting. Cumulative Layout Shift on AI-image apps is fixed by reserving the result container's aspect ratio with CSS and matching it to the ratio sent to hiapi.

Consistent Characters with Nano-Banana on hiapi: A Working Workflow for Storyboards and E-Commerce
Three Nano-Banana models on hiapi all tagged for character consistency: Nano-Banana ($0.05 flat), Nano-Banana-2 ($0.085 / $0.076 / $0.114 across 1K/2K/4K — 2K is cheaper than 1K), and Nano-Banana-Pro ($0.17 at 1K/2K, $0.30 at 4K). The technique is a character bible — a dense, repeatable, deterministic prompt prefix that anchors face geometry, skin/hair markers, wardrobe, and vibe across all renders. No reference image, no fine-tune, no LoRA. Storyboard demo: one engineer character ('Mira') across cover, model sheet, warm-tungsten workshop, and cold-overcast rooftop. Same beanie, same toolbelt, same beauty mark stays on the right cheek through both scenes. E-commerce demo: one fashion model ('Aria') in three full-body look-book shots — frontal hero, three-quarter angle, then a wardrobe swap to a camel double-breasted overcoat. Face, hair parting, beauty mark, and gold studs all hold across renders. Flat Nano-Banana rejects the resolution field with a 400 — only set it for Pro and -2. Output URLs have an expireAt; download bytes immediately rather than hot-linking. Total cost for all 8 images in the article: $0.52 (7 × $0.05 Nano-Banana + 1 × $0.17 Nano-Banana-Pro hero).

hiapi Image and Video Generation APIs: The Complete Platform Guide
hiapi is an image and video generation API gateway: one Bearer-auth endpoint fronts FLUX 1.1 Pro, Nano-Banana, GPT-Image-2, Qwen-Image, Wan2.7, Seedance, and HappyHorse. Pricing is flat per task — $0.02 for gpt-image-2-beta, $0.05 for Nano-Banana or flux-1.1-pro, up to $0.823 for a 1080p Seedance clip. No token billing, no surge. All generation runs through the async POST /v1/tasks endpoint. Same shape for text-to-image, image-to-image, text-to-video, image-to-video. Most image models accept input.prompt + input.aspect_ratio. qwen-image-2.0 uses a DashScope-style nested schema with literal pixel sizes — keep a model→payload adapter map. Four sample images in this post — cover illustration, photoreal portrait, CJK calligraphy signboard, layout poster — were all rendered through hiapi for a total of $0.155.

FLUX 1.1 Pro on hiapi: Capabilities, Pricing, and a Working Code Example
FLUX 1.1 Pro is on hiapi at $0.05 per image, flat across aspect ratios — no resolution multiplier. It is served on the async /v1/tasks endpoint, not /v1/chat/completions; use `aspect_ratio` not `size`. Photoreal portraits, product flat-lays, and short headline text render reliably; unprompted text on objects is still hallucinated. Older FLUX.1 Dev and the original FLUX Pro are not on hiapi — the catalogue carries only the 1.1 Pro flagship.

Inside Codex's Agent Loop: Lessons from Datadog and Sora's 28-Day Android Launch
The Codex agent loop is a simple control flow — prepare prompt, model inference, optional tool call, append result, repeat — that terminates when the model emits a normal assistant message. Three implementation details make it production-grade: prefix caching on the Responses API, tool-call results that live inside the conversation, and termination detected from output shape (not a turn counter). Datadog uses the loop for system-level code review on every PR across 1,000+ engineers; its incident-replay harness showed Codex catching ~22% of historical incident-related issues human reviewers had missed. OpenAI shipped Sora for Android in 28 days with four engineers, ~85% Codex-generated code, and a 99.9% crash-free rate — by scaffolding with exemplars and AGENTS.md, not by prompting 'go build it.' The same agent-loop architecture transfers to media-generation agents built on hiapi: stable system prompt + tool-call accumulation + critique-based termination, wrapping image and video endpoints.

GPT Image 2 Multi-Turn Editing and Style Consistency: A hiapi Capabilities Tour
gpt-image-2 (text-to-image) and gpt-image-2-image-to-image are two halves of the same workflow — first draft and surgical editor — both priced at $0.03 per call at 1K on hiapi. The two patterns that move the needle: a verbatim character bible reused across scenes for series consistency, and a first-render-then-edit two-call flow for any job that must look like an extension of an existing brand asset. Both variants speak the same async task API — POST /v1/tasks, then poll the task ID — the only difference is that the editing variant adds an input_urls array of reference images.

Does GPT Image 2 Really Nail Text? We Stress-Tested Signage, Posters and Labels
Across 24 text-heavy generations — including English headlines, CJK calligraphy, multi-string infographics, embedded brand blocks, currency, and dense UI mockups — every primary string rendered correctly. GPT Image 2 will sometimes add contextually appropriate text you didn't ask for (brand monograms, founding-year badges, scent names). Useful most of the time, undesired occasionally. The remaining ~1% error rate at production scale shows up on the smallest text — sub-12pt captions, dense legal copy, ingredient lists. Always proof at 100% zoom before shipping. If text matters, lock it in straight quotes. Smart quotes get rendered as smart quotes. Special characters (em-dashes, ampersands) work; single-character substitutions are the most common failure mode when they occur.

GPT Image 2 E-commerce Workflow: From Product Spec to Listing Set
Write one fixed product specification, then vary only the shot instructions to build a more consistent listing set. The workflow covers a white-background packshot, alternate angle, detail, lifestyle scene, and packaging with verified on-pack text. Three retained outputs include their exact prompts, aspect ratios, task IDs, and recorded task costs. A reusable Python script submits a complete shot list without repeating generic task-polling documentation.
Build with the models you just read about.
Compare image, video, and audio models, then use the same API workflow in production.