Skip to content

How do I generate an image with GPT Image or Nano Banana through AISwapLab?

Choose an available image model, quote its prompt and size, then POST to /api/v1/images/generations with max_credits and a persisted Idempotency-Key. The current route creates one text-to-image job using a quality supported by the selected model. It returns a job record rather than immediate image bytes; poll that job and download its private content after completed.

GENERATE AND INSPECT API IMAGESAISwapLab team · Editorial methodUpdated 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Choose exact supported options; Approve and submit once; Retrieve and inspect the asset.
Workflow diagram: Choose exact supported options → Approve and submit once → Retrieve and inspect the asset. Read the article for evidence and limits.

Use the customer contract rather than upstream examples

The image aliases include gpt-image-2, gpt-image-2.5, gpt-image-2.6 and nano-banana-2.1. They share the customer endpoint but can have different prices and provider mappings. Fields such as response_format, input_image_id or an arbitrary image-editing payload are not accepted on this route, even if a provider offers them elsewhere.

What to do next

  1. 01

    Choose exact supported options

    Read GET /models for availability, sizes and qualities. Use a prompt within 4,000 characters, a documented size and quality=medium for the current published rate.

  2. 02

    Approve and submit once

    Obtain /quotes for the intended body, check its estimate, then send the image creation request with the same approved inputs and a durable unique identifier.

  3. 03

    Retrieve and inspect the asset

    Save the job ID, poll within the key's rate allowance, and download only after completed. Check the image's actual dimensions and visual content before treating it as suitable for use.

A concrete example

Illustrative body: model gpt-image-2, a descriptive scene prompt, size 1K, quality medium, n 1 and an explicitly approved max_credits. This is an integration example, not a newly generated sample or a quality comparison.

Illustrative single-image JSON body

Illustrative integration code. No paid generation was executed for this guide. Review live availability, quotes and your own approval before running creation requests.

json
{
  "model": "gpt-image-2",
  "prompt": "A quiet coastal cafe at sunrise, square composition, no text.",
  "size": "1K",
  "quality": "medium",
  "n": 1,
  "max_credits": 1
}

Before you call it ready

  • The model is an available image alias.
  • One durable job is retained.
  • The private image is validated after download.

When to stop or choose another method

If your client expects base64 in the first response, implement asynchronous handling before enabling the feature. Do not repeatedly create images while waiting for immediate bytes.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation