OpenAI GPT Image 2 Text-to-Image
openai/gpt-image-2/text-to-image
OpenAI's GPT Image 2 Text-to-Image generates high-quality images from natural-language prompts. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
Examples



Parameters
| Name | Type | Default | Constraints | Description |
|---|---|---|---|---|
| prompt *Prompt | textarea | — | ≤ 5000 chars | The positive prompt for the generation. |
| nImage Count | slider | 1 | 1 ~ 10 | The number of images to generate (1-10). Each image is billed separately. |
| aspect_ratioAspect Ratio | select | — | 1:1 | 1:2 | 1:3 | 2:1 | 2:3 | 3:1 | 3:2 | 3:4 | … | The aspect ratio of the generated image. Ignored if 'size' is specified. |
| resolutionResolution | select | — | 1k | 2k | 4k | Output resolution level. Ignored if 'size' is specified. |
| sizeSize | text | auto | — | Specific image resolution. The format is [width]x[height]. If specified, aspect_ratio and resolution will be ignored. |
| qualityQuality | select | auto | auto | low | medium | high | Rendering quality. Higher quality costs more and takes longer. |
| output_formatOutput Format | select | png | png | jpeg | webp | The format of the output image. JPEG is faster for low latency. |
| output_compressionCompression | number | — | 0 ~ 100 | Compression level, only valid for JPEG/WebP (0-100). |
| moderationModeration | select | auto | auto | low | Content moderation level. |
Output fields
| Field | Type | Description |
|---|---|---|
| images | array<string> |
API
Call this model through one unified REST API. Get a key on the API Keys page.
cURL
# 1) Submit — returns { "task_uuid": "..." }
curl -X POST "https://www.namifusion.com/api/v1/marketplace/run/openai/gpt-image-2/text-to-image" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "A futuristic cityscape at sunset, with glowing skyscrapers and flying cars.",
"n": 3,
"aspect_ratio": "16:9",
"resolution": "4k",
"size": "1024x1024",
"quality": "high",
"output_format": "jpeg",
"output_compression": 85,
"moderation": "auto"
}
}'
# 2) Poll until status is "completed", then read the output URLs
curl "https://www.namifusion.com/api/v1/marketplace/run/tasks/TASK_UUID" \
-H "Authorization: Bearer YOUR_API_KEY"Python
import time, requests
API_KEY = "YOUR_API_KEY"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# 1) Submit
resp = requests.post(
"https://www.namifusion.com/api/v1/marketplace/run/openai/gpt-image-2/text-to-image",
headers=HEADERS,
json={
"input": {
"prompt": "A futuristic cityscape at sunset, with glowing skyscrapers and flying cars.",
"n": 3,
"aspect_ratio": "16:9",
"resolution": "4k",
"size": "1024x1024",
"quality": "high",
"output_format": "jpeg",
"output_compression": 85,
"moderation": "auto"
}
},
)
resp.raise_for_status() # 401/402/429/5xx stop here instead of polling a bad task
task = resp.json()
# 2) Poll until a terminal state (completed / failed / cancelled).
# This model is allowed up to 600s server-side.
deadline = time.time() + 660
while task.get("status") not in ("completed", "failed", "cancelled"):
if time.time() > deadline:
raise TimeoutError(f"still {task.get('status')} — keep the task_uuid and poll later")
time.sleep(3)
poll = requests.get(f"https://www.namifusion.com/api/v1/marketplace/run/tasks/{task['task_uuid']}", headers=HEADERS)
poll.raise_for_status()
task = poll.json()
print(task["status"], task.get("output"))JavaScript
const API_KEY = "YOUR_API_KEY";
const HEADERS = { Authorization: `Bearer ${API_KEY}` };
// 1) Submit
const resp = await fetch("https://www.namifusion.com/api/v1/marketplace/run/openai/gpt-image-2/text-to-image", {
method: "POST",
headers: { ...HEADERS, "Content-Type": "application/json" },
body: JSON.stringify({
"input": {
"prompt": "A futuristic cityscape at sunset, with glowing skyscrapers and flying cars.",
"n": 3,
"aspect_ratio": "16:9",
"resolution": "4k",
"size": "1024x1024",
"quality": "high",
"output_format": "jpeg",
"output_compression": 85,
"moderation": "auto"
}
}),
});
if (!resp.ok) throw new Error(`submit failed: ${resp.status} ${await resp.text()}`);
let task = await resp.json();
// 2) Poll until a terminal state (completed / failed / cancelled).
// This model is allowed up to 600s server-side.
const deadline = Date.now() + 660 * 1000;
while (!["completed", "failed", "cancelled"].includes(task.status)) {
if (Date.now() > deadline) throw new Error(`still ${task.status} — keep the task_uuid and poll later`);
await new Promise((r) => setTimeout(r, 3000));
const poll = await fetch(`https://www.namifusion.com/api/v1/marketplace/run/tasks/${task.task_uuid}`, { headers: HEADERS });
if (!poll.ok) throw new Error(`poll failed: ${poll.status}`);
task = await poll.json();
}
console.log(task.status, task.output);Documentation
OpenAI GPT Image 2 Text-to-Image
Transform text into stunning visuals with unparalleled quality and precision.
OpenAI GPT Image 2 Text-to-Image is a cutting-edge model designed to generate high-quality images from natural-language prompts. With strong prompt fidelity, flexible aspect ratios, and production-ready API access, this model is ideal for developers and creators seeking polished visuals for diverse applications. Enjoy seamless performance with no cold starts and affordable pricing.
🚀 Key Features
- Strong Prompt Fidelity: Generates images that closely follow detailed natural-language instructions, including scene layout, visual style, and composition.
- High-Quality Image Generation: Produces polished visuals suitable for marketing creatives, concept design, product mockups, and branded content.
- Flexible Aspect Ratios: Supports square, portrait, and landscape outputs for various use cases, including social media, editorial, and product visuals.
- Accurate Text Rendering: Creates images with clearer, more usable in-image text for posters, ads, packaging, and interface mockups.
- Production-Ready API: Access the model through a ready-to-use REST inference API for fast integration into applications and workflows.
🛠️ Technical Specifications
| Parameter | Description | Options/Range |
|---|---|---|
| prompt | Text description of the desired image. | Required |
| aspect_ratio | Aspect ratio of the generated image. | 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
| resolution | Output resolution of the image. | 1k (default), 2k |
| quality | Image quality level. Higher quality costs more. | low, medium (default), high |
Example Prompt
A cinematic product photo of a luxury perfume bottle on a marble surface, soft golden-hour lighting, shallow depth of field, elegant reflections, premium editorial photography style.
💰 Pricing
| Model | Modality | Input | Cached input | Output |
|---|---|---|---|---|
| gpt-image-2 | Image | $8.00 | $2.00 | $30.00 |
| Text | $5.00 | $1.25 | - |
💡 Best Use Cases
- Marketing Creatives: Generate hero images, ad visuals, banners, and campaign assets from text prompts.
- E-commerce Content: Create product shots, lifestyle scenes, and promotional visuals without a full studio workflow.
- Social Media Content: Quickly produce eye-catching visuals tailored to different content formats.
- Concept Art & Ideation: Explore visual directions for products, scenes, characters, and campaigns.
🔗 Related Models
- OpenAI GPT Image 2 Edit: Edit one or more reference images using natural-language instructions for enhanced creative control.
Related models
xAI Grok Imagine Image v2.0 Text to Image
xAI Grok Imagine Image V2.0 Text-to-Image generates high-quality images from text prompts, with configurable aspect ratio, resolution, and quality for creative visuals, social content, marketing assets, and production workflows. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
Qwen Image 3.0 Pro Text to Image
Qwen Image 3.0 Pro is a professional-grade text-to-image model with superior quality and advanced prompt understanding. Up to 2k. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
OpenAI GPT Image 2 Edit
OpenAI's GPT Image 2 Edit enables image editing from natural-language instructions with one or more reference images. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
Nami Z-Image T2I Spicy
Generate an image from a text prompt with configurable width, height, prompt enhancement, and seed.
Nano Banana Text to Image
Gemini 2.5 Flash Image. Lightweight and fast. The most affordable option for instant, high-volume generation.
Nano Banana Pro Text to Image
Gemini 3.0 Pro Image. The high-fidelity choice for 4K visuals, multilingual text rendering, and pro camera controls.
Nano Banana Pro Text to Image
Gemini 3.0 Pro Image. The high-fidelity choice for 4K visuals, multilingual text rendering, and pro camera controls.
Google Nano Banana Lite Text to Image API
Google Nano Banana 2 Lite Text to Image generates high-quality images from text prompts with low latency, flexible aspect ratios, and fast image creation for creative and production workflows. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.