
An “image” download can contain JSON because you requested the task-status endpoint, received an API error, or saved a response without checking its type. Inspect HTTP status and Content-Type before treating bytes as media. A filename such as result.png does not convert JSON into an image.
Key Takeaways
GET /tasks/{id}returns task JSON; successful content comes from/tasks/{id}/content.- Check status, media type, a bounded file signature, and decoding before publishing.
- Keep diagnostic responses separate from approved binary assets.
Find which response you saved
| Observation | Likely investigation |
|---|---|
| HTTP 200 with task fields such as status and usage | You saved the task-status response |
| JSON error with 401 | Check credential validity and header |
| JSON error with membership-required 403 | Restore current account eligibility |
| JSON error from content before completion | Recheck the saved task outcome |
| HTTP success with an image type | Validate the actual bytes before approval |
| HTML body | Check the address, proxy, or access page |
The API console separates status and content resources. Poll the saved task until data.status is succeeded, then retrieve its private result using Bearer authentication and active membership.
Do not diagnose a successfully fetched JSON task record as corrupt model output. The endpoint did exactly what a status resource should do.
Validate the response envelope first
MDN's Content-Type reference explains the response's declared media type. Use it with the HTTP status, not as a substitute for byte inspection.
For current image output, expect an allowed image type such as PNG, JPEG, or WebP. Reject application/json and text/html from the image-publication path. Parse an error only through a controlled diagnostic path that retains sanitized error code and request ID.
Avoid logging the entire JSON or HTML body by default. It may contain unnecessary private context, and a shared screenshot must never expose Authorization headers.
Peek at a bounded signature
A worker can inspect the beginning of the response before streaming the rest into a temporary, unpublished file. This JavaScript example checks a PNG signature only; it does not validate every supported format.
function hasPngSignature(head) {
const expected = [137, 80, 78, 71, 13, 10, 26, 10];
return head.length >= expected.length &&
expected.every((value, index) => head[index] === value);
}
console.log(hasPngSignature(
new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10])
)); // true
console.log(hasPngSignature(new TextEncoder().encode('{"error":{}}')));
// false
The signature is defined by the W3C PNG specification. A matching prefix is a preliminary check, not proof that the complete image is intact or safe to publish. Use appropriate format handling for JPEG and WebP rather than rejecting them because they are not PNG.
Decode before promoting the file
Apply your application's byte and pixel limits, then inspect the full downloaded file with a maintained image decoder. Pillow's Image documentation describes image identification, dimensions, and loading.
A useful acceptance record contains task ID, requested model and tier, HTTP status, declared type, detected format, byte count, measured dimensions, and review decision. If decoding fails, keep the result quarantined and investigate transfer completeness before requesting another generation.
Do not publish a partial or error response under a media extension simply because a downstream system requires that extension.
Correct delivery without repeating creative spend
Current model market image generations use 10 points at 1K, 15 at 2K, and 20 at 4K. A wrong download route or expired access condition is not automatically a reason for another paid candidate.
Use the existing HTML-download diagnostic for page responses and the browser download behavior guide for navigation-versus-save problems. Preserve the successful task and repair the response-handling stage first.
Related tasks
- Why Does My Downloaded Image Open as a Web Page?
- Why Does My Download Button Open the Photo in a New Browser Page Instead of Saving It?
Sources and scope
- Imagild API console: Status JSON and authenticated content are separate routes.
- Imagild model market: Current point costs for new creative operations.
- MDN Content-Type: Media type declaration is a response header, distinct from filename or full decoding.
- W3C PNG specification: The exact eight-byte PNG signature used in the preliminary example.
- Pillow Image reference: Image identification, dimensions and loading for decoder-level inspection.
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.