elksmmx a065e3b294 feat:0309 hai 9 horas
..
tool a065e3b294 feat:0309 hai 9 horas
README.md a065e3b294 feat:0309 hai 9 horas
run.py a065e3b294 feat:0309 hai 9 horas
test.prompt a065e3b294 feat:0309 hai 9 horas

README.md

NanoBanana 工具测试

测试 nanobanana 图像生成工具的功能。

工具描述

nanobanana: 通用的图像生成工具,根据文本描述和/或参考图像生成图片。输出格式只有图片,不能输出文字。

测试场景

测试1: 纯文本生成图像

  • 输入:文本描述
  • 输出:生成的图像
  • 示例:生成一只可爱的橙色小猫

测试2: 基于参考图像生成

  • 输入:参考图像 + 文本描述
  • 输出:转换后的图像
  • 示例:将图片转换为油画风格

使用方法

1. 准备环境

确保已设置 OpenRouter API Key:

export OPENROUTER_API_KEY="your-api-key"
# 或
export OPEN_ROUTER_API_KEY="your-api-key"

2. 准备测试图片(可选)

如果要测试图像转换功能,请在 input/ 目录中放置测试图片:

cp your-test-image.png examples/test_nanobanana/input/

3. 运行测试

cd /Users/elksmmx/Desktop/agent\ 2.10/Agent
python examples/test_nanobanana/run.py

输出

生成的图片将保存在 output/ 目录中:

  • output/cat.png - 测试1生成的图片
  • output/transformed.png - 测试2生成的图片

目录结构

test_nanobanana/
├── README.md           # 本文件
├── run.py             # 测试脚本
├── tool/              # 自定义工具
│   ├── __init__.py
│   └── nanobanana.py  # nanobanana工具实现
├── input/             # 测试图片输入目录
├── output/            # 生成图片输出目录
└── .trace/            # 执行轨迹(自动生成)

注意事项

  1. API Key: 必须配置 OpenRouter API Key
  2. 模型: 默认使用 google/gemini-2.5-flash-image 模型
  3. 费用: 图像生成会消耗 API 额度
  4. 输出格式: 工具只输出图片,不输出文字描述

常见问题

Q: 提示 "未找到 OpenRouter API Key"

A: 请设置环境变量 OPENROUTER_API_KEYOPEN_ROUTER_API_KEY

Q: 生成失败,提示模型不可用

A: 检查 OpenRouter 账户是否有足够额度,或尝试其他模型

Q: 想要测试其他模型

A: 修改 run.py 中的模型参数,或在调用时指定 model 参数