Loading...
Loading...
通过inference.sh CLI使用Google Gemini 3.1 Flash Image Preview(Nano Banana 2)生成图片。功能包括:文本转图片、图片编辑、多图输入(最多14张)、Google搜索 grounding。触发词:nano banana 2、nanobanana 2、gemini 3.1 flash image、gemini 3 1 flash image preview、google image generation
npx skill4agent add inference-sh-9/skills nano-banana-2curl -fsSL https://cli.inference.sh | sh && infsh login
infsh app run google/gemini-3-1-flash-image-preview --input '{"prompt": "a banana in space, photorealistic"}'infsh app run google/gemini-3-1-flash-image-preview --input '{
"prompt": "A futuristic cityscape at sunset with flying cars"
}'infsh app run google/gemini-3-1-flash-image-preview --input '{
"prompt": "Minimalist logo design for a coffee shop",
"num_images": 4
}'infsh app run google/gemini-3-1-flash-image-preview --input '{
"prompt": "Panoramic mountain landscape with northern lights",
"aspect_ratio": "16:9"
}'infsh app run google/gemini-3-1-flash-image-preview --input '{
"prompt": "Add a rainbow in the sky",
"images": ["https://example.com/landscape.jpg"]
}'infsh app run google/gemini-3-1-flash-image-preview --input '{
"prompt": "Detailed illustration of a medieval castle",
"resolution": "4K"
}'infsh app run google/gemini-3-1-flash-image-preview --input '{
"prompt": "Current weather in Tokyo visualized as an artistic scene",
"enable_google_search": true
}'| 参数 | 类型 | 说明 |
|---|---|---|
| string | 必填。要生成或修改的内容 |
| array | 用于编辑的输入图片(最多14张)。支持格式:JPEG、PNG、WebP |
| integer | 要生成的图片数量 |
| string | 输出比例:"1:1"、"16:9"、"9:16"、"4:3"、"3:4"、"auto" |
| string | 分辨率:"1K"、"2K"、"4K"(默认:1K) |
| string | 图片输出格式 |
| boolean | 启用实时信息 grounding(如天气、新闻等) |
| 字段 | 类型 | 说明 |
|---|---|---|
| array | 生成或编辑后的图片 |
| string | 模型返回的文本描述或响应 |
| object | 用于计费的输入/输出元数据 |
# 1. 生成示例输入以查看所有选项
infsh app sample google/gemini-3-1-flash-image-preview --save input.json
# 2. 编辑提示词
# 3. 运行
infsh app run google/gemini-3-1-flash-image-preview --input input.jsonfrom inferencesh import inference
client = inference()
# 基础生成
result = client.run({
"app": "google/gemini-3-1-flash-image-preview@0c7ma1ex",
"input": {
"prompt": "A banana in space, photorealistic"
}
})
print(result["output"])
# 流式获取实时更新
for update in client.run({
"app": "google/gemini-3-1-flash-image-preview@0c7ma1ex",
"input": {
"prompt": "A futuristic cityscape at sunset"
}
}, stream=True):
if update.get("progress"):
print(f"progress: {update['progress']}%")
if update.get("output"):
print(f"output: {update['output']}")# 原版Nano Banana(Gemini 3 Pro Image、Gemini 2.5 Flash Image)
npx skills add inference-sh/skills@nano-banana
# 全平台技能(包含150+应用)
npx skills add inference-sh/skills@inference-sh
# 所有图片生成模型
npx skills add inference-sh/skills@ai-image-generationinfsh app list --category image