OpenAI
GPT Image 2
gpt-image-2/text-to-image
OpenAI's image generation and editing model, focused on photorealistic quality, high-precision text rendering, and native 4K output, suited for commercial materials and product images that contain text
Try gpt-image-2/text-to-image
Input
Showcases
View all showcasesOutput
imagePricing
gpt-image-2/text-to-image per image
| Specifications | Unit Price |
|---|---|
| 1K | $0.030 |
| 2K | $0.040 |
| 4K | $0.060 |
gpt-image-2/text-to-image @beta per image
| Specifications | Unit Price |
|---|---|
| With Reference Resources | $0.020 |
gpt-image-2/text-to-image @ext per image
Positioning Overview
gpt-image-2 is OpenAI's text-to-image model, aimed at developers who need to reliably produce commercial-grade visual assets. It excels at honoring the multiple constraints within complex prompts, maintains good typographic tidiness in posters, packaging, and layouts that contain text, and supports resolutions from 1K to 4K along with a variety of aspect ratios. You can generate an image simply by passing a prompt through the unified HiAPI.ai interface, making it well suited for teams embedding image-generation capabilities into design tools, marketing asset pipelines, and content production backends.
Core Highlights
- Good adherence to complex prompts — It inherits the semantic understanding of the GPT series and can still generate images according to intent when a prompt contains subject, style, text, and layout constraints at the same time.
- More reliable rendering of images containing text — It delivers good fidelity and layout performance for text content in signage, packaging, and layouts, reducing the need to fix lettering after generation.
- Broad resolution and aspect-ratio coverage — It supports 1K, 2K, and 4K output and more than a dozen ratios from 1:1 to 21:9, so one integration can accommodate many placement specifications.
- Multiple versions per single call — It can generate several results at once, making it easy to compare options and explore styles under the same prompt.
Capability Details
Image generation from text prompts: Generate images by passing a prompt of up to 20,000 characters, making it suitable for turning natural-language descriptions directly into usable visual assets.
Multi-resolution and multi-aspect-ratio output: Choose among 1K, 2K, and 4K, and select landscape or portrait ratios according to placement. The auto ratio and extreme ratios such as 9:21 and 3:1 are limited to 1K, and 1:1 does not support 4K.
Transparent-background output: background supports three modes—auto, opaque, and transparent. Transparent images can be used directly for compositing and overlaying; this parameter takes effect only at 1K.
Text and layout presentation: It delivers good rendering and layout performance for mixed text-and-image compositions, making it suitable for commercial visuals that need a finished look.
Multiple results returned at once: A single prompt can produce multiple style-consistent images, making it easy to quickly compare versions and pick the best one.
Applicable Scenarios
- Marketing teams: ad posters and key visual generation — Input campaign themes and layout requirements to produce campaign key visuals that can go directly into placement or further retouching.
- E-commerce operations: product image and product-photography style rendering — Use product descriptions as input to generate photography-style product images for detail pages, shelf images, and social assets.
- Design teams: packaging and layout drafts with text — Input copy and text-image relationships to produce packaging, signage, and layout design drafts containing multilingual text.
- Content platforms: multi-version iteration of concepts — Batch-generate images from the same prompt for style exploration, then send candidate options for review before finalizing.
Limitations and Selection Advice
It outputs images only and does not support other modalities such as video. The official rating places its generation speed at medium, so it is not suitable for real-time interactive scenarios that are extremely latency-sensitive; high resolution and batch image generation will lengthen processing time and raise call costs at the same time, so trade-offs must be made according to placement specifications. For images containing precise text, manual proofreading is still recommended. If the need leans toward compositional reasoning in complex scenes or extreme generation speed, other models should be evaluated separately; HiAPI.ai also offers an image-to-image route in this series, which can be used when an existing image must serve as input. Billing is calculated per image, and the specific amount is subject to the pricing panel.
What's new
View changelog →- Parameter change gpt-image-2 added 1K / 2K / 4K resolution tiers
Frequently asked questions
View all FAQs →-
What is GPT Image 2?
GPT Image 2 is an OpenAI text-to-image model for posters, knowledge cards, product visuals, and images with explicit text and layout requirements.
-
Is GPT Image 2 the same as GPT Image 2.0?
GPT Image 2.0 is a common search shorthand; use the exact GPT Image 2 model ID shown on this page and in the API docs.
-
Which endpoint and model ID does the GPT Image 2 API use?
Send POST requests to /v1/tasks, set model to gpt-image-2/text-to-image, and pass prompt, aspect_ratio, and resolution in input. The create response returns a taskId; retrieve the final image through task polling or a callback.
-
How do I use GPT Image 2?
In the Playground, describe the subject, scene, layout, and exact text, then choose the aspect ratio, resolution, and background. Click Run to view the result.
Create a generation task
https://api.hiapi.ai/v1/tasks Headers
AuthorizationstringRequiredAccount API key. Required on every request. Example: Bearer YOUR_HIAPI_API_KEY. Get your API key
Content-TypestringOptionalThe request body is always parsed as JSON; when sent, only application/json (optionally with charset) is accepted — any other value returns 415. Example: application/json.
Idempotency-KeystringOptionalIdempotency key, up to 255 bytes. Retries with the same key from the same account create the task only once; replays return the original taskId.
On network timeouts or client retries, the same key creates the task only once — no double charges (scope: the API key's account). Use a business-unique identifier as the key (e.g. "order-42"); replays return the original taskId, and keys expire 24 hours after the first request. See the Unified Async API overview for the full scenario matrix.
Body
modelstringRequiredCurrent fixed value: gpt-image-2/text-to-image
routestringOptionalCurrent fixed value: default
inputobjectRequired
Business parameters for gpt-image-2/text-to-image and route default — see the parameter table below.
promptstringRequiredminLength 1maxLength 20000Text prompt, required, maximum length 20,000 characters.
backgroundstringOptionalBackground mode, supported only at 1K resolution.
autoopaquetransparentresolutionstringOptionalDefault: "1K"Resolution of the generated image, default 1K. When aspect_ratio is auto, only 1K is supported, and 1:1 does not support 4K; when aspect_ratio is 3:1/1:3/9:21, only 1K is supported; when background is auto/opaque/transparent, only 1K is supported.
1K2K4Kaspect_ratiostringOptionalDefault: "auto"Aspect ratio of the generated image, default auto. When omitted or set to auto, only 1K resolution is supported.
auto1:13:22:34:33:45:44:5Show all (8)
16:99:162:11:23:11:321:99:21callbackobjectOptional
Terminal-state notification config. When omitted, no callback is delivered — poll the task yourself. See the callback note below.
Provide callback.url when creating a task and HiAPI POSTs to your service once the task reaches a terminal state — no polling needed. The callback payload mirrors the task detail structure; signature verification, delivery retries and idempotency are documented on the Unified Async API overview page.
urlstringRequiredRequired when callback is present. A POST is sent to this URL once the task reaches a terminal state; must be a valid http(s) URL.
whenstringOptionalDefault: "final"Only final is supported today — notified on both success and fail.
finalstoragestringOptionalDefault: "temp"Artifact storage tier: temp (default, retained about 7 days) or persistent (long-term, billed by size). Insufficient balance or exceeding the storage cap silently downgrades to temp; the effective tier is shown in the task detail response.
temppersistentmodelstringRequiredCurrent fixed value: gpt-image-2/text-to-image
routestringOptionalCurrent fixed value: beta
inputobjectRequired
Business parameters for gpt-image-2/text-to-image and route beta — see the parameter table below.
sizestringOptionalDefault: "auto"pattern ^(auto|[1-9][0-9]{2,4}x[1-9][0-9]{2,4})$Output image size. Use auto or a compliant WIDTHxHEIGHT value such as 2048x2048.
promptstringRequiredmaxLength 20000Text prompt describing the image to generate. Max 20000 characters.
callbackobjectOptional
Terminal-state notification config. When omitted, no callback is delivered — poll the task yourself. See the callback note below.
Provide callback.url when creating a task and HiAPI POSTs to your service once the task reaches a terminal state — no polling needed. The callback payload mirrors the task detail structure; signature verification, delivery retries and idempotency are documented on the Unified Async API overview page.
urlstringRequiredRequired when callback is present. A POST is sent to this URL once the task reaches a terminal state; must be a valid http(s) URL.
whenstringOptionalDefault: "final"Only final is supported today — notified on both success and fail.
finalstoragestringOptionalDefault: "temp"Artifact storage tier: temp (default, retained about 7 days) or persistent (long-term, billed by size). Insufficient balance or exceeding the storage cap silently downgrades to temp; the effective tier is shown in the task detail response.
temppersistentmodelstringRequiredCurrent fixed value: gpt-image-2/text-to-image
routestringOptionalCurrent fixed value: ext
inputobjectRequired
Business parameters for gpt-image-2/text-to-image and route ext — see the parameter table below.
promptstringRequiredminLength 1maxLength 20000图像生成提示词 Max 20000 characters.
qualitystringRequiredDefault: "low"lowmediumhighresolutionstringRequiredDefault: "1K"1K2K4Kaspect_ratiostringOptionalDefault: "1:1"输出画幅比例
auto1:13:22:34:33:45:44:5Show all (8)
16:99:162:11:23:11:321:99:21callbackobjectOptional
Terminal-state notification config. When omitted, no callback is delivered — poll the task yourself. See the callback note below.
Provide callback.url when creating a task and HiAPI POSTs to your service once the task reaches a terminal state — no polling needed. The callback payload mirrors the task detail structure; signature verification, delivery retries and idempotency are documented on the Unified Async API overview page.
urlstringRequiredRequired when callback is present. A POST is sent to this URL once the task reaches a terminal state; must be a valid http(s) URL.
whenstringOptionalDefault: "final"Only final is supported today — notified on both success and fail.
finalstoragestringOptionalDefault: "temp"Artifact storage tier: temp (default, retained about 7 days) or persistent (long-term, billed by size). Insufficient balance or exceeding the storage cap silently downgrades to temp; the effective tier is shown in the task detail response.
temppersistentRequest examples
# Submit an async task; returns a taskId immediately (no waiting for generation)
curl -X POST "https://api.hiapi.ai/v1/tasks" \
-H "Authorization: Bearer $HIAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2/text-to-image",
"input": {
"prompt": "…",
"resolution": "1K",
"aspect_ratio": "auto"
}
}' const res = await fetch("https://api.hiapi.ai/v1/tasks", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.HIAPI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-image-2/text-to-image",
input: {
"prompt": "…",
"resolution": "1K",
"aspect_ratio": "auto"
}
}),
});
const task = await res.json();
// { code: 200, message: "success", data: { taskId } } import os, requests
res = requests.post(
"https://api.hiapi.ai/v1/tasks",
headers={"Authorization": f"Bearer {os.environ['HIAPI_API_KEY']}"},
json={
"model": "gpt-image-2/text-to-image",
"input": {
"prompt": "…",
"resolution": "1K",
"aspect_ratio": "auto"
}
},
)
print(res.json()) # { code, message, data: { taskId } } 200 OK
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-01HZTQ8BX2N3GM3YFK4Z9D7VQR"
}
} 400 Bad Request
{
"code": 400,
"message": "invalid request",
"data": null,
"error_code": "INVALID_REQUEST"
} # Submit an async task; returns a taskId immediately (no waiting for generation)
curl -X POST "https://api.hiapi.ai/v1/tasks" \
-H "Authorization: Bearer $HIAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2/text-to-image@beta",
"input": {
"size": "auto",
"prompt": "…"
}
}' const res = await fetch("https://api.hiapi.ai/v1/tasks", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.HIAPI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-image-2/text-to-image@beta",
input: {
"size": "auto",
"prompt": "…"
}
}),
});
const task = await res.json();
// { code: 200, message: "success", data: { taskId } } import os, requests
res = requests.post(
"https://api.hiapi.ai/v1/tasks",
headers={"Authorization": f"Bearer {os.environ['HIAPI_API_KEY']}"},
json={
"model": "gpt-image-2/text-to-image@beta",
"input": {
"size": "auto",
"prompt": "…"
}
},
)
print(res.json()) # { code, message, data: { taskId } } 200 OK
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-01HZTQ8BX2N3GM3YFK4Z9D7VQR"
}
} 400 Bad Request
{
"code": 400,
"message": "invalid request",
"data": null,
"error_code": "INVALID_REQUEST"
} # Submit an async task; returns a taskId immediately (no waiting for generation)
curl -X POST "https://api.hiapi.ai/v1/tasks" \
-H "Authorization: Bearer $HIAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2/text-to-image@ext",
"input": {
"prompt": "…",
"quality": "low",
"resolution": "1K",
"aspect_ratio": "1:1"
}
}' const res = await fetch("https://api.hiapi.ai/v1/tasks", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.HIAPI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-image-2/text-to-image@ext",
input: {
"prompt": "…",
"quality": "low",
"resolution": "1K",
"aspect_ratio": "1:1"
}
}),
});
const task = await res.json();
// { code: 200, message: "success", data: { taskId } } import os, requests
res = requests.post(
"https://api.hiapi.ai/v1/tasks",
headers={"Authorization": f"Bearer {os.environ['HIAPI_API_KEY']}"},
json={
"model": "gpt-image-2/text-to-image@ext",
"input": {
"prompt": "…",
"quality": "low",
"resolution": "1K",
"aspect_ratio": "1:1"
}
},
)
print(res.json()) # { code, message, data: { taskId } } 200 OK
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-01HZTQ8BX2N3GM3YFK4Z9D7VQR"
}
} 400 Bad Request
{
"code": 400,
"message": "invalid request",
"data": null,
"error_code": "INVALID_REQUEST"
} Get task detail
https://api.hiapi.ai/v1/tasks/:id Response fields
taskIdstringRequiredTask ID, always prefixed with tk-hiapi-.
modelstringRequiredResolved full model name. Tasks submitted with the route parameter return base@route (e.g. gpt-image-2/text-to-image@ext); otherwise identical to the name passed at creation.
routestringOptionalPresent only when the task was submitted with an explicit route parameter; echoes the submitted value.
statusstringRequiredTask status.
queued Queued, not started yet.
handling Being processed.
archiving Processing finished, artifacts being prepared.
success Terminal: completed, artifacts available (output returned).
fail Terminal: failed (error returned).
After submission, check status: success and fail are terminal, everything else is non-terminal. Poll every 1–3 seconds until terminal. On success, download artifacts from output[].url and transfer them before expireAt; pass storage: "persistent" at creation time when long-term retention is needed.
creatednumberRequiredTask creation time (Unix seconds).
completednumberRequiredUnix seconds when the task reached a terminal state; fixed to 0 while not terminal.
outputarrayOptional
Present only when status == success. Artifact list — always an array; a single task may return multiple types at once (e.g. video + first_frame).
Array [ object ]
Array items
urlstringRequiredArtifact URL, directly downloadable.
typestringRequiredCurrent possible values: video, image, audio, first_frame, last_frame, thumbnail; more may be added later.
expireAtnumberRequiredUnix seconds until which the artifact remains accessible; download or transfer before it expires.
errorobjectOptional
Present only when status == fail.
codestringRequiredBusiness error code.
messagestringRequiredError description.
Response examples
Success
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-01HZTQ8BX2N3GM3YFK4Z9D7VQR",
"model": "happyhorse-1-0",
"status": "success",
"created": 1777282033,
"completed": 1777282099,
"output": [
{
"url": "https://cdn.hiapi.ai/tasks/.../video.mp4",
"type": "video",
"expireAt": 1777886899
}
]
}
} Processing (non-terminal)
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-...",
"model": "happyhorse-1-0",
"status": "archiving",
"created": 1777282033,
"completed": 0
}
} Failed
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-...",
"model": "happyhorse-1-0",
"status": "fail",
"created": 1777282033,
"completed": 1777282099,
"error": {
"code": "TASK_FAILED",
"message": "task failed"
}
}
} 
