Generate

GPT Image 2.6

Generate and edit images with Sunburst or Flare, custom dimensions, and image output settings.

Use GPT-Image-2.6-Sunburst for detailed visual work or GPT-Image-2.6-Flare for faster iteration. Both support text-to-image (T2I) and image editing (I2I). Access depends on your account; check GET /api/v0/models?kind=image for the models and controls available to you.

Generate an image

curl https://api.machgen.ai/api/v0/generate \
  -H "Authorization: Bearer $MACHGEN_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "GPT-Image-2.6-Sunburst",
    "task_type": "T2I",
    "prompt": "A red ceramic mug on a white tabletop, soft daylight",
    "image_config": { "width": 1024, "height": 1024 },
    "image_output": { "quality": "max", "complexity": "medium" }
  }'

The response includes a task_id. Poll the task until it completes, then download its image. Each task produces one image.

Edit an image

Use a completed image task as the source, or pass uploaded/external image references in src_image_urls. For example, change the mug's color while keeping its composition:

curl https://api.machgen.ai/api/v0/generate \
  -H "Authorization: Bearer $MACHGEN_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "GPT-Image-2.6-Flare",
    "task_type": "I2I",
    "prompt": "Change only the red mug to blue. Keep the composition and lighting.",
    "src_task_ids": ["<completed-image-task-id>"],
    "image_config": { "width": 1536, "height": 1024 },
    "image_output": {
      "complexity": "low",
      "quality": "high",
      "background": "opaque",
      "output_format": "webp",
      "output_compression": 80
    }
  }'

Editing accepts 1-16 ordered reference images. PNG, JPEG and WebP inputs must be smaller than 50 MB each. Prompts may contain up to 32,000 characters. A text instruction can guide edits to the whole image or describe a region. For a masked edit, add src_mask_url with an uploaded or external PNG mask. The mask must have an alpha channel, be smaller than 50 MB and match the first reference image's dimensions. Transparent areas identify the region to edit. Masks cannot be combined with GIF output.

For annotated edits, add src_markup_url alongside src_image_urls. Upload a separate transparent PNG containing your circles, arrows or sketches, and explain the intended change in prompt. Keep the original image first in src_image_urls; do not flatten the annotations into it. The annotation layer must contain transparent pixels, be smaller than 50 MB and match the first image after orientation. Each may contain at most 16,777,216 pixels. Markup requires PNG, JPEG or WebP output, cannot be combined with src_mask_url, and adds no reference-image charge. This option is currently available through the API only.

The OpenAI-compatible image-edit endpoint accepts a multipart markup file or JSON "markup": {"image_url": "https://example.com/annotations.png"}.

Continue an edit

Send another I2I request with continuation_task_id set to your previous completed task ID and keep the same model. You can refer to earlier instructions, for example, “restore the original background.” Additional reference images are optional. Continue using the new task ID after each successful edit.

{
  "model": "GPT-Image-2.6-Flare",
  "task_type": "I2I",
  "continuation_task_id": "YOUR_PREVIOUS_TASK_ID",
  "prompt": "Restore the original background and keep the new subject color",
  "image_config": { "width": 1024, "height": 1024 }
}

The first continuation uses the original prompt, references and result image. Subsequent edits retain the conversation with OpenAI. Output settings apply to each request; set the size and image settings you want each time.

A conversation supports up to 8 turns including the original image, 16 unique reference images including previous results, and 64,000 prompt characters in total. Continue within 29 days of the first follow-up. At a limit or expiry, start a new ordinary image edit using the latest result. History is never silently truncated. Prompt enhancement is disabled for continuations because the conversation already provides the context.

Continuations support PNG, JPEG and WebP output. They currently cannot include an edit mask or markup layer. These controls remain available in ordinary image edits. The OpenAI-compatible /images/edits endpoint also accepts continuation_task_id; no image upload is required when continuing a task.

Each request charges for its new output and the unique images in its conversation history, including earlier generated results and new references, at the existing reference-image rate. Conversation text processing is included. UI controls are not yet available.

Dimensions and aspect ratios

Set image_config.width and height to the exact output dimensions. Recommended starting sizes are 1024×1024, 1536×1024, and 1024×1536. Other sizes are accepted when all of these conditions hold:

  • Both edges are positive multiples of 16.
  • Neither edge exceeds 3840 pixels.
  • Total pixels are between 655,360 and 8,294,400, inclusive.
  • Width divided by height is between 1/3 and 3, inclusive.

For example, 1536×864 is valid 16:9; 1920×1080 is invalid because 1080 is not a multiple of 16. Use 1920×1088 for that near-Full-HD preset, or 2048×1152 for exact 16:9. The UI's named presets show their actual pixel dimensions. Explicit width and height take precedence over aspect_ratio.

OpenAI describes resolutions above 2560×1440 as experimental. To let the model choose the dimensions, use "image_config": {"size_mode": "auto"} without width, height or aspect ratio. The completed task reports its actual dimensions. See the official image guide.

Pricing

