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.

GPT Image 2

OpenAI's GPT Image 2 text-to-image model generates 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.

Base URL

https://api.icreat.ai

Authentication

All API requests must be authenticated with an API Key. You can obtain an API Key from the console.

export ICREAT_API_KEY="your-api-key-here"

HTTP Request Headers

import os

API_KEY = os.environ.get("ICREAT_API_KEY")
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer " + API_KEY,
}

Protect your API Key

Never expose your API Key in client-side code or public repositories. Use environment variables or a backend proxy.

Code Examples

Image and video generation uses a two-step async flow: submit a task to get task_id, then poll via query task result; the response includes status and result ([] while processing; on SUCCEEDED, result holds resources and costUSD is present). The examples below use the same task_id across both steps.

1. Submit Task

Send a generation request to the submit endpoint. On success, the response body returns task_id — save it for polling and result retrieval.

POST/v1/task/submit/openai/gpt-image-2

2. Query Task Result (Poll)

Use the task_id from submit to poll progress (repeat until terminal). The response includes status and result: result is [] while processing; on SUCCEEDED, result holds resources and costUSD is included; FAILED means the task failed.

POST/v1/task/result

Input Schema

Submit Task — Input

The following parameters are accepted in the submit request body.

Total: 4 Required: 3 Optional: 1

promptstringrequired

Text prompt. Maximum length: 32,000 characters.

sizestringrequired

Dimensions of the generated image. Supports presets such as 1024x1024, 2048x2048, 1280x720, 2560x1440, and more.

qualitystringrequired

Controls how closely the output preserves the original input image.

highmediumlow
imagearray[string]

List of reference image URLs (1–10). When non-empty, image-to-image generation is performed.

Query Task Result — Input

Total: 1 Required: 1 Optional: 0

task_idstringrequired

The task ID returned from the submit endpoint.

Output Schema

Submit Task — Output

Total: 1

task_idstring

Unique identifier for the async task. Use this ID to poll status and retrieve results.

Query Task Result — Output

Total: variable

statusstring

Current task status. result is usually [] until success; on SUCCEEDED, result holds resources and costUSD is present.

SUBMITTEDSUCCEEDEDFAILED
resultarray[object]

Generated resources. Empty array while processing or on failure; array of objects on success.

costUSDnumber

Task cost in USD. Present only when status is SUCCEEDED.

LLM Prompt

The Markdown below is an LLM-friendly prompt you can paste into AI assistants (e.g. Cursor, ChatGPT) to help them understand this model's API, call flow, and key parameters. Use Copy for AI or copy from the code block below.

# openai/gpt-image-2

> OpenAI's GPT Image 2 text-to-image model generates high-quality images from natural-language prompts.

## Overview

Use the iCreat two-step async task API: submit a generation request, then poll the query task result endpoint; on success read resources from `result` (includes `costUSD`).

## API Info

- **Base URL**:`https://api.icreat.ai`
- **Submit endpoint (POST)**:`/v1/task/submit/openai/gpt-image-2`
- **Query result endpoint (POST)**:`/v1/task/result`
- **Model ID**:`openai/gpt-image-2`
- **Auth**:`Authorization: Bearer ${ICREAT_API_KEY}`

## Call Flow

1. **Submit**: POST submit path with body per Input Notes; response `{ "task_id": "..." }`
2. **Query result**: POST `/v1/task/result` with `{ "task_id": "..." }`; response includes `status` and `result` (`[]` while processing); on `SUCCEEDED`, `result` holds resources and `costUSD` is present; read `url` or `download_url` when `type` is `Image`

### Input Notes

- Request body uses top-level flat fields
- Required: `prompt`, `size`, `quality`
- Optional: `image`
- `prompt` (required): Text prompt. Maximum length: 32,000 characters.
- `size` (required): Dimensions of the generated image. Supports presets such as `1024x1024`, `2048x2048`, `1280x720`, `2560x1440`, and more.
- `quality` (required): Controls how closely the output preserves the original input image.
- `image` (optional): List of reference image URLs (1–10). When non-empty, image-to-image generation is performed.

### Output Notes

- Poll: read `status`; `result` is `[]` while processing
- Success: `result` is `[{ "type": "Image", "url": "...", "download_url": "..." }]` plus `costUSD`

## Notes

- Use the same `task_id` across both steps; `result` is `[]` while processing — keep polling
- `FAILED` is terminal — check request parameters or reference media