The Four Hard Boundaries That Keep an AI Image Pipeline From Falling Apart
Most AI image demos stop at a single fetch. A pipeline that actually ships needs verifiable prompt quality checks, hard cost caps, and a security proxy that treats every provider URL as hostile — and the architecture must let you test the decision graph without spinning up a database.
Calling an image API is the easy part. The real work sits in the four boundaries around it. AI Mind v0.4.12 uses a Zod schema with `.strict()` to turn user descriptions into a structured ImageBrief that separates explicit requirements from system defaults, so downstream steps never confuse the two. A prompt inspection node then cross-references the generated prompt against that brief using a fixed taxonomy of issue codes and severity levels — the LLM provides a judgment, but the code owns every routing decision.
Hard counters enforce the limits: at most one image generation, one prompt revision, and five planning calls. There is no "try again" loop, because every extra call costs real money and the system prefers to generate nothing over generating uncontrollably. The final boundary is a security proxy that fetches the provider URL server-side through six checks — URL structure, ownership, run status, HTTP response headers, streaming size enforcement, and magic bytes — so the frontend never touches an untrusted URL.
The pipeline explicitly does not support editing, inpainting, or multi-image generation. Those are separate capabilities, not extra parameters, and the system returns a clear unsupported-capability error rather than silently degrading.
Hard-coding limits like maxImageGenerations=1 is a cost-control strategy disguised as an engineering constraint. The system prefers to generate nothing over generating uncontrollably, which is the opposite of how most AI demos are built.
The `assumptions` field in ImageBrief is a clever piece of factual bookkeeping: it prevents the inspection step from flagging system defaults as missing user requirements, which would otherwise create false-positive blocks.
Using `"Return no reasoning"` in the inspection prompt is a security and simplicity win — it keeps internal execution prompts out of user-facing output and removes noise from the decision pipeline.
The explicit Non-goals (no editing, no multi-image, no HITL) are as important as the features. They prevent scope creep from turning a text-to-image pipeline into an unmaintainable Swiss Army knife.
Refusing to restore images on page refresh is a deliberate product decision, not a bug. It avoids building a persistence layer for temporary artifacts and forces users to download what they want to keep.