Overview

GPT Image 2 is designed for high-quality image generation, strong instruction following, and practical creative workflows such as marketing visuals, concept art, product imagery, and readable text inside images.

If you only need one thing to get started, start here: send a prompt, choose an output size, and inspect the first image URL returned by the API.

Billing follows quality tiers:

  • low: 2 credits per image
  • medium: 6 credits per image
  • high: 12 credits per image

Endpoint

  • Method: POST
  • URL: https://api.gptimageapi.dev/v1/images/generate

Authentication

Include your API key in the Authorization header. Don't have one yet? Create an API key here.

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

{
  "prompt": "A photorealistic product photo of a citrus soda bottle on a wet studio table, soft reflections, premium lighting, minimal background.",
  "model": "gpt-image-2",
  "size": "4:3",
  "quality": "high",
  "n": 1,
  "background": "opaque"
}

Core fields

  • prompt: The natural-language description of the image you want to generate.
  • model: Use gpt-image-2 for the standard generation route.
  • size: Use aspect ratios such as 1:1, 4:3, 16:9, 9:21, 1:2, and 2:1.
  • quality: Typical values are low, medium, and high.
  • n: Number of output images.
  • background: Use transparent when you need alpha output for cutouts or overlays.

Why teams pick GPT Image 2

  • Stronger prompt adherence for commercial visuals and polished scenes.
  • Better handling of text inside images than older general-purpose image models.
  • Useful across ideation, product marketing, UI mockups, and creative iteration.
  • Transparent background output for compositing workflows.

Response

All successful responses use a unified JSON payload:

{
  "code": 0,
  "message": "ok",
  "data": {
    "images": [
      {
        "url": "https://cdn.gptimageapi.dev/renders/1234567890.png"
      }
    ]
  }
}

Best practices

  • Be explicit about subject, environment, composition, lighting, and camera framing.
  • Put required on-image text in quotes when it must appear verbatim.
  • Use medium while iterating, then switch to high for final outputs.
  • Quality also controls credit usage: low costs 2, medium costs 6, high costs 12.
  • Prefer one focused request over one prompt that tries to describe five different scenes at once.

Prompting notes

  • Wrap literal text in quotes when exact copy must appear inside the image.
  • Keep each quoted region short. Multiple short strings usually outperform one dense paragraph.
  • Mention layout context directly: poster, menu board, app screen, packaging panel, billboard, price card.
  • Use high quality for the final render, not every prompt iteration.

Limitations to plan for

  • Very long paragraphs of on-image text remain less reliable than short headings or labels.
  • Sensitive or policy-restricted prompts may be blocked or rewritten.
  • Fine-grained layout control still benefits from iterative prompting and human review.

Example

curl -X POST "https://api.gptimageapi.dev/v1/images/generate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A photorealistic product photo of a citrus soda bottle on a wet studio table, soft reflections, premium lighting, minimal background.",
    "model": "gpt-image-2",
    "size": "4:3",
    "quality": "high",
    "n": 1
  }'

Node.js

async function generate() {
  const res = await fetch('https://api.gptimageapi.dev/v1/images/generate', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      prompt:
        'A photorealistic product photo of a citrus soda bottle on a wet studio table, soft reflections, premium lighting, minimal background.',
      model: 'gpt-image-2',
      size: '4:3',
      quality: 'high',
      n: 1,
    }),
  });

  const result = await res.json();
  if (result.code !== 0) throw new Error(result.message);
  return result.data.images[0].url;
}

Python

import requests


def generate():
  url = 'https://api.gptimageapi.dev/v1/images/generate'
  headers = {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  }
  payload = {
    'prompt': 'A photorealistic product photo of a citrus soda bottle on a wet studio table, soft reflections, premium lighting, minimal background.',
    'model': 'gpt-image-2',
    'size': '4:3',
    'quality': 'high',
    'n': 1,
  }

  res = requests.post(url, headers=headers, json=payload, timeout=60)
  res.raise_for_status()
  result = res.json()
  if result.get('code') != 0:
    raise Exception(result.get('message'))
  return result.get('data', {}).get('images', [])[0].get('url')


print(generate())

Next steps

  • Use the playground to test prompts interactively.
  • Continue with image edits if your workflow starts from existing assets.
  • Read the model guide for capability and prompting notes.