GPT Image 2
/v1/tasks All models are called through the Unified Async API POST /v1/tasks endpoint; only the input fields differ (see input parameters below).
Model summary
| Model name | gpt-image-2 |
|---|---|
| Type | Image generation (text-to-image) |
| Endpoint | POST /v1/tasks |
| Pricing | See HiAPI Pricing |
HiAPI text-to-image model for accurate text rendering, complex prompts, and layout-heavy compositions.
Production guidance
- For production, pass callback.url at the top level of the request body so HiAPI can notify your service when the task reaches a terminal state.
- GET /v1/tasks/:id is better for local debugging, low-volume jobs, or fallback reconciliation if a callback is missed.
- Use callback.when=final. Both success and fail are terminal states, so your service should deduplicate by taskId.
Best suited for
Useful for menus, signs, UI screenshots, infographics, and any image where text must stay readable.
promptresolutionUse one detailed prompt to describe headlines, supporting copy, subject placement, and whitespace.
promptaspect_ratioresolutionGenerate clean product visuals with consistent composition for product pages and social covers.
promptaspect_ratioControl subject, style, material, camera, composition, and text content in one complex prompt.
promptAdapt one creative direction into square, landscape, portrait, or ultrawide placements.
aspect_ratioresolutionRequest parameters
model string required Fixed value gpt-image-2.
input object required Business parameters. GPT Image 2 model-specific configuration lives here.
prompt string required Text prompt, up to 20000 characters.
aspect_ratio enum optional Aspect ratio of the generated image.
resolution enum optional Image resolution.
callback object optional Optional callback configuration. HiAPI sends a terminal notification to your service when the task finishes.
url string required Required when callback is provided. HTTPS URL that receives the terminal task notification.
when enum optional Callback trigger timing. Use final for terminal-state notifications.
Example requests
Minimum usable request with prompt, aspect ratio, and resolution.
{
"model": "gpt-image-2",
"input": {
"prompt": "A clean product photo of a red apple on a white table",
"aspect_ratio": "1:1",
"resolution": "1K"
}
}For product pages, social avatars, and square cover placements.
{
"model": "gpt-image-2",
"input": {
"prompt": "A premium skincare bottle on a white acrylic surface, soft studio lighting, clean commercial product photography",
"aspect_ratio": "1:1",
"resolution": "1K"
}
}Put the required words, hierarchy, and layout constraints directly into the prompt.
{
"model": "gpt-image-2",
"input": {
"prompt": "A vertical launch poster with the exact headline \"SUMMER DROP\", small subtitle \"New arrivals\", bright product photography, clean grid layout, generous whitespace",
"aspect_ratio": "9:16",
"resolution": "1K"
}
}Recommended production shape: create the task, then wait for callback.url to receive the terminal notification.
{
"model": "gpt-image-2",
"input": {
"prompt": "A clean product photo of a red apple on a white table",
"aspect_ratio": "1:1",
"resolution": "1K"
},
"callback": {
"url": "https://your-domain.com/hiapi/callback",
"when": "final"
}
}Getting the result
- The response returns a taskId immediately without waiting for generation to finish.
- In production, prefer waiting for callback.url to receive the terminal notification. For local debugging, poll GET /v1/tasks/:id.
- When status=success, download the generated image from output[].url.
- When status=fail, fix the request based on the returned error instead of retrying the same invalid payload.