GPT Image 2 Official
Describes the integration status of `gpt-image-2-official` in the current project, along with the request fields and response structure of the unified image interface.
- The page path is retained to illustrate the integration status within the current project.
- Unified image interface:
POST /v1/images/generations - Successful response is a synchronous
ImageResponse
Current Integration Status
- This model has been deprecated. Please use the better model
gpt-image-2for optimal results.
Public Image Interface Design
Request Routing
POST /v1/images/generationsSuccessful Response Structure
{
"created": 1712345678,
"data": [
{
"url": "https://example.com/generated-image.png",
"b64_json": "",
"revised_prompt": ""
}
]
}Standard Request Fields
The current project guarantees the availability of the following standard fields:
modelpromptnsizequalityresponse_format
Ready-to-Use Call Examples
The following examples apply when "the backend has already mapped gpt-image-2-official as an available model":
cURL
curl --request POST \
--url https://api.magickapi.com/v1/images/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2-official",
"prompt": "星空下的古老城堡",
"n": 1,
"size": "1024x1024",
"quality": "high",
"response_format": "url"
}'Python
import requests
url = "https://api.magickapi.com/v1/images/generations"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"model": "gpt-image-2-official",
"prompt": "星空下的古老城堡",
"n": 1,
"size": "1024x1024",
"quality": "high",
"response_format": "url",
}
response = requests.post(url, headers=headers, json=payload, timeout=300)
response.raise_for_status()
result = response.json()
print(result)
print("image_url:", result["data"][0]["url"])Node.js
const url = "https://api.magickapi.com/v1/images/generations";
const payload = {
model: "gpt-image-2-official",
prompt: "星空下的古老城堡",
n: 1,
size: "1024x1024",
quality: "high",
response_format: "url",
};
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (!response.ok) {
throw new Error(await response.text());
}
const result = await response.json();
console.log(result);
console.log("image_url:", result.data?.[0]?.url);If you prefer to receive Base64 content directly, change response_format to b64_json and read data[0].b64_json.
Image Editing
If the channel corresponding to this model supports editing capabilities, the unified editing endpoints are:
POST /v1/images/editsPOST /v1/edits
Last updated on
GPT Image 2
Describes the integration status of `gpt-image-2` in the current project, as well as the request fields and response structure of the unified image interface.
BFL FLUX Official Models
Routes, parameters, and examples for calling BFL official FLUX image generation, image editing, Fill, and Erase models through Magick API.