# OpenAI

## 1. Overview

The industry's leading large language model. Edit images based on text prompts.

**Model List:**

* `gpt-image-2`

## 2. Request Description

* **Request Method**: `POST`
* **Request URL**:

  > `https://gateway.theturbo.ai/v1/images/edits`

***

## 3. Request Parameters

### 3.1 Header Parameters

<table><thead><tr><th width="156.43359375">Parameter Name</th><th width="106.90625">Type</th><th width="91.39453125">Required</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>Content-Type</code></td><td>string</td><td>Yes</td><td>Sets the request header type, must be <code>multipart/form-data</code></td><td><code>multipart/form-data; boundary=------------------------y0QNRDhXQUE3yHQi7DEbLz</code></td></tr><tr><td><code>Accept</code></td><td>string</td><td>Yes</td><td>Sets the response type, recommended to use <code>application/json</code></td><td><code>application/json</code></td></tr><tr><td><code>Authorization</code></td><td>string</td><td>Yes</td><td>API_KEY for authentication, format <code>Bearer $YOUR_API_KEY</code></td><td><code>Bearer $YOUR_API_KEY</code></td></tr></tbody></table>

***

### 3.2 Body Parameters (application/json)

<table><thead><tr><th width="99.5859375">Parameter Name</th><th width="100.08203125">Type</th><th width="78.58203125">Required</th><th width="293.51171875">Description</th><th>Example (Default)</th></tr></thead><tbody><tr><td><strong>model</strong></td><td>string</td><td>Yes</td><td>The model ID to use. See the available versions listed in <a href="#id-1.-overview">Overview</a>, e.g., <code>gpt-image-2</code>.</td><td><code>gpt-image-2</code></td></tr><tr><td><strong>prompt</strong></td><td>string</td><td>Yes</td><td>A text description of the desired image. The maximum description length for <code>gpt-image-2</code> is 32,000 characters.</td><td><code>A cute baby sea otter</code></td></tr><tr><td><strong>image</strong></td><td>file/file array</td><td>Yes</td><td>Submit images for editing. For <code>gpt-image-2</code>, each image should be a PNG, WEBP, or JPG file smaller than 25MB. You can submit up to 16 images via an array.</td><td></td></tr><tr><td>mask</td><td>file</td><td>No</td><td>An additional image whose fully transparent areas (e.g., where alpha is zero) indicate where the image should be edited. If multiple images are provided, the mask is applied to the first image. Must be a valid PNG file, smaller than 4MB, and must have the same dimensions as the image.</td><td></td></tr><tr><td>n</td><td>number</td><td>No</td><td>The number of images to generate, must be between 1 and 10. <code>gpt-image-2</code> only supports n=1.</td><td><code>1</code></td></tr><tr><td>size</td><td>string</td><td>No</td><td>The size of the generated image. <code>gpt-image-2</code> supports arbitrary resolutions, specified as a <code>WIDTHxHEIGHT</code> string, where both <code>WIDTH</code> and <code>HEIGHT</code> must be divisible by 16, and the requested aspect ratio must be between <code>1:3</code> and <code>3:1</code>, with a maximum of <code>3840x2160</code>.</td><td><code>1024x1024</code></td></tr><tr><td>quality</td><td>string</td><td>No</td><td>The quality option for the generated image. <code>gpt-image-2</code> supports <code>high</code>, <code>medium</code>, <code>low</code>.</td><td><code>high</code></td></tr></tbody></table>

***

## 4. Request Examples

{% tabs %}
{% tab title="Single Image" %}

```sh
curl -X POST https://gateway.theturbo.ai/v1/images/edits \
	-H "Authorization: Bearer $YOUR_API_KEY" \
	-F "model=gpt-image-2" \
	-F "image=@input.png" \
	-F 'prompt=A cute baby sea otter wearing a beret' \
	-F ... other parameters
```

{% endtab %}

{% tab title="Multiple Images" %}

```sh
curl -X POST https://gateway.theturbo.ai/v1/images/edits \
	-H "Authorization: Bearer $YOUR_API_KEY" \
	-F "model=gpt-image-2" \
	-F "image[]=@input1.png" \
	-F "image[]=@input2.png" \
	-F 'prompt=A cute baby sea otter wearing a beret' \
	-F ... other parameters
```

{% endtab %}
{% endtabs %}

## 5. Response Example

{% tabs %}
{% tab title="b64\_json" %}

```json
{
	"created": 1589478378,
	"data": [{
			"b64_json": "..."
		},
		{
			"b64_json": "..."
		}
	],
	"usage": {
		"input_tokens": 0,
		"input_tokens_details": {
			"image_tokens": 0,
			"text_tokens": 0
		},
		"output_tokens": 0,
		"total_tokens": 0,
		"output_tokens_details": {
			"image_tokens": 0,
			"text_tokens": 0
		}
	}
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://docs.console.zenlayer.com/api/compute/aig/image-edit/openai-image-edit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
