# Image Edit

## Edit Image

> Edits images using natural language instructions. Supports openai/gpt-image-1 model with PNG, WEBP, or JPG formats (max 50MB per image, up to 16 images). Requires multipart/form-data.

```json
{"openapi":"3.1.0","info":{"title":"FastRouter API Reference","version":"1.0.0"},"tags":[{"name":"Images","description":"Generate and edit images using AI models like DALL-E, Stable Diffusion, Flux, and more."}],"servers":[{"url":"https://api.fastrouter.ai","description":"Production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"FastRouter API Key. Get yours at https://fastrouter.ai\n\nFormat: `Authorization: Bearer YOUR_API_KEY`"}},"responses":{"UnauthorizedError":{"description":"Invalid Credentials - Your API key is invalid, disabled, or your OAuth session has expired. Check your credentials.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"},"status":{"type":"integer"}}}}}}}},"RateLimitError":{"description":"Rate Limited - You have exceeded your request limits (TPM/RPM). Slow down or increase your limits.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"},"status":{"type":"integer"}}}}}}}}}},"paths":{"/api/v1/images/edits":{"post":{"operationId":"editImage","tags":["Images"],"summary":"Edit Image","description":"Edits images using natural language instructions. Supports openai/gpt-image-1 model with PNG, WEBP, or JPG formats (max 50MB per image, up to 16 images). Requires multipart/form-data.","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["image","prompt","model"],"properties":{"image":{"oneOf":[{"type":"string","format":"binary","description":"Single image file"},{"type":"array","items":{"type":"string","format":"binary"},"maxItems":16,"description":"Array of image files (up to 16)"}],"description":"The image(s) to edit. Must be PNG, WEBP, or JPG and smaller than 50MB each. Supports up to 16 images."},"prompt":{"type":"string","maxLength":32000,"description":"Text description of the desired modification. Max length: 32,000 characters for gpt-image-1."},"model":{"type":"string","enum":["openai/gpt-image-1"],"description":"Must be 'openai/gpt-image-1'","default":"openai/gpt-image-1"},"n":{"type":"integer","minimum":1,"maximum":10,"default":1,"description":"Number of edited images to generate (1-10)"},"size":{"type":"string","enum":["1024x1024","1536x1024","1024x1536","auto"],"default":"1024x1024","description":"Output image size. Options: 1024x1024, 1536x1024, 1024x1536, or auto"},"output_format":{"type":"string","enum":["png","jpeg","webp"],"default":"png","description":"Output image format: png, jpeg, or webp"},"output_compression":{"type":"integer","minimum":0,"maximum":100,"default":100,"description":"Compression level (0-100) for JPEG or WEBP outputs. Higher values mean better quality."},"mask":{"type":"string","format":"binary","description":"Optional PNG mask file (< 4MB). Transparent areas indicate regions to edit. Must match dimensions of the first input image."},"background":{"type":"string","enum":["transparent","opaque","auto"],"default":"auto","description":"Controls background transparency: transparent, opaque, or auto. If transparent, output format must be png or webp."},"response_format":{"type":"string","enum":["url","b64_json"],"default":"url","description":"Format of the response data"}}}}}},"responses":{"200":{"description":"Image edited successfully","content":{"application/json":{"schema":{"type":"object","properties":{"created":{"type":"integer","description":"Unix timestamp"},"data":{"type":"array","description":"Array of edited images","items":{"type":"object","properties":{"url":{"type":"string","format":"uri","description":"URL of the edited image (if response_format=url)"},"b64_json":{"type":"string","description":"Base64-encoded image data (if response_format=b64_json)"},"revised_prompt":{"type":"string","description":"The revised prompt used by the model"}}}}}}}}},"400":{"description":"Bad Request - Invalid parameters or image format"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"413":{"description":"Payload Too Large - Image exceeds 50MB limit"},"429":{"$ref":"#/components/responses/RateLimitError"},"500":{"description":"Internal Server Error"}}}}}}
```