Both models price each image using the estimated output tokens for its dimensions and quality. Generation and editing share the same price for a given output size and quality. Each reference adds 1.048576 megapixels at the baseline rate, regardless of its uploaded size, once per generated image. Masks do not add a reference charge. Automatic and omitted quality reserve the max price, then charge the quality actually returned. Any difference is refunded at your original discounted rate.

For example, 1920×1088 at max has a list price of $0.159 per image at the standard rate. Generate shows your estimate, including applicable discounts, before submission. OpenAI's output cost calculator

GIF pricing includes every delivered frame. Automatic size reserves the maximum output cost for the selected quality, multiplied by the requested GIF frames. Any unused amount is returned after completion. SVG authoring is included.

Image settings

In Generate, open Image settings beside Advanced. Choose Automatic size, or turn on Custom size to adjust the current width and height. For image edits, Edit mask uploads a mask. Selecting GIF shows the frame count and frame delay controls. The API uses the optional image_output object for both generation and editing.

FieldValuesWhen omitted
complexitylow, medium, highhigh
qualitylow, medium, high, xhigh, max, autoauto
backgroundauto, opaque, transparentauto
output_formatpng, jpeg, webp, svg (generation only), gifpng
output_compressionInteger from 0 to 100, JPEG/WebP only100 for JPEG/WebP
frame_countInteger from 2 to 16, GIF only9
frame_duration_msInteger from 20 to 655350, GIF only200

Complexity controls planning before rendering; quality controls the rendered image. Lower complexity can suit a focused edit, while higher complexity can help with dense text and layouts. Higher settings can increase generation time. Omitting quality or choosing quality: "auto" lets the model choose. Use an explicit quality for a predictable rendering tier.

Transparent backgrounds require PNG or WebP. For a cutout, use "background": "transparent", "output_format": "png" and describe the subject in your prompt. Downloads retain the selected format and transparency. Changing to PNG clears compression in the UI; the API rejects that combination.

The OpenAI-compatible image endpoints accept the same output controls as top-level fields. The native REST API and Python client use image_output. See ImageOutputOptions for the shared schema.

For SVG, select "output_format": "svg" on a text-to-image request. The downloaded file retains its vector paths. SVG is not accepted as an editing input. To select the author, add "svg": {"model": "gpt-5.5", "reasoning": {"effort": "high"}} inside image_output. Without it, the author is gpt-5.5 with its default effort. Supported effort values depend on the selected author model and upstream access.

Optionally send a top-level safety_identifier of up to 128 characters for safety monitoring. Use a pseudonymous identifier, not personal information. It does not change which account owns or pays for the image. If the compatible endpoint receives a legacy user without an explicit safety_identifier, it hashes the value together with your MachGen account ID before forwarding it for safety monitoring.

The compatible Images endpoints also accept lowercase model names such as gpt-image-2.6-flare. Their svg configuration is a top-level request field.

For animation, select "output_format": "gif" and describe the movement and loop. GIF supports generation and editing with still references; it does not support masks or custom compression. Frame delays are rounded to 10 ms. Explicit frame dimensions must be positive multiples of 16; small canvases such as 512×512 are supported by the platform. Upstream GIF size limits and preview access also apply. GIF files are checked against the requested pixel and frame budget rather than a fixed 50 MiB limit. Both URL and base64 delivery support larger animations.

Reduced upstream moderation uses the account's existing moderation permission. Authorized callers can use native moderate=false or compatible moderation=low; the provider still filters requests. Other accounts receive an error.

Streaming previews

On the OpenAI-compatible Images endpoints, send stream=true and optionally partial_images=1..3. With partial_images=0, only the completed image is sent. The provider may produce fewer previews than requested. Generation emits image_generation.partial_image and image_generation.completed; edits emit image_edit.partial_image and image_edit.completed. Each event carries base64 image data. With n>1, image_index identifies the requested image and task_id identifies its native task.

for event in client.images.generate(
    model="gpt-image-2.6-flare", prompt="A red bicycle", stream=True,
    partial_images=2,
):
    if event.type == "image_generation.partial_image":
        print("Preview", event.partial_image_index)
    elif event.type == "image_generation.completed":
        print("Completed", event.task_id)

For the native API, set image_output.partial_images. Poll the task or subscribe to task updates; image_previews lists authenticated preview URLs. These are intermediate images, not completed outputs. Previews are retained for seven days; expired preview URLs return 404. Completed output images are unaffected. Previews support PNG, JPEG and WebP; GIF, SVG and continued edits do not support intermediate previews. A continued edit can still use stream=true to receive its final image as an event.

Each generated preview adds 100 output tokens, with your existing discount. The estimate reserves the requested count; unused preview charges are refunded. Disconnecting does not cancel generation. Retrieve the native task using the response's X-MachGen-Task-Ids header instead of submitting it again.

Multiple images

The OpenAI-compatible Images endpoints accept n from 1 to 10. SVG requires n=1. Each image has its own task and charge. Responses return images in request order; X-MachGen-Task-Ids lists their native task IDs. Response size and quality describe the images when all results share that value. Automatic sizing or quality can differ between images; a differing value is omitted from the shared response metadata.

If a request stops after some images have been submitted, those tasks continue. Use the IDs in the response header to retrieve them rather than retrying the whole request. Native /api/v0/generate continues to create one image per task.