Use with n8n
Generate images in an n8n workflow with GPT Image or Nano Banana through the Cheapest Imagen API, using the HTTP Request node. Settings, the request body, and how to save the image.
n8n can call the API with its built-in HTTP Request node. You need an API key from your account.
1. Store the key
In n8n, create a credential of type Header Auth:
| Field | Value |
|---|---|
| Name | Authorization |
| Value | Bearer YOUR_KEY |
2. Generate the image
Add an HTTP Request node:
| Setting | Value |
|---|---|
| Method | POST |
| URL | https://api.cheapestimagen.com/v1/images/generations |
| Authentication | Generic Credential Type, Header Auth, the credential from step 1 |
| Send Body | on, Body Content Type JSON |
| Options, Timeout | 420000 (an image can take a few minutes) |
Body:
{
"model": "nano-banana-2.1",
"prompt": "{{ $json.prompt }}",
"size": "1024x1024",
"response_format": "url"
}The node returns the link to the image at data[0].url. To use GPT Image, change model to gpt-image-2 or gpt-image-2.6; every id is on the models page.
3. Save the image
Add a second HTTP Request node:
| Setting | Value |
|---|---|
| Method | GET |
| URL | {{ $json.data[0].url }} |
| Options, Response, Response Format | File |
Its output is the image as binary data, ready for a storage, email or chat node. The link works for 72 hours.
Edit an image
To change an existing picture, call https://api.cheapestimagen.com/v1/images/edits with a JSON body that carries the picture as a link:
{
"model": "nano-banana-2.1",
"prompt": "{{ $json.prompt }}",
"images": [{ "image_url": "{{ $json.imageUrl }}" }],
"response_format": "url"
}Limits to plan for
An account may have 50 requests in progress and send 300 a minute. In a loop over many items, set the batch size of the node to 50 or fewer. See Rate limits and bulk generation.
Migrate from OpenAI
Move existing OpenAI Images API code to Cheapest Imagen by changing only the base URL and the API key; the request and response fields stay the same.
Create image POST
Creates one or more images from a text prompt. Credits are held when the request starts and returned for every image that is not delivered.