nano-banana

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nano Banana - Image Generation API

Nano Banana - 图像生成API

Generate images from text prompts using Google Nano Banana (Gemini's native image generation).
通过Google Nano Banana(Gemini原生图像生成工具)从文本提示生成图像。

Base URL

基础URL

https://api.eng0.ai/api/data
https://api.eng0.ai/api/data

Models

模型

ModelIDBest ForMax Resolution
Flash
flash
Fast generation, high-volume tasks1024px
Pro
pro
Professional quality, complex prompts4K

模型ID适用场景最大分辨率
Flash
flash
快速生成、高批量任务1024px
Pro
pro
专业画质、复杂提示词4K

Generate Image

生成图像

Create an image from a text description.
bash
curl -X POST https://api.eng0.ai/api/data/images/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A futuristic cityscape at sunset with flying cars",
    "model": "flash",
    "aspectRatio": "16:9"
  }'
Parameters:
NameTypeRequiredDefaultDescription
prompt
stringYes-Text description of the image to generate
model
stringNo
flash
flash
(fast, 1024px) or
pro
(high-quality, up to 4K)
aspectRatio
stringNo
1:1
Output aspect ratio
imageSize
stringNo
1K
1K
,
2K
, or
4K
(4K only with
pro
model)
Aspect Ratios:
RatioUse Case
1:1
Square (social media, icons)
16:9
Landscape (presentations, banners)
9:16
Portrait (mobile, stories)
4:3
Standard landscape
3:4
Standard portrait
21:9
Ultra-wide (cinematic)
2:3
,
3:2
,
4:5
,
5:4
Various formats
Response:
json
{
  "image": {
    "base64": "iVBORw0KGgoAAAANSUhEUgAA...",
    "mimeType": "image/png",
    "dataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
  },
  "description": "A vibrant futuristic cityscape..."
}
Response Fields:
FieldDescription
image.base64
Base64-encoded image data
image.mimeType
Image MIME type (typically
image/png
)
image.dataUrl
Ready-to-use data URL for HTML/CSS
description
Model's description of the generated image

根据文本描述创建图像。
bash
curl -X POST https://api.eng0.ai/api/data/images/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A futuristic cityscape at sunset with flying cars",
    "model": "flash",
    "aspectRatio": "16:9"
  }'
参数说明:
参数名类型是否必填默认值说明
prompt
string是-要生成的图像的文本描述
model
string否
flash
flash
(快速生成,1024px)或
pro
(高质量,最高4K)
aspectRatio
string否
1:1
输出图像的宽高比
imageSize
string否
1K
1K
、
2K
或
4K
(仅
pro
模型支持4K)
宽高比选项:
比例使用场景
1:1
正方形(社交媒体、图标)
16:9
横屏(演示文稿、横幅)
9:16
竖屏(移动端、故事内容)
4:3
标准横屏
3:4
标准竖屏
21:9
超宽屏(电影级)
2:3
,
3:2
,
4:5
,
5:4
多种格式
响应示例:
json
{
  "image": {
    "base64": "iVBORw0KGgoAAAANSUhEUgAA...",
    "mimeType": "image/png",
    "dataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
  },
  "description": "A vibrant futuristic cityscape..."
}
响应字段说明:
字段说明
image.base64
Base64编码的图像数据
image.mimeType
图像MIME类型(通常为
image/png
)
image.dataUrl
可直接用于HTML/CSS的Data URL
description
模型对生成图像的描述

Common Workflows

常见工作流

Generate a Simple Image

生成简单图像

bash
curl -X POST https://api.eng0.ai/api/data/images/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A cute robot holding a cup of coffee"
  }'
bash
curl -X POST https://api.eng0.ai/api/data/images/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A cute robot holding a cup of coffee"
  }'

Generate High-Quality 4K Image

生成高质量4K图像

bash
curl -X POST https://api.eng0.ai/api/data/images/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Professional product photo of a sleek smartphone on marble surface",
    "model": "pro",
    "imageSize": "4K",
    "aspectRatio": "4:3"
  }'
bash
curl -X POST https://api.eng0.ai/api/data/images/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Professional product photo of a sleek smartphone on marble surface",
    "model": "pro",
    "imageSize": "4K",
    "aspectRatio": "4:3"
  }'

Generate Social Media Banner

生成社交媒体横幅

