
Preview an Imagild API image through your own authenticated media route, or fetch that route and create a temporary browser Blob URL. Do not place the Imagild Bearer key in an img URL. The API's output_url is a private content endpoint, not an anonymous CDN link.
Key Takeaways
- Authorize the application user before your backend retrieves the owned result.
- Keep the upstream key on the server and validate the media response.
- Revoke browser Blob URLs when the preview is replaced or removed.
Decide which component owns access
A browser img element cannot add your Imagild Authorization header by itself. Putting a key in a query string exposes it to logs and copied links rather than solving the access boundary.
Use this path: browser user → authenticated application media endpoint → owned Imagild task content. Your backend validates the user's access to the application's asset record, loads its known task ID, and constructs the upstream URL from the fixed Imagild base.
Do not accept an arbitrary upstream URL from the browser. A task ID is an identifier, not proof that this user owns the corresponding media. The API console describes private downloads and the active-membership requirement.
Choose direct application delivery or a Blob preview
| Technique | Suitable use | Responsibility |
|---|---|---|
img src points to your same-origin authenticated route | Routine inline image delivery | Backend authorization, content validation, private caching policy |
| Fetch your route, then create a Blob URL | Preview with application-controlled loading/error state | The same backend checks plus browser cleanup |
img src contains an upstream key | Avoid | Exposes the credential |
| Publish an approved copy in your own storage | Deliberate sharing workflow | Rights, privacy, access, and retention policy |
A Blob URL is a local browser reference. It is not a durable sharing link or a replacement for archiving an approved asset.
MDN documents createObjectURL as a way to create a URL for a Blob. The corresponding revokeObjectURL guidance explains releasing that reference when it is no longer needed.
Fetch a validated application route
This browser example assumes your application has implemented /app/media/{assetId} with user authentication, ownership checks, and bounded image delivery. That path is illustrative; it is not an Imagild endpoint.
async function showPreview(assetId, imageElement) {
const response = await fetch(
"/app/media/" + encodeURIComponent(assetId),
{ credentials: "same-origin", signal: AbortSignal.timeout(30000) }
);
const type = response.headers.get("content-type")?.split(";")[0];
if (!response.ok ||
!["image/png", "image/jpeg", "image/webp"].includes(type)) {
throw new Error("Image preview unavailable");
}
const url = URL.createObjectURL(await response.blob());
imageElement.src = url;
try {
await imageElement.decode();
} catch (error) {
imageElement.removeAttribute("src");
URL.revokeObjectURL(url);
throw error;
}
return () => {
imageElement.removeAttribute("src");
URL.revokeObjectURL(url);
};
}
Call the returned cleanup when removing this preview. If a component can launch overlapping requests, abort or ignore stale requests and associate cleanup with the correct image instance. Do not let an older response replace a newer selected image.
Blob previews buffer the image in browser memory. For large collections, prefer bounded thumbnails or direct delivery and load only visible items. Avoid retaining every full-resolution Blob in application state.
Explain failures without regenerating
A preview denial does not establish that image generation failed. Check the application's authorization, upstream key, active membership, and task state. Only a successful task should expose an available image result.
Inspect status and Content-Type before displaying bytes. The HTML-instead-of-image diagnostic helps distinguish an access page from a real image.
Keep delivery separate from another paid operation
Current model market prices are 10, 15, and 20 points for 1K, 2K, and 4K image generations. Fixing a preview route should retrieve the existing result rather than silently submit a new paid candidate.
Use the archive guide when an approved image needs durable storage. Private delivery, temporary previews, and deliberate publication are different decisions, and each deserves its own access policy.
Related tasks
- Why Does My Downloaded Image Open as a Web Page?
- How to Archive Imagild Assets Before the 90-Day Storage Window Ends
Sources and scope
- Imagild API console: Private authenticated task content and active membership.
- Imagild model market: New-image tier points, distinct from preview recovery.
- MDN createObjectURL: Creating temporary object URLs from browser Blobs.
- MDN revokeObjectURL: Releasing no-longer-needed object URL references.
Product instructions were checked against the current Imagild API contract and the public model catalog. Code, budgets and acceptance checks are illustrative; this article does not claim a new paid generation test, an uptime measurement, a search-volume study or a ranking of AI citations.
Prepared by Imagild Editorial, the company editorial team responsible for these guides. AI assisted research and drafting. This is documentation-based guidance with proposed examples, not a claim of hands-on testing or an independent product review. Report a correction.
Cover: Original Imagild product screenshot captured on 28 October 2026; model availability and prices may change. This image is not an API response or a performance benchmark.