> For the complete documentation index, see [llms.txt](https://docs.fastrouter.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fastrouter.ai/api-reference/image/image-edit.md).

# 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.\
> \
> \> \*\*Tip:\*\* Supported parameters and their accepted values differ from one model to another. Call \*\*GET /api/v1/models\*\* and inspect each model's \`supported\_parameters\` and \`supported\_params\_details\` to see exactly which fields it accepts and the allowed values, ranges, or enums.

```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 OpenAI GPT Image, Google Imagen/Gemini, Flux, Seedream, Grok, and Leonardo."}],"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, missing, or disabled. Check your credentials.\n\nNote: the 401 error body uses `code`, `message`, `param`, and `type` (there is no `status` field), and `type` is `invalid_request_error`.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"param":{"type":"string","nullable":true},"code":{"type":"string"}}}}}}}},"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.\n\n> **Tip:** Supported parameters and their accepted values differ from one model to another. Call **GET /api/v1/models** and inspect each model's `supported_parameters` and `supported_params_details` to see exactly which fields it accepts and the allowed values, ranges, or enums.","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"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fastrouter.ai/api-reference/image/image-edit.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