bash
curl -X POST https://api.eng0.ai/api/data/images/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Abstract gradient background with geometric shapes in blue and purple",
    "aspectRatio": "16:9"
  }'
bash
curl -X POST https://api.eng0.ai/api/data/images/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Abstract gradient background with geometric shapes in blue and purple",
    "aspectRatio": "16:9"
  }'

Generate Mobile Story Image

生成移动端故事图像

bash
curl -X POST https://api.eng0.ai/api/data/images/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Cozy coffee shop interior with warm lighting",
    "aspectRatio": "9:16"
  }'

bash
curl -X POST https://api.eng0.ai/api/data/images/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Cozy coffee shop interior with warm lighting",
    "aspectRatio": "9:16"
  }'

Using with Python

Python使用示例

python
import requests
import base64
from pathlib import Path

BASE_URL = "https://api.eng0.ai/api/data"

def generate_image(
    prompt: str,
    model: str = "flash",
    aspect_ratio: str = "1:1",
    image_size: str = "1K"
) -> dict:
    """Generate an image from a text prompt."""
    response = requests.post(
        f"{BASE_URL}/images/generate",
        json={
            "prompt": prompt,
            "model": model,
            "aspectRatio": aspect_ratio,
            "imageSize": image_size
        }
    )
    return response.json()

def save_image(result: dict, filepath: str) -> None:
    """Save generated image to a file."""
    if "image" in result:
        image_data = base64.b64decode(result["image"]["base64"])
        Path(filepath).write_bytes(image_data)
        print(f"Saved to {filepath}")
    else:
        print(f"Error: {result.get('error', 'Unknown error')}")
python
import requests
import base64
from pathlib import Path

BASE_URL = "https://api.eng0.ai/api/data"

def generate_image(
    prompt: str,
    model: str = "flash",
    aspect_ratio: str = "1:1",
    image_size: str = "1K"
) -> dict:
    """Generate an image from a text prompt."""
    response = requests.post(
        f"{BASE_URL}/images/generate",
        json={
            "prompt": prompt,
            "model": model,
            "aspectRatio": aspect_ratio,
            "imageSize": image_size
        }
    )
    return response.json()

def save_image(result: dict, filepath: str) -> None:
    """Save generated image to a file."""
    if "image" in result:
        image_data = base64.b64decode(result["image"]["base64"])
        Path(filepath).write_bytes(image_data)
        print(f"Saved to {filepath}")
    else:
        print(f"Error: {result.get('error', 'Unknown error')}")

Example: Generate and save an image

Example: Generate and save an image

result = generate_image( prompt="A serene mountain landscape at dawn with mist in the valley", aspect_ratio="16:9" ) save_image(result, "landscape.png")
result = generate_image( prompt="A serene mountain landscape at dawn with mist in the valley", aspect_ratio="16:9" ) save_image(result, "landscape.png")

Example: Generate high-quality product image

Example: Generate high-quality product image

result = generate_image( prompt="Minimalist tech gadget on white background, studio lighting", model="pro", image_size="4K" ) save_image(result, "product.png")

---
result = generate_image( prompt="Minimalist tech gadget on white background, studio lighting", model="pro", image_size="4K" ) save_image(result, "product.png")

---

Using with Node.js

Node.js使用示例

javascript
const fs = require('fs');

const BASE_URL = 'https://api.eng0.ai/api/data';

async function generateImage(prompt, options = {}) {
  const response = await fetch(`${BASE_URL}/images/generate`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      prompt,
      model: options.model || 'flash',
      aspectRatio: options.aspectRatio || '1:1',
      imageSize: options.imageSize || '1K'
    })
  });
  return response.json();
}

function saveImage(result, filepath) {
  if (result.image) {
    const buffer = Buffer.from(result.image.base64, 'base64');
    fs.writeFileSync(filepath, buffer);
    console.log(`Saved to ${filepath}`);
  } else {
    console.error('Error:', result.error || 'Unknown error');
  }
}

// Example usage
(async () => {
  const result = await generateImage(
    'A neon-lit cyberpunk street scene at night',
    { aspectRatio: '21:9' }
  );
  saveImage(result, 'cyberpunk.png');
})();

javascript
const fs = require('fs');

const BASE_URL = 'https://api.eng0.ai/api/data';

