> For the complete documentation index, see [llms.txt](https://docs.ionos.com/cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionos.com/cloud/api-reference/ai/ai-model-hub/open-ai-compatible-endpoints/edit-an-image-using-a-model.md).

# Edit an image using a model

Edit an image using a model in a format that is compatible with the OpenAI API. Accepts a `multipart/form-data` request with an input image reference in the `url` field and a text `prompt`. Optionally, provide `mask_image` to restrict editing to specific areas.

```json
{"openapi":"3.0.3","info":{"title":"IONOS CLOUD - OpenAI compatible AI Model Hub API","version":"1.0.0"},"tags":[{"name":"OpenAI Compatible Endpoints","description":"Endpoints compatible with OpenAI's API specification"}],"servers":[{"url":"https://openai.inference.de-txl.ionos.com","description":"Berlin"}],"security":[{"tokenAuth":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Please provide header value as 'Bearer <token>' and don't forget to add 'Bearer' HTTP Authorization Scheme before the token."}},"schemas":{"ImageEditRequest":{"type":"object","properties":{"url":{"type":"string","format":"uri","description":"URL of the image to edit.\nSupported formats: public HTTP/HTTPS URLs or base64 data URLs (e.g. `data:image/png;base64,...`).\nIf a mask is not provided, the model will use the entire image as the area to edit.\n"},"prompt":{"type":"string","maxLength":1000,"description":"A text description of the desired image(s). Maximum length is 1000 characters."},"mask_image":{"type":"string","format":"Data URI","description":"A base64-encoded mask image in `data:image/png;base64,<encoded-data>` format.\nFully transparent areas (alpha = 0) indicate where the image should be edited.\nMust have the same dimensions as the input image.\n"},"model":{"type":"string","description":"ID of the model to use. Please check /v1/models for available models."},"n":{"type":"integer","default":1,"minimum":1,"maximum":10,"description":"The number of images to generate. Defaults to 1."},"size":{"type":"string","pattern":"^\\d+\\*\\d+$","default":"1024*1024","description":"The size of the generated images, in `\"width*height\"` format.\nDefaults to `\"1024*1024\"`.\nBoth width and height must be multiples of 16 and between 64 and 2048 (inclusive).\n"},"output_format":{"type":"string","description":"The file format of the generated image.\nDefaults to `png`.\n","default":"png"},"user":{"type":"string","description":"A unique identifier representing your end-user."}},"required":["model","url","prompt"]},"ImageGenerationResponse":{"type":"object","properties":{"created":{"type":"integer","description":"The Unix timestamp of the image generation"},"data":{"type":"array","description":"The list of generated images","items":{"type":"object","properties":{"url":{"type":"string","description":"The URL of the generated image.\nAs of right now, this format is not supported\n","default":null},"b64_json":{"type":"string","description":"The base64 encoded image in JSON format.\n"},"revised_prompt":{"type":"string","description":"Refined initial text prompt for improved image generation using advanced language model capabilities.\nAs of right now, this format is not supported\n"}}}}}},"ErrorResponse":{"type":"object","description":"OpenAI-compatible error response. Returned for error responses that define this schema (for example, 429 Too Many Requests). Note: the backend currently returns an IONOS-native error body format; alignment to this schema is tracked in GPHML-2078.\n","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable error description."},"type":{"type":"string","description":"Error category (e.g. \"requests\", \"invalid_request_error\")."},"code":{"type":"string","nullable":true,"description":"Machine-readable error code (e.g. \"rate_limit_exceeded\"). May be null or omitted."},"param":{"type":"string","nullable":true,"description":"Parameter related to the error, if applicable. May be null or omitted."}},"required":["message","type"]}},"required":["error"]}},"headers":{"X-RateLimit-Limit":{"description":"Sustained request rate limit expressed as requests per minute. Enforcement is per second — see X-RateLimit-Burst for the short-window limit. The actual value depends on your contract; the default is 300 req/min (5 req/s).\n","schema":{"type":"integer"}},"X-RateLimit-Burst":{"description":"Maximum number of requests allowed within a 2-second burst window. Exceeding this triggers a 429 response. The actual value depends on your contract; the default is 10 requests per burst window.\n","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Requests remaining in the current 2-second burst window. Resets when the burst window expires. Does not reflect the per-minute X-RateLimit-Limit.\n","schema":{"type":"integer"}}},"responses":{"TooManyRequests":{"description":"Rate limit exceeded. Retry after the number of seconds indicated by the Retry-After header. Limits are contract-specific; check X-RateLimit-Limit and X-RateLimit-Burst in the response headers for the values that apply to your contract.\n","headers":{"Retry-After":{"description":"Number of seconds to wait before retrying.","schema":{"type":"integer"}},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Burst":{"$ref":"#/components/headers/X-RateLimit-Burst"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Overloaded":{"description":"The platform is temporarily overloaded and is shedding load to stay stable. Retry after the number of seconds indicated by the Retry-After header. This is unrelated to your contract's rate limits.\n","headers":{"Retry-After":{"description":"Number of seconds to wait before retrying.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/v1/images/edits":{"post":{"operationId":"openaiCompatImagesEditsPost","summary":"Edit an image using a model","description":"Edit an image using a model in a format that is compatible with the OpenAI API.\nAccepts a `multipart/form-data` request with an input image reference in the `url` field and a text `prompt`.\nOptionally, provide `mask_image` to restrict editing to specific areas.\n","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ImageEditRequest"}}}},"responses":{"200":{"description":"Successful operation","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Burst":{"$ref":"#/components/headers/X-RateLimit-Burst"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImageGenerationResponse"}}}},"400":{"description":"Bad request"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"description":"Server error"},"529":{"$ref":"#/components/responses/Overloaded"}},"tags":["OpenAI Compatible Endpoints"]}}}}
```


---

# 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.ionos.com/cloud/api-reference/ai/ai-model-hub/open-ai-compatible-endpoints/edit-an-image-using-a-model.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.
