> For the complete documentation index, see [llms.txt](https://nsclouds.gitbook.io/aillm.nscloud.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nsclouds.gitbook.io/aillm.nscloud.ai/image-edits/openai.md).

# OpenAI

### 1. Overview

OpenAI exposes image edit capabilities in this environment.

{% hint style="success" %}
This endpoint provides gpt-image-2 image capabilities through the OpenAI Images API.
{% endhint %}

**Supported models：**

* `gpt-image-2`

### 2. gpt-image-2 Parameter Notes

{% hint style="info" %}
`gpt-image-2` supports editing from one or more input images. `mask` is optional, and transparent areas represent regions to edit.
{% endhint %}

| Parameter       | Support                                                                                                 |
| --------------- | ------------------------------------------------------------------------------------------------------- |
| `image`         | Required. Supports a single image or multiple images; accepts URLs, base64, data URIs, or file uploads. |
| `prompt`        | Required. Reference maximum length is 32000 characters.                                                 |
| `mask`          | Optional. Transparent areas represent the edit region.                                                  |
| `n`             | Optional. Reference range is 1-10; the actual number of returned images can be lower than requested.    |
| `size`          | Optional. Supports `auto` and the fixed sizes listed below.                                             |
| `quality`       | Optional. Supports `low`, `medium`, and `high`; omitted, `auto`, and `standard` are billed as `high`.   |
| `background`    | Optional. Supports `opaque` and `auto`.                                                                 |
| `output_format` | Optional. Supports `png` and `jpeg`.                                                                    |

Supported sizes: `auto`, `1024x1024`, `1024x1536`, `1536x1024`, `2048x2048`, `2048x1152`, `3840x2160`, `2160x3840`, `2048x1360`, `1360x2048`, `1152x2048`, `2048x1536`, `1536x2048`, `2048x880`, `880x2048`, `688x2048`, `2048x688`, `2048x1024`, `1024x2048`

### 3. API Details

## Edit Image

> Create edited images based on original images and text prompts. Compatible with OpenAI's Images API.

```json
{"openapi":"3.1.0","info":{"title":"NSCloud AI API Documentation","version":"1.11.0"},"tags":[{"name":"image_edits_openai","description":"OpenAI's image edits API"}],"servers":[{"url":"https://aillm.nscloud.ai","description":"Global Server"}],"security":[{"APIKeyHeader":[]}],"components":{"securitySchemes":{"APIKeyHeader":{"type":"http","scheme":"bearer","description":"Authenticate using Bearer token format: 'Bearer YOUR_SECRET_TOKEN'"}},"schemas":{"ImageUsage":{"type":"object","description":"Resource usage summary for image generation.","properties":{"total_tokens":{"type":"integer","description":"Total token count."},"input_tokens":{"type":"integer","description":"Input token count."},"output_tokens":{"type":"integer","description":"Output token count."},"input_tokens_details":{"type":"object","description":"Optional breakdown of input token usage.","properties":{"text_tokens":{"type":"integer","description":"Input tokens attributed to text prompts."},"image_tokens":{"type":"integer","description":"Input tokens attributed to images."}},"additionalProperties":true}}},"ErrorResponse":{"type":"object","description":"Error response payload.","properties":{"error":{"$ref":"#/components/schemas/ErrorDetail"}}},"ErrorDetail":{"type":"object","description":"Error detail object.","properties":{"message":{"type":"string","description":"Human-readable error message."},"type":{"type":"string","description":"Error type."},"param":{"description":"Parameter associated with the error, if any.","type":["string","null"]},"code":{"description":"Machine-readable error code, if any.","type":["string","null"]}}}},"responses":{"ErrorResponse":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/v1/images/edits":{"post":{"tags":["image_edits_openai"],"summary":"Edit Image","description":"Create edited images based on original images and text prompts. Compatible with OpenAI's Images API.","operationId":"createImageEdit_openai","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","description":"gpt-image-2 image editing request body.","properties":{"model":{"type":"string","description":"Model ID to invoke."},"image":{"description":"Input image or images. Supports file uploads, URLs, base64 strings, and data URIs.","anyOf":[{"type":"string","format":"binary"},{"type":"array","items":{"type":"string","format":"binary"}},{"type":"string"},{"type":"array","items":{"type":"string"}}]},"prompt":{"type":"string","maxLength":32000,"description":"Prompt used to guide image editing."},"mask":{"description":"Optional mask. Transparent areas represent regions to edit.","anyOf":[{"type":"string","format":"binary"},{"type":"string"}]},"n":{"type":"integer","minimum":1,"maximum":10,"default":1,"description":"Number of images to request. The actual returned count can be lower than requested."},"size":{"type":"string","description":"Requested output image size.","enum":["auto","1024x1024","1024x1536","1536x1024","2048x2048","2048x1152","3840x2160","2160x3840","2048x1360","1360x2048","1152x2048","2048x1536","1536x2048","2048x880","880x2048","688x2048","2048x688","2048x1024","1024x2048"],"default":"1024x1024"},"quality":{"type":"string","description":"Requested image quality level.","enum":["low","medium","high"],"default":"high"},"background":{"type":"string","description":"Background handling mode.","enum":["opaque","auto"]},"output_format":{"type":"string","description":"Output image format.","enum":["png","jpeg"],"default":"png"}},"required":["model","image","prompt"]},"encoding":{"image":{"style":"form","explode":true}}}}},"responses":{"200":{"description":"Success Response","content":{"application/json":{"schema":{"type":"object","description":"gpt-image-2 image edit response.","properties":{"created":{"type":"integer","description":"Unix timestamp in seconds when the response was created."},"background":{"type":"string","description":"Background type used for the edited image."},"output_format":{"type":"string","description":"Output image format."},"quality":{"type":"string","description":"Effective image quality used by the model."},"size":{"type":"string","description":"Final returned image size."},"data":{"type":"array","description":"Edited image results.","items":{"type":"object","properties":{"url":{"type":"string","description":"Edited image URL."},"revised_prompt":{"type":"string","description":"Prompt actually used or revised by the model."}}}},"usage":{"$ref":"#/components/schemas/ImageUsage"}}}}}},"400":{"$ref":"#/components/responses/ErrorResponse"},"401":{"$ref":"#/components/responses/ErrorResponse"},"429":{"$ref":"#/components/responses/ErrorResponse"}}}}}}
```
