GPT Image 2 API
/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/text-to-image |
|---|---|
| Type | Image generation (text-to-image) |
| Routes | default / pro / beta / ext |
| Endpoint | POST /v1/tasks |
| Pricing | See HiAPI Pricing |
HiAPI GPT Image 2 text-to-image API for accurate text rendering, complex prompts, layout-heavy compositions, and production image generation.
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.
- Create a HiAPI API key before calling GPT Image 2, and keep the key on your server.
- Image cost depends on model, resolution, and request volume. Use the live HiAPI Pricing page instead of hard-coding prices in your app.
- For prompt validation, start with 1K output. Increase resolution or switch to a higher-fidelity model only for final assets.
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_ratioresolutionThe pro route delivers higher quality at 1K/2K; beta controls output via a size field; ext unlocks multi-ratio 4K. Each route is priced differently.
routeRequest parameters
Default route: full 1K/2K/4K resolutions and 16 aspect ratios (including auto), one flat rate per image.
model string required Fixed value gpt-image-2/text-to-image.
route string optional Omit for the default route, or pass default explicitly.
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. Default auto. Note: 5:4, 4:5, 3:1, 1:3, and 9:21 support 1K images only.
resolution enum optional Image resolution. Note: 1:1 cannot be generated at 4K; auto or an unspecified aspect ratio can only be generated at 1K.
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.
The pro quality route: 1K/2K only, 10 aspect ratios (no auto, default 1:1). Pass route: "pro" at the top level — equivalent to model gpt-image-2/text-to-image@pro.
model string required Fixed value gpt-image-2/text-to-image, combined with route to select the pro route.
route string required Fixed value pro.
input object required Business parameters.
prompt string required Text prompt, up to 20000 characters.
aspect_ratio enum optional Aspect ratio, default 1:1; the pro route does not accept auto.
resolution enum optional Image resolution; the pro route supports 1K/2K only.
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.
The beta route has a different parameter shape: a size field replaces aspect_ratio and resolution. Pass route: "beta" at the top level.
model string required Fixed value gpt-image-2/text-to-image, combined with route to select the beta route.
route string required Fixed value beta.
input object required Business parameters.
prompt string required Text prompt, up to 20000 characters.
size string optional Output size, replacing aspect_ratio and resolution. Default auto lets the model decide; a width x height pixel value is also accepted.
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.
The ext multi-ratio 4K route: all 16 aspect ratios available at 1K/2K/4K, resolution and quality are required, priced by quality tier. Pass route: "ext" at the top level.
model string required Fixed value gpt-image-2/text-to-image, combined with route to select the ext route.
route string required Fixed value ext.
input object required Business parameters.
prompt string required Text prompt, up to 20000 characters.
aspect_ratio enum optional Output aspect ratio; all 16 ratios are available at every resolution tier (including 5:4, 4:5, 2:1, etc.).
resolution enum required Resolution tier: 1K ≈ 1024px, 2K ≈ 2048px, 4K up to 3840×2160; actual pixels vary by ratio.
quality enum required Quality tier, affects pricing: low is clean and sharp for volume, medium adds visible detail, high is cinematic.
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/text-to-image",
"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/text-to-image",
"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/text-to-image",
"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"
}
}Pass route: "pro" at the top level for the quality route. Note the pro route supports 1K/2K only and does not accept auto for aspect_ratio.
{
"model": "gpt-image-2/text-to-image",
"route": "pro",
"input": {
"prompt": "A premium wireless headphone product shot on dark slate, dramatic studio lighting, editorial style",
"aspect_ratio": "3:2",
"resolution": "2K"
}
}Recommended production shape: create the task, then wait for callback.url to receive the terminal notification.
{
"model": "gpt-image-2/text-to-image",
"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.
FAQ
What is the GPT Image 2 API?
GPT Image 2 is HiAPI’s text-to-image generation API for product visuals, posters, and text-heavy layouts. You call it through the unified POST /v1/tasks endpoint with model gpt-image-2/text-to-image; it returns a taskId immediately, and you fetch the result by polling or callback.
How do I get an API key for GPT Image 2?
Create a key in the HiAPI dashboard under API keys and send it as a Bearer token in the request header. Keep the key on your server, not in client-side code. Create an API key
How much does the GPT Image 2 API cost?
Image cost depends mainly on resolution (1K / 2K / 4K) and request volume. Start with 1K to validate a prompt and increase resolution only for final assets. Use the live HiAPI pricing page for current per-image rates instead of hard-coding a number. View live pricing
Can GPT Image 2 render text inside images?
Yes. GPT Image 2 is strong at accurate text rendering for menus, posters, signage, infographics, and UI mockups — put the exact words and layout requirements directly in the prompt.
Which routes does gpt-image-2/text-to-image offer, and how do the parameters differ?
Four routes. Standard: aspect_ratio (including auto) plus resolution (1K/2K/4K). Pro: resolution is limited to 1K/2K, and aspect_ratio drops auto with a slightly narrower list. Beta: a different parameter shape — a size field replaces aspect_ratio and resolution. Ext: a multi-ratio 4K route (quality and resolution required) — see the ext tab under request parameters. Each route is priced differently — check the live HiAPI pricing page.
How do I call the pro or beta route?
Pass the base model name with a top-level route parameter, e.g. route: 'pro', or spell the route into the model name, e.g. gpt-image-2/text-to-image@pro — the two are equivalent. Note that input parameters differ per route, so adjust the fields accordingly.