GPT Image 2
OpenAI's GPT Image 2 raw image model can generate high-quality images based on natural language prompts. It provides a ready-to-use REST inference API, offering excellent performance, no cold start, and affordability.
openai/gpt-image-2
OpenAI’s GPT Image 2 text-to-image model can generate high-quality images from natural-language prompts. It provides a ready-to-use REST inference API with excellent performance, no cold starts, and affordable pricing.
1. Authentication
The API uses an API key for authentication.
Obtain an API Key
Please visit https://icreat.ai/hub/keys to obtain an API key.
2. Calling the API
Submit a Request
Use cURL to send an HTTP request to create a task:
curl --fail-with-body --connect-timeout 10 --max-time 60 \
-X POST https://api.icreat.ai/v1/task/submit/openai/gpt-image-2 \
-H "Authorization: Bearer ${ICREAT_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Replace the background with a city street illuminated by neon lights at night.",
"image": ["https://cdn.example.com/source/dog.png"],
"size": "1024x1024",
"quality": "high"
}'The server will return a response similar to the following:
{ "task_id": "task-xxx" }Use the task_id to poll the task status and retrieve the result.
3. Query Task Status
curl --connect-timeout 10 --max-time 60 \
-X POST "https://api.icreat.ai/v1/task/query-status" \
-H "Authorization: Bearer ${ICREAT_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"task_id": "task-xxx"
}'The server will return the task status. When the status is SUCCEEDED, you can retrieve the result.
4. Retrieve the Result
curl --connect-timeout 10 --max-time 60 \
-X POST "https://api.icreat.ai/v1/task/get-result" \
-H "Authorization: Bearer ${ICREAT_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"task_id": "task-xxx"
}'The server will return the output result for the task.
5. Parameter Description
The API accepts the following input parameters:
5.1 prompt
- Type:
string - Required: Yes
- Description: Text prompt. Maximum length: 32,000 characters.
5.2 image
- Type:
string[] - Required: No
- Description: A list of reference image URLs. When the list is not empty, image-to-image generation is performed. Supports 1–10 images.
5.3 size
- Type:
string - Required: Yes
- Description: The dimensions of the generated image.
- Only the following values are supported.:
1024x1024, 2048x2048, 2880x2880, 1280x720, 2560x1440, 3840x2160, 720x1280, 1440x2560, 2160x3840, 1152x864, 2304x1728, 3264x2448, 864x1152, 1728x2304, 2448x3264, 1248x832, 2496x1664, 3504x2336, 834x1248, 1664x2496, 2336x3504, 1120x896, 2240x1792, 3200x2560, 896x1120, 1792x2240, 2560x3200, 1456x624, 3024x1296, 3696x1584
5.4 quality
- Type:
string - Required: Yes
- Description: Controls how closely the generated result preserves the original input image.
- Available values:
high,medium,low
6. Input Examples
6.1 Text-to-Image
{
"prompt": "A Shiba Inu wearing sunglasses, in a cyberpunk style.",
"size": "1024x1024",
"quality": "high"
}6.2 Generate an Image Using a Reference Image
{
"prompt": "Replace the background with a city street illuminated by neon lights at night.",
"image": ["https://cdn.example.com/source/dog.png"],
"size": "1024x1024",
"quality": "high"
}