Set up Image generation API (GPT Image / Nano Banana)

Generate and edit images from your own code in the OpenAI Images format, billed per image

Steps

  1. First: do you need the API at all?

    For a few images, just use the Image page on the website, where plans apply. Use this API when your own code needs dozens of images or you are building image generation into a product. It is billed per image from your credits; plans do not cover it. Put these three settings in your code:

    • Base URL: https://gpt.cherrychat.org/v1 (Ends in /v1)
    • API key: sk-your-key
    • Model name: nano-banana-2.1 (Or gpt-image-2 / nano-banana-2)
  2. Draw one with curl and get a link

    Run it in a terminal and wait 20–60 seconds. The "url" in the JSON reply is the image; open it in a browser.

  3. Python: generate and save to a file

    Run pip install openai, save the code as draw.py and run python draw.py; cat.png appears next to it. Without response_format the reply is base64, which the code decodes and saves.

  4. Edit: upload an image and describe the change

    Edits use /v1/images/edits with the reference image uploaded as a file. This turns cat.png into a version with a red scarf, saved as cat-scarf.png.

  5. Count, size and price

    n is how many images you want (1–4); you pay only for images actually returned. Write size in pixels, such as 1024x1024, 1536x1024 (landscape) or 1024x1536 (portrait); the image follows that aspect ratio. Per-image prices are on the Models page.

Common pitfalls

Error → cause → fix

What you seeWhyWhat to do
HTTP 400 unsupported_endpointAn image model was sent to a chat endpoint, or a chat model to the images endpointSend image models to https://gpt.cherrychat.org/v1/images/generations
Timeout after about a minuteYour client gave up before the image was finishedRaise the timeout to 300 seconds; dropped requests are not charged
Edits return 415 or ask for multipart/form-dataThe edit request was sent as JSON instead of uploading the image fileUse images.edit in the SDK, or curl -F image=@file, as in step 4
HTTP 400 saying the content was rejected (safety / moderation)The prompt or reference image triggered content moderationRephrase and try again; rejected requests are not charged
HTTP 402 or "insufficient balance" (billing_error in Claude format)Your credits cannot cover this call. API calls are paid from credits only; memberships and unlimited plans do not applyTop up any amount in the CherryChat Store, then retry after a few seconds

Guide checked 2026-11-02. The tool's screens may change; the official docs win if they differ.

API · API Pricing

Operated by UK Company CHERRYCHAT LTD · Company Number 16096119 · Support WeChat: JsnonoChat · Content is AI-generated — please verify before relying on it

CherryChat

The network is slow. Still loading…