async function generateImage(prompt, options = {}) {
  const response = await fetch(`${BASE_URL}/images/generate`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      prompt,
      model: options.model || 'flash',
      aspectRatio: options.aspectRatio || '1:1',
      imageSize: options.imageSize || '1K'
    })
  });
  return response.json();
}

function saveImage(result, filepath) {
  if (result.image) {
    const buffer = Buffer.from(result.image.base64, 'base64');
    fs.writeFileSync(filepath, buffer);
    console.log(`Saved to ${filepath}`);
  } else {
    console.error('Error:', result.error || 'Unknown error');
  }
}

// Example usage
(async () => {
  const result = await generateImage(
    'A neon-lit cyberpunk street scene at night',
    { aspectRatio: '21:9' }
  );
  saveImage(result, 'cyberpunk.png');
})();

Prompt Tips

提示词技巧

Be Specific

描述要具体

Bad:  "A dog"
Good: "A golden retriever puppy playing in autumn leaves, warm sunlight"
不好:  "A dog"
好: "A golden retriever puppy playing in autumn leaves, warm sunlight"

Include Style

指定风格

"Oil painting style portrait of a woman in Renaissance clothing"
"Minimalist vector illustration of a mountain range"
"Photorealistic close-up of a dewdrop on a leaf"
"Oil painting style portrait of a woman in Renaissance clothing"
"Minimalist vector illustration of a mountain range"
"Photorealistic close-up of a dewdrop on a leaf"

Specify Lighting

说明光线

"... with dramatic side lighting"
"... golden hour sunlight"
"... soft diffused studio lighting"
"... with dramatic side lighting"
"... golden hour sunlight"
"... soft diffused studio lighting"

Add Context

添加背景信息

"... in the style of Studio Ghibli"
"... professional product photography"
"... vintage 1970s film aesthetic"

"... in the style of Studio Ghibli"
"... professional product photography"
"... vintage 1970s film aesthetic"

Model Comparison

模型对比

FeatureFlashPro
SpeedFastSlower
Max Resolution1024px4K
Complex PromptsGoodExcellent
Text RenderingGoodSharp
Best ForQuick iterations, previewsFinal assets, print
When to use Flash:
  • Rapid prototyping
  • Social media content
  • High-volume generation
  • When speed matters
When to use Pro:
  • Professional/commercial use
  • Print materials
  • Complex compositions
  • When quality matters

特性FlashPro
速度快较慢
最大分辨率1024px4K
复杂提示词处理良好优秀
文本渲染良好清晰
最佳适用场景快速迭代、预览图最终素材、印刷品
何时使用Flash:
  • 快速原型制作
  • 社交媒体内容
  • 高批量生成
  • 优先考虑速度时
何时使用Pro:
  • 专业/商业用途
  • 印刷物料
  • 复杂构图
  • 优先考虑画质时

Error Handling

错误处理

No Image Generated:
json
{
  "error": "No image generated",
  "message": "SAFETY"
}
This occurs when the prompt triggers content safety filters.
Invalid Parameters:
json
{
  "error": "Invalid parameters",
  "message": "Missing required parameter: prompt"
}

未生成图像:
json
{
  "error": "No image generated",
  "message": "SAFETY"
}
当提示词触发内容安全过滤器时会出现此错误。
参数无效:
json
{
  "error": "Invalid parameters",
  "message": "Missing required parameter: prompt"
}

Important Notes

重要说明

  • All generated images include invisible SynthID watermarking
  • Images are generated server-side; base64 responses can be large
  • The
    pro
    model takes longer but produces higher quality
  • 4K resolution is only available with the
    pro
    model
  • Content safety filters may block certain prompts

  • 所有生成的图像包含不可见的SynthID水印
  • 图像在服务器端生成;Base64格式的响应可能较大
  • pro
    模型耗时更长但画质更高
  • 仅
    pro
    模型支持4K分辨率
  • 内容安全过滤器可能拦截部分提示词

Combining with Other Skills

与其他技能结合使用

This skill provides image generation. Combine with:
  • deep-research - Generate illustrations for research reports
  • market-data - Create visualizations of financial data
Example workflow:
  1. Research a topic (deep-research)
  2. Generate relevant illustrations (this skill)
  3. Compile into a report
本技能提供图像生成功能,可与以下技能结合:
  • deep-research - 为研究报告生成插画
  • market-data - 创建金融数据可视化图
示例工作流:
  1. 研究主题(deep-research)
  2. 生成相关插画(本技能)
  3. 整理成报告