Skip to main content
POST
/
v1
/
images
/
generations
# model can be "gemini-3.1-flash-lite-image", the alias "nano-banana-2-lite" also works
curl --request POST \
  --url https://api.apimart.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gemini-3.1-flash-lite-image",
    "prompt": "赛博朋克风格的城市夜景,霓虹灯闪烁",
    "size": "16:9",
    "resolution": "1K",
    "n": 1
  }'
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01K8SGYNNNVBQTXNR4MM964S7K"
    }
  ]
}
Model-name compatibility note: gemini-3.1-flash-lite-image also accepts the alias nano-banana-2-lite, and gemini-3.1-flash-lite-image-ext also accepts the alias nano-banana-2-lite-ext; each name and its alias are equivalent and interchangeable.
# model can be "gemini-3.1-flash-lite-image", the alias "nano-banana-2-lite" also works
curl --request POST \
  --url https://api.apimart.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gemini-3.1-flash-lite-image",
    "prompt": "赛博朋克风格的城市夜景,霓虹灯闪烁",
    "size": "16:9",
    "resolution": "1K",
    "n": 1
  }'
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01K8SGYNNNVBQTXNR4MM964S7K"
    }
  ]
}

Authorizations

Authorization
string
required
All API endpoints require Bearer Token authenticationGet your API Key:Visit the API Key Management Page to get your API KeyAdd it to the request header:
Authorization: Bearer YOUR_API_KEY

Body

model
string
default:"gemini-3.1-flash-lite-image"
required
Image generation model nameThe following model names are supported:
  • gemini-3.1-flash-lite-image (Nano Banana Lite, compatible alias nano-banana-2-lite)
  • gemini-3.1-flash-lite-image-ext (compatible alias nano-banana-2-lite-ext)
Both share the same parameters and constraints (1K only, google_search / official_fallback not supported, up to 14 reference images). Neither has a -official variant, and neither supports the official_fallback fallback parameter. Billing is subject to the backend configuration of each channel.The aliases nano-banana-2-lite (for gemini-3.1-flash-lite-image) and nano-banana-2-lite-ext (for gemini-3.1-flash-lite-image-ext) are equivalent to their original names and interchangeable.
prompt
string
required
Text description for image generation
size
string
Image aspect ratioSupported ratios:
  • auto - Automatically choose the aspect ratio
  • 1:1 - Square, avatars, social media
  • 3:2 / 2:3 - Standard photos
  • 4:3 / 3:4 - Traditional display ratio
  • 16:9 / 9:16 - Widescreen / vertical video covers
  • 5:4 / 4:5 - Instagram images
  • 21:9 - Ultra-wide banner
For text-to-image, when size is auto, the default is 1:1 or 16:9; for image-to-image, the aspect ratio follows the upstream response. (We recommend specifying an aspect ratio.)
resolution
string
default:"1K"
Output image resolutionSupported values:
  • 1K - ~1024px, standard resolution (the only tier Lite supports)
Lite only supports 1K. Passing 2K / 4K / 0.5K is silently downgraded to 1K — it won’t raise an error, nor will it actually output higher resolution. The frontend UI does not need to expose a resolution option.
n
integer
default:"1"
Number of images to generateRange: 1 to 4, default 1When n>1, the backend sends multiple concurrent requests upstream and bills by the actual number of successful images. We recommend the frontend always send 1 (to show progress image by image and make billing more intuitive).⚠️ Note: Must enter a plain number (e.g., 1), do not use quotes or it will cause an error
image_urls
array
Reference image URL list for image-to-image generationTwo formats are supported:1. Full image URL
  • Publicly accessible image URL (http:// or https://)
  • Example: https://example.com/image.jpg
2. Base64 encoded format
  • Must use the full Data URI format
  • Format: data:image/{format};base64,{base64data}
  • Supported image formats: jpeg, png, webp
  • Example: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABg...
  • ⚠️ Note: Must include the data:image/jpeg;base64, prefix
Limitations:
  • Maximum 14 reference images (recommended: up to 10 object refs + 4 character refs)
  • Single image size: not exceeding 10MB
  • Supported formats: jpeg, png, webp
webhook
string
Task callback URL (base)When a task succeeds / fails, the platform calls back to webhook + /callback (it does not forward the upstream request). Passing this parameter can significantly reduce polling; we still recommend keeping polling as a fallback.
Lite usage notes
  • google_search / google_image_search are not supported: Lite uses the Developer API’s interactions endpoint, and the upstream has not enabled the Search tool (it returns “Search as tool is not enabled for this model”), so the platform adapter does not send this parameter either. Passing it won’t raise an error and images are generated as usual, but there is no search enhancement effect at all. If you need search enhancement, switch to gemini-3.1-flash-image-preview.
  • mask_url inpainting is not supported (the Gemini family uses aspect ratio + reference images rather than masks).
  • Billed by token (unlike the fixed per-image price of flash/pro): input is about 0.25permilliontokens,imageoutputisabout0.25 per million tokens, image output is about 30 per million tokens, and a single 1K image ≈ 1120 output tokens ≈ $0.0336/image. The actual price is subject to the backend multiplier configuration.
  • All generated images contain Google’s SynthID invisible watermark (upstream behavior, cannot be disabled).

Response

code
integer
Response status code
data
array
Response data array