跳转到主要内容
Nano Banana 2 is a Google image generation model available through the standard /v1/images/generations endpoint. It produces native 2K resolution images by default and supports reference-image-driven generation, multi-image style fusion, and 4K upscaling via the extra_fields parameter. Endpoint: POST https://api.qhaigc.net/v1/images/generations

Supported Models

Model IDDescription
nano-banana-2Google image model. Native 2K resolution, reference image support, 4K upscaling.
nano-banana-proEnhanced character consistency and complex image understanding.

Request Parameters

model
string
必填
Use nano-banana-2 or nano-banana-pro.
prompt
string
必填
Text description of the image you want to generate.
size
string
必填
Image dimensions. You can use either OpenAI-style widthxheight values or Nano Banana native resolution names:
size valueResolutionAspect Ratio
1024x10241K1:1
1024x17921K9:16
1792x10241K16:9
512512native
1K1Knative
2K2Knative
4K4Knative
If you pass a size not in this table (e.g. 800x600), the model falls back to its default resolution.
extra_fields
object
Nano Banana-specific advanced parameters. All fields are optional.

Response Fields

created
integer
Unix timestamp of when the image was generated.
data
array
Array containing the generated image object.

Code Examples

Basic generation

from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key-here",
    base_url="https://api.qhaigc.net/v1"
)

response = client.images.generate(
    model="nano-banana-2",
    prompt="A fresh banana resting on a wooden table, photorealistic style, soft natural light, high detail",
    size="1024x1024"
)

print(response.data[0].url)

Native 2K with custom aspect ratio

curl https://api.qhaigc.net/v1/images/generations \
  -H "Authorization: Bearer sk-your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2",
    "prompt": "A cluster of bananas hanging from a tree, documentary photography style, crisp detail",
    "size": "2K",
    "extra_fields": {
      "aspect_ratio": "16:9",
      "temperature": 0.8
    }
  }'

Reference image URL

curl https://api.qhaigc.net/v1/images/generations \
  -H "Authorization: Bearer sk-your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2",
    "prompt": "Match the composition and color palette of the reference, generate a banana product poster",
    "size": "1024x1024",
    "extra_fields": {
      "reference_images": [
        "https://example.com/reference-poster.jpg"
      ],
      "temperature": 0.7
    }
  }'

Multi-image style fusion

curl https://api.qhaigc.net/v1/images/generations \
  -H "Authorization: Bearer sk-your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2",
    "prompt": "Fuse the styles of both reference images into a minimal banana brand key visual",
    "size": "2K",
    "extra_fields": {
      "reference_images": [
        "https://example.com/style-1.jpg",
        "https://example.com/style-2.jpg"
      ]
    }
  }'

4K upscaled output with base64 reference

curl https://api.qhaigc.net/v1/images/generations \
  -H "Authorization: Bearer sk-your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2",
    "prompt": "Convert this banana line art into a 3D cartoon style",
    "size": "1024x1024",
    "extra_fields": {
      "reference_images": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..."],
      "image_size": "4K",
      "aspect_ratio": "1:1",
      "temperature": 0.5
    }
  }'
When you pass both extra_fields.image_size and extra_fields.aspect_ratio, they override whatever resolution and ratio would have been inferred from the size field.

Fallback Behavior

ScenarioBehavior
size not in the mapping tableNo resolution mapping applied; model uses its default
extra_fields not passedOnly prompt and size are used; fully OpenAI-compatible
Invalid fields inside extra_fieldsInvalid fields are ignored; generation proceeds normally
Reference image URL not accessibleURL is passed to the model as-is; model may return an error

Common Errors

ErrorCause
no base64 image found in responseModel did not return an image. Check your prompt or model support.
failed to upload imageImage upload to the proxy server failed. Contact support if this persists.
chat response contains no choicesModel returned empty response, likely due to a safety filter. Adjust your prompt.