
Put an Imagild API key in the Authorization header of a backend request, never in a media URL's query string. A key-bearing URL can be copied into application logs, analytics or shared screenshots. The returned task output_url is an authenticated API route, not a public link that becomes safe by appending a credential.
Key Takeaways
- Use
Authorization: Bearer …for API requests, including result downloads. - Serve browser media through your own authorized delivery route when necessary.
- A URL without a visible token still needs resource authorization.
Recognize the tempting workaround
A browser image or video tag does not provide a general mechanism for attaching your server's Bearer key. Appending ?api_key=SECRET to the source URL is therefore a tempting shortcut. It is not the Imagild authentication contract and can expose the credential.
The API console shows header-based authentication. OWASP's REST guidance explicitly advises against credentials in URLs because URLs can be captured in server logs.
Changing the query parameter name, encoding its value or hiding it behind a short link does not turn the credential into a secret.
Choose a delivery path for the actual client
| Consumer | Appropriate application pattern |
|---|---|
| Backend worker | Send the Bearer header directly to the fixed API route |
| Logged-in browser | Request an application-owned media route that checks its session |
| Public campaign page | Publish a reviewed derivative deliberately through your own delivery system |
| Support report | Share sanitized task context, not a credential-bearing URL |
The last two are application publishing decisions, not additional Imagild endpoints. Do not describe an authenticated output route as a lifetime public CDN address.
Use the download behavior guide when deciding how your application's save control should behave. Navigation, authenticated retrieval and saving a file are different concerns.
Resolve the task before constructing the remote URL
For a protected browser route, first authorize the local media item. Only then derive the remote request from the saved task identity. This sketch is application code:
const item = await findAuthorizedMediaItem(session.userId, appItemId);
if (!item) throw new Error("Media item unavailable");
const url = new URL(
"/api/relay/v1/tasks/" + encodeURIComponent(item.taskId) + "/content",
"https://imagild.com"
);
// The backend attaches its Bearer header; the browser never receives it.
The helper must enforce your real user or workspace policy. Do not replace it with an unrestricted “fetch any URL” endpoint. The fixed host and derived path prevent this particular route from becoming a general destination selector.
Preserve download behavior without exposing credentials
Your backend can stream authorized bytes to its client rather than buffering an entire long video in memory. If your player needs byte ranges, implement and verify the forwarding behavior in that application route. Imagild's content endpoint supports Range requests, but that does not implement your proxy for you.
Handle failure statuses and content types before labeling the response as playable media. A 403 may reflect API membership or access, while an HTML error page saved as an image is a separate problem. The HTML-instead-of-image guide helps identify the latter.
Do not put private responses into an unrestricted shared cache. Your application's delivery and caching policy must preserve the same access decision.
Check the final rendered media path
In a local test, use a nonsecret credential marker and inspect browser-visible URLs, page source, requests and error messages. None should contain it. Confirm that another application's user cannot retrieve the same item simply by changing its identifier.
Then test a valid saved file and a denied response. The valid path should display or save media correctly; the denied path should explain the failure without suggesting a new paid generation. Pass the design when authentication stays in backend headers and the browser delivery route remains owner-aware.
Related tasks
- Why Does My Download Button Open the Photo in a New Browser Page Instead of Saving It?
- Why Does My Downloaded Image Open as a Web Page?
Sources and scope
- Imagild API console: Actual model API authentication, membership, task ownership, supported routes and private media retrieval.
- OWASP REST Security Cheat Sheet: Credentials should be transmitted in headers rather than URLs, where they can enter logs.
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.