fashn-logo
FASHNAI

Edit

Edit is a versatile post-processing endpoint that preserves identity and product fidelity while executing freeform instructions. Use it to change poses or viewpoints for extra angles, style a shot with accessories or lighting, or fix issues in Product to Model or Model Swap outputs.

Model Specifications
  • Model Name: edit
  • Lifecycle: experimental
  • Processing Time: 20s–120s (see below)
  • Credits: 1-5 per output image depending on resolution and generation_mode

Request

Refine images by submitting the source image and edit instructions to the universal /v1/run endpoint:

POSThttps://api.fashn.ai/v1/run

Request Examples

curl -X POST https://api.fashn.ai/v1/run \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -d '{
           "model_name": "edit",
           "inputs": {
             "image": "https://example.com/model.jpg",
             "prompt": "turn the model slightly to the left, add a black leather crossbody bag, soft daylight studio lighting"
           }
         }'

Response

Returns a prediction ID for status polling:

{
  "id": "123a87r9-4129-4bb3-be18-9c9fb5bd7fc1-u1",
  "error": null
}

Request Parameters

image
Required
image URL | base64

Source image to refine. The model preserves subject identity and product details while applying the requested edits.

prompt
Required
string

Freeform instructions for the edits you want to apply, ideal for pose or view adjustments, styling (accessories, lighting, environment), or small fixes to existing outputs.

maskimage URL | base64

Optional mask image that guides the edit toward specific regions. White pixels (255) mark areas to prioritize, black pixels (0) mark areas to preserve. The model may still adjust nearby pixels to keep the image coherent, so treat the mask as a strong hint rather than strict inpainting.

The mask must have the same dimensions as the source image.

image_contextimage URL | base64

Optional reference image that provides visual context to guide the edit. Use this when the desired result cannot be fully described in words alone. Examples include a specific background scene, complex pose, or texture pattern.

resolution'1k' | '2k' | '4k'

Output resolution tier. '1k' produces ~1 megapixel output, '2k' ~4 megapixels, and '4k' ~16 megapixels. Exact output dimensions depend on this tier and the image aspect ratio.

Default: '1k'

generation_mode'fast' | 'balanced' | 'quality'

Sets the generation quality level. 'quality' produces the most detailed and realistic output but takes longer to process and costs more credits. 'fast' prioritizes speed and lower cost. If omitted, FASHN selects generation_mode automatically. For edit, omitted generation_mode is currently billed as 'fast' at 1k and as 'quality' at 2k or 4k.

seedinteger

Sets random operations to a fixed state. Use the same seed to reproduce results with the same inputs, or different seed to force different results.

Default: 42
Range: 0 to 2^32 - 1

num_imagesinteger

Number of images to generate in a single request. Must be between 1 and 4. Additional images consume more compute (and credits) and can increase processing time.

Default: 1

output_format'png' | 'jpeg'

Specifies the output image format.

-png: Delivers the highest quality image, ideal for use cases such as content creation where quality is paramount.


-jpeg: Provides a faster response with a slightly compressed image, more suitable for real-time applications.

Default: png

return_base64boolean

When set to true, the API will return the generated image as a base64-encoded string instead of a CDN URL. The base64 string will be prefixed according to the output_format (e.g., data:image/png;base64,... or data:image/jpeg;base64,...).

This option offers enhanced privacy as user-generated outputs are not stored on our servers when return_base64 is enabled.

Default: false

Credit Cost

generation_mode \ resolution1k2k4k
fast123
balanced234
quality345

Additional pricing rules:

  • num_images multiplies the total cost by the number of outputs requested.
  • If generation_mode is omitted, automatic pricing applies.

Processing Time

Processing time depends on both resolution and generation_mode. The fastest configuration (fast + 1k) typically completes in under 20 seconds, while the most intensive (quality + 4k) can take up to 120 seconds. Actual latency may vary with current server load.

Response Polling

After submitting your request, poll the status endpoint using the returned prediction ID. See API Fundamentals for complete polling details.

Successful Response

When your edit completes successfully, the status endpoint will return:

{
  "id": "123a87r9-4129-4bb3-be18-9c9fb5bd7fc1-u1",
  "status": "completed",
  "output": [
    "https://cdn.fashn.ai/123a87r9-4129-4bb3-be18-9c9fb5bd7fc1-u1/output_0.png"
  ],
  "error": null
}

The output array contains URLs to your edited images, which follow your instructions while preserving product and subject fidelity.

Runtime Errors

Edit shares the common runtime errors in Error Handling.

For detailed implementation guidance and best practices:

On this page