Gpt image
Generate 4o Image(GPT IMAG 1)¶
Create a new 4o Image(gpt image 1) generation task. Generated images are stored for 14 days, after which they expire Pricing: GPT Imag1 : 10 credits per image (~$0.05)
The 4o Image API, powered by the advanced GPT-4o model, provides high-quality AI image generation services. Whether you need text-to-image generation, image editing, or image variants, our API meets all your creative needs.
Authentication¶
All API requests require a Bearer Token in the request header:
x-api-key: YOUR_API_KEY
Get API Key:
-
Visit API Key to get your API Key
-
Add to request header:
x-api-key: Your_API_Key
1. Create Generation Task¶
API Information¶
- URL:
POST https://api.revidapi.com/paid/gpt4o-image/generate - Header:
x-api-key: Your_API_Key
Body¶
size enum<string> required
(Required) Aspect ratio of the generated image. Must be one of the listed values.
Available options: 1:1, 3:2, 2:3
Example: "1:1"
prompt string
(Optional) Text prompt that conveys the creative idea you want the 4o model to render. Required if neither filesUrl nor fileUrl is supplied. At least one of prompt or filesUrl must be provided.
Example: "A beautiful sunset over the mountains"
filesUrl string<uri>[]
(Optional) Up to 5 publicly reachable image URLs to serve as reference or source material. Use this when you want to edit or build upon an existing picture. If you don’t have reliable hosting, upload your images first via our File Upload API quick‑start: https://docs.revidapi.com/.
Supported formats: .jfif, .pjpeg, .jpeg, .pjp, .jpg, .png, .webp. At least one of prompt or filesUrl must be provided.
Example:
[ "https://example.com/image1.png", "https://example.com/image2.jpg"]
¶
[ "https://example.com/image1.png", "https://example.com/image2.jpg"]
nVariants enum<integer>
(Optional) How many image variations to produce (1, 2, or 4). Each option has a different credit cost—see up‑to‑date pricing at https://revidapi.com/. Default is 1.
Available options:1,2,4
Example: 1
maskUrl string<uri>
(Optional) Mask image URL indicating areas to modify (black) versus preserve (white). The mask must match the reference image’s dimensions and format (≤ 25 MB). When more than one image is supplied in filesUrl, maskUrl is ignored.
Example:

In the image above, the left side shows the original image, the middle shows the mask image (white areas indicate parts to be preserved, black areas indicate parts to be modified), and the right side shows the final generated image.
Example:
"https://example.com/mask.png"
isEnhance boolean
(Optional) Enable prompt enhancement for more refined outputs in specialised scenarios (e.g., 3D renders). Default false.
Example: false
uploadCn boolean
(Optional) Choose the upload region. true routes uploads via China servers; false via non‑China servers.
Example: false
enableFallback boolean
(Optional) Activate automatic fallback to backup models (e.g., Flux) if GPT‑4o image generation is unavailable. Default false.
Example: false
fallbackModel enum<string> default:FLUX_MAX
(Optional) Specify which backup model to use when the main model is unavailable. Takes effect when enableFallback is true. Available values: GPT_IMAGE_1 or FLUX_MAX. Default value is FLUX_MAX.
Available options: GPT_IMAGE_1, FLUX_MAX
Example: "FLUX_MAX"
fileUrl string<uri> deprecated
(Optional, Deprecated) File URL, such as an image URL. If fileUrl is provided, 4o image may create based on this image. This parameter will be deprecated in the future, please use filesUrl instead.
Example:
"https://example.com/image.png"
Request Example¶
curl --request POST \
--url https://api.revidapi.com/paid/gpt4o-image/generate \
--header 'x-api-key: Your API Key' \
--data '
{
"filesUrl": [
"https://example.com/image1.png",
"https://example.com/image2.png"
],
"prompt": "A beautiful sunset over the mountains",
"size": "1:1",
"callBackUrl": "https://your-callback-url.com/callback",
"isEnhance": false,
"uploadCn": false,
"nVariants": 1,
"enableFallback": false,
"fallbackModel": "FLUX_MAX"
}
Response Example¶
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task12345"
}
}
2. Get 4o Image Details¶
Query 4o Image generation task details using taskId, including generation status, parameters and results.
API Information¶
- URL:
POST https://api.revidapi.com/paid/gpt4o-image/info - Parameter:
taskId(passed via URL parameter) - Header:
x-api-key: Your_API_Key
Request Example¶
curl --request POST \
--url https://api.revidapi.com/paid/gpt4o-image/info \
--header 'x-api-key: Your-api-key'
Response Example¶
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task12345",
"paramJson": "{\"prompt\":\"A beautiful sunset over the mountains\",\"size\":\"1:1\",\"isEnhance\":false}",
"completeTime": 1672574400000,
"response": {
"resultUrls": [
"https://example.com/result/image1.png"
]
},
"successFlag": 1,
"status": "SUCCESS",
"errorCode": null,
"errorMessage": "",
"createTime": 1672561200000,
"progress": "1.00"
}
}
Response Parameters¶
Status Descriptions¶
- GENERATING: Generating in progress
- SUCCESS: Generation successful
- CREATE_TASK_FAILED: Failed to create task
- GENERATE_FAILED: Generation failed
Important Notes¶
- Maximum query rate is 3 times per second per task
Response¶
Response status code
- 200: Success - Request has been processed successfully
- 400: Your prompt was flagged by Website as violating content policies. Only English prompts are supported at this time. Failed to fetch the image. Kindly verify any access limits set by you or your service provider. public error unsafe image upload.
- 401: Unauthorized - Authentication credentials are missing or invalid
- 404: Not Found - The requested resource or endpoint does not exist
- 422: Validation Error - The request parameters failed validation checks. record is null. Temporarily supports records within 14 days. record result data is blank. record status is not success. record result data not exist. record result data is empty.
- 451: Failed to fetch the image. Kindly verify any access limits set by you or your service provider.
- 455: Service Unavailable - System is currently undergoing maintenance
- 500: Server Error - An unexpected error occurred while processing the request. Timeout Internal Error, Please try again later.