Text-to-image models are great at generating a single compelling portrait but terrible at maintaining that identity across a series. The problem isn't the model's capability; it's the workflow. Relying on textual descriptions for each new image causes 'character drift,' where glasses change shape, hair color shifts, and the subject becomes unrecognizable by the tenth post. The solution is procedural: generate candidates, save one as a persistent asset, and force every subsequent edit to reference that saved URI rather than a new text prompt.

The Reference-First Pipeline

A recent DEV.to tutorial demonstrates this approach using SpicyAPI and plain Node.js, requiring no SDKs. The workflow generates four initial head-and-shoulders portraits using bytedance/seedream-5.0-pro/text-to-image. Once a user selects a preferred face, the script saves that specific output to a persistent asset library, returning a stable URI like spicy://a/ast_.... This URI becomes the anchor for all future generations.

Anchoring Edits to Saved Assets

For the photo set, the script calls an image edit model (bytedance/seedream-5.0-pro/edit) with the saved reference URI in the image_urls field. The prompt then only describes the scene or action, explicitly instructing the model to keep the face, hair, and accessories exactly the same. This prevents the 'chaining error' where each new image is based on the previous output, allowing small deviations to accumulate. Instead, every shot is a direct derivative of the original, immutable reference.

Cost and Technical Implementation

The tutorial emphasizes practical infrastructure details. Output URLs from standard generation tasks expire after 20 minutes, making them unsuitable for long-term character consistency. The asset library solves this by storing files permanently, though it requires unlocking via account top-ups. The implementation uses idempotency keys to prevent duplicate saves and billing on retries. The total cost for four candidates, three scene photos, and a five-second video clip using alibaba/wan-3.0/image-to-video comes to approximately $0.70, a negligible price for consistent branding.

Key Takeaways

  • Do not chain generations; always point back to the original saved reference URI.
  • Use persistent asset URIs instead of expiring signed output URLs for long-term projects.
  • Keep prompts simple by naming what must stay the same rather than re-describing the entire character.
  • Implement idempotency keys in your API calls to avoid double-billing on network retries.

The Bottom Line

Stop fighting the model’s memory loss with clever prompts; fix the pipeline by anchoring every generation to a persistent, immutable reference URI.

Sources

https://dev.to/spicyapi_ai/keep-an-ai-character-consistent-through-an-api-one-saved-reference-many-shots-306b