Agent Images
Agent Images is an endpoint that turns a plain-language request into finished images. Describe the result in a prompt and attach up to six images, such as product photos or a model photo. The Agent decides which operations the request needs, such as a try-on, a model swap, or an edit, runs them, and returns every image it made.
Lifecycle: Experimental · Released: October 26, 2026
Request body
Send the parameters documented under Input parameters as top-level fields of a JSON object. A field not listed there is rejected with 400 BadRequest.
Request
Run the Agent and wait for its images in the same request:
The request stays open until the Agent finishes, which takes about 40 seconds for one image at the default settings and longer for requests with several steps. To avoid holding a connection open, use an asynchronous run instead.
Input parameters
promptRequiredstring
What you want, in plain language: between 1 and 10,000 characters. Refer to the images by their position ("the first image", "the dress in the second image") or by what they show.
The Agent never asks a question back. When the prompt is unclear, it makes the best guess that fits the prompt and the images.
images(image URL | data URI)[]
Up to 6 images, in the order the prompt refers to them. Each item is a
publicly accessible http(s) image URL or a base64 data URI
(data:image/<format>;base64,...).
Default: [] (the Agent generates from the prompt alone)
aspect_ratio'1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9'
Aspect ratio of the generated images. An aspect ratio asked for in the prompt takes precedence.
Default: None. The Agent chooses: an edit keeps the edited image's frame, and a new image gets a frame that suits the request.
resolution'1k' | '2k' | '3k' | '4k'
Output resolution tier of the generated images. '1k' produces about 1
megapixel, '2k' about 4, '3k' about 9, and '4k' about 16. An output
size asked for in the prompt takes precedence. Some images are made and
billed at '2k' when '3k' or '4k' is requested.
Default: 1k
generation_mode'fast' | 'balanced' | 'quality'
Sets the generation quality level for every image the Agent generates.
'quality' produces the most detailed and realistic output but takes longer
and costs more credits. 'fast' prioritizes speed and lower cost.
Default: balanced
return_base64boolean
When set to true, every image in results is returned as a base64 data URI
(data:image/png;base64,...) instead of a CDN URL.
The images are still stored on the CDN for three days.
Default: false
What the Agent can do
For each request, the Agent can:
- Generate images: create new images or edit existing ones, including try-on, product-to-model, model creation and swap, background changes, packshots, and transparent images.
- Upscale images: enlarge an image or restore its detail.
- Remove backgrounds: return a transparent cutout of an image.
Each of these counts as one operation; inspecting its own results does not.
A request for several images, such as "three angles" or "two colorways", makes one image per generation. The Agent adds no steps you did not ask for, such as an upscale or a variation.
The Agent makes images only. A request for a video, or one that cannot be met with images, fails with NoImageGenerated.
Technical limitations
| Requirement | Limit |
|---|---|
| Input images | 6 per request |
| Base64 image size | 10 MB per image |
| Image formats | JPEG, PNG, WebP |
| Prompt length | 10,000 characters |
| Operations | 8 per request |
| Request duration | 15 minutes |
A request with too many images, a base64 image over 10 MB, or a prompt over 10,000 characters fails with 400 BadRequest. An image the Agent cannot read, such as one in another format, fails with 422 BadRequest.
A request that reaches 8 operations stops and returns the images made so far. A request still running after 15 minutes stops the same way. If it made no image, it fails with 504 AgentTimeout. Generations still running at that point complete and are billed, but are not returned.
Each operation counts against your concurrency limit while it runs. Rate limits are 100 requests per 60 seconds to start a run and 50 requests per 10 seconds for /v1/agent/status.
Credit cost
You pay only for the images the Agent makes. Each generated image costs:
generation_mode \ resolution | 1k | 2k | 3k | 4k |
|---|---|---|---|---|
fast | 1 | 1 | 1 | 1 |
balanced | 1 | 2 | 3 | 3 |
quality | 2 | 3 | 4 | 4 |
Additional pricing rules:
- An upscale or a background removal costs 1 credit.
- A request costs the sum of its operations, intermediate images included, with at most 8 operations per request, so at most 32 credits.
- Failed operations do not consume credits.
- The top-level
credits_usedfield and theX-Fashn-Credits-Usedresponse header give the exact cost of the request, and each entry inpredictionsgives its own.
Response
idstring
ID of the Agent run. Errors returned after the run starts include it too.
predictionsobject[]
Every operation that produced images, in the order the Agent ran them, intermediate steps included. Each entry has:
id: the prediction ID.tool: the operation,generate-image,image-upscale, orbackground-remove.results: the images it produced, as CDN URLs, or as data URIs withreturn_base64.credits_used: the credits it consumed.
credits_usedinteger
Total credits consumed by the request.
The Agent's text is never returned.
Asynchronous runs
To avoid waiting on an open request, start the run, then poll its status or receive it on a webhook. The run takes the same request body as /v1/agent/images:
POSThttps://api.fashn.ai/v1/agent/images/run
Request example
Response
Returns the run ID for status polling:
With the optional webhook_url query parameter, FASHN sends the run's result to that URL when the run ends, with the same body as a completed or failed status response. See Webhooks.
Status polling
Poll the run with the ID returned when it started:
GEThttps://api.fashn.ai/v1/agent/status/{id}
The response follows the /v1/status states, processing, completed, and failed, with no partial results while the run is processing. A completed run returns the same predictions and credits_used as the synchronous response, and sets the X-Fashn-Credits-Used header:
A failed run returns the error:
A run that does not exist, or that belongs to another user, returns 404.
Errors
An invalid request fails before the run starts, with the API-level errors, such as 400 BadRequest or 429 RateLimitExceeded. When a generation is refused for your credits or concurrency limit and the run made no image, the run fails with that 429 error, OutOfCredits or ConcurrencyLimitExceeded.
Otherwise, a run that made no image fails with one of the errors below. A synchronous request returns it with the HTTP status shown and the run's id, and an asynchronous run returns it as its failed status.
| Code | Name | Cause | How to fix |
|---|---|---|---|
| 422 | NoImageGenerated | The Agent did not make an image, for example for a video request or an unclear prompt. | Make the prompt more specific, or check the input images. |
| 422 | ImageLoadError | An input image URL could not be downloaded. | Use publicly accessible image URLs, or send the images as base64. |
| 422 | BadRequest | An input image could not be read. | Send JPEG, PNG, or WebP images, and a smaller version of a very large image. |
| 422 | Runtime error name | The Agent's last generation failed, for example with ContentModerationError. | See Common runtime errors. |
| 504 | AgentTimeout | The request ran longer than 15 minutes and made no image. | Simplify the request, or split it into several requests. |
| 500 | InternalServerError | The run failed unexpectedly. | Retry with backoff; contact support@fashn.ai with the run id if it persists. |
When the Agent made at least one image, the run succeeds with the images it made, even if a later step failed.
Data handling
Base64 input images are stored privately while the run uses them, and deleted after it ends. Generated images follow the standard data retention of API outputs.
Related guides
- Prompting in FASHN ↗ - Learn how to write effective prompts for best results
- Image Preprocessing Best Practices - Optimize your input images for better results
- Data Retention & Privacy - Understand how FASHN handles your data