Generate or edit an image with Gemini
curl --request POST \
--url https://gengen.farm/api/gengen/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gemini-3.1-flash-image",
"prompt": "A cyan greenhouse at sunrise, editorial photography"
}
'import requests
url = "https://gengen.farm/api/gengen/v1/images/generations"
payload = {
"model": "gemini-3.1-flash-image",
"prompt": "A cyan greenhouse at sunrise, editorial photography"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gemini-3.1-flash-image',
prompt: 'A cyan greenhouse at sunrise, editorial photography'
})
};
fetch('https://gengen.farm/api/gengen/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": "<string>",
"model": "<string>",
"status": "succeeded",
"outputs": {
"images": [
"<string>"
],
"expiresAt": "2023-11-07T05:31:56Z",
"text": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Image API
Generate images with Gemini
Generate or edit images synchronously with Google native image models through the GENGEN Image API.
POST
/
images
/
generations
Generate or edit an image with Gemini
curl --request POST \
--url https://gengen.farm/api/gengen/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gemini-3.1-flash-image",
"prompt": "A cyan greenhouse at sunrise, editorial photography"
}
'import requests
url = "https://gengen.farm/api/gengen/v1/images/generations"
payload = {
"model": "gemini-3.1-flash-image",
"prompt": "A cyan greenhouse at sunrise, editorial photography"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gemini-3.1-flash-image',
prompt: 'A cyan greenhouse at sunrise, editorial photography'
})
};
fetch('https://gengen.farm/api/gengen/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": "<string>",
"model": "<string>",
"status": "succeeded",
"outputs": {
"images": [
"<string>"
],
"expiresAt": "2023-11-07T05:31:56Z",
"text": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Use the normalized GENGEN request schema with one of these public model IDs:
GENGEN fixes
See the Google model pages for detailed capabilities.
gemini-3-pro-imagegemini-3.1-flash-imagegemini-3.1-flash-lite-image
| Property | Value |
|---|---|
| Method | POST |
| Endpoint | /api/gengen/v1/images/generations |
| Processing | Synchronous |
| Output | Public HTTPS URLs in outputs.images |
| URL retention | 24 hours |
Text-to-image request
curl --request POST \
--url https://gengen.farm/api/gengen/v1/images/generations \
--header 'Authorization: Bearer gengen_live_xxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-3.1-flash-image",
"prompt": "A cyan greenhouse at sunrise, editorial photography",
"controls": {
"size": "1K",
"aspectRatio": "16:9"
}
}'
Image editing request
Add public or signed HTTPS URLs, or Base64 data URLs, underassets.referenceImages. Raw gs:// URIs are not accepted; use a signed HTTPS URL instead.
curl --request POST \
--url https://gengen.farm/api/gengen/v1/images/generations \
--header 'Authorization: Bearer gengen_live_xxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-3-pro-image",
"prompt": "Keep the product unchanged and replace the background with a clean studio scene.",
"assets": {
"referenceImages": [
"https://example.com/product.png"
]
},
"controls": {
"size": "2K",
"aspectRatio": "1:1"
}
}'
Response
Read generated media fromoutputs.images. Google image responses are URL-only: GENGEN stores each generated image in a dedicated Vercel Blob path and never returns the generated image as Base64. Each URL is retained for 24 hours. The response uses only the normalized top-level fields shown below; duplicate compatibility aliases and provider billing usage are omitted.
{
"id": "image:550e8400-e29b-41d4-a716-446655440000",
"model": "gemini-3.1-flash-image",
"status": "succeeded",
"outputs": {
"images": [
"https://example.public.blob.vercel-storage.com/gengen/google-generated-images/2026/08/21/image_550e8400/01-example.png"
],
"expiresAt": "2026-08-22T08:00:00.000Z"
}
}
Generated image URLs expire after 24 hours. Download or copy every image to storage you control before
outputs.expiresAt.Parameters
| Parameter | Type | Description |
|---|---|---|
model | string | Required Google native image model ID. |
prompt | string | Generation or editing instruction. Required unless at least one reference image is supplied. |
assets.referenceImages | string[] | Up to 14 public or signed HTTPS URLs, or Base64 reference images. Raw gs:// URIs are not accepted. |
controls.size | string | Pro: 1K, 2K, 4K; Nano Banana 2: 512, 1K, 2K, 4K; Lite: 1K. |
controls.aspectRatio | string | Supports 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, and 1:8/8:1. Pro and Nano Banana 2 also support 9:21; Lite does not. |
providerOptions.google.generationConfig | object | Advanced Google image sampling settings such as temperature and topP. |
providerOptions.google.safetySettings | array | Vertex AI safety settings forwarded to Google. |
candidateCount to 1; request multiple alternatives with separate calls. Reference image formats are PNG, JPEG, WebP, HEIC, and HEIF.
Supported sizes vary by model: Nano Banana Pro (Gemini 3 Pro Image) supports
1K, 2K, and 4K; Nano Banana 2 (Gemini 3.1 Flash Image) supports 512, 1K, 2K, and 4K; Nano Banana 2 Lite (Gemini 3.1 Flash-Lite Image) supports 1K.Authorizations
A workspace API key beginning with gengen_live_.
Body
application/json
- Option 1
- Option 2
Google native image model ID.
Available options:
gemini-3-pro-image, gemini-3.1-flash-image, gemini-3.1-flash-lite-image Generation or editing instruction.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes