Summary
- 通过逆向工程的 Gemini Web API 进行文本和图像生成。
- 核心能力:
- - 文本生成: 使用 Gemini 模型生成文本响应
- - 图像生成: 从文本提示生成图像并保存到本地
- - 视觉输入: 支持参考图像进行图生图或图生文
- - 多轮对话: 通过 sessionId 保持上下文连续性
- 使用时机:
- -…
plugins-world/pw-skills
通过逆向工程的 Gemini Web API 进行文本和图像生成。 核心能力: - 文本生成: 使用 Gemini 模型生成文本响应 - 图像生成: 从文本提示生成图像并保存到本地 - 视觉输? - 多轮对话: 通过 sessionId 保持上下文连续性 使用时机: - 需要生成高质量 AI 图像时 (封面图、? - 需要 Gemini 模型进行文本生成时 - 需要基于参考图像生成变体或描述时 - 作为? 不适用场景: - 需要官方 API 支持和稳定性保证的生产环境 - 对 API 变更敏感的? - 需要批量高频调用的场景 (可能触发限流) 重要提醒: - 首次使用需要用户同意? - 需要 Google 账号认证 (自…
npx skills add plugins-world/pw-skills --skill pw-danger-gemini-web
Related neighbors and high-traction skills in the same topics — useful to compare before installing.
Converts X (Twitter) tweets and articles to markdown with YAML front matter. Uses reverse-engin…
27.1K installsGenerates images and text via reverse-engineered Gemini Web API. Supports text generation, imag…
27K installsGenerates images and text via reverse-engineered Gemini Web API.
484 installsConverts X (Twitter) tweets and articles to markdown with YAML front matter. Uses reverse-engin…
474 installsGenerates images and text via reverse-engineered Gemini Web API. Supports text generation, imag…
173 installsGenerates images and text via reverse-engineered Gemini Web API.
168 installsOther skills from plugins-world/pw-skills.
npx skills add plugins-world/pw-skills
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
Alternate registries and mirrors of this skill.
npx skills add smithery/plugins-world --skill pw-danger-gemini-web
main
Files included with this skill beyond the listing page.
SKILL.md
22,053 B
SUMMARY.md
983 B
支持功能:
--sessionId 进行多轮对话重要: 所有脚本位于此技能的 scripts/ 子目录中。
Agent 执行说明:
SKILL_DIR${SKILL_DIR}/scripts/<script-name>.ts${SKILL_DIR} 替换为实际路径脚本参考:
| 脚本 | 用途 |
|---|---|
scripts/main.ts |
文本/图像生成的 CLI 入口点 |
scripts/gemini-webapi/* |
gemini_webapi 的 TypeScript 移植版(GeminiClient、类型、工具) |
使用此技能前,必须执行同意检查。
步骤 1: 检查同意文件
# macOS
cat ~/Library/Application\ Support/pw-skills/gemini-web/consent.json 2>/dev/null
# Linux
cat ~/.local/share/pw-skills/gemini-web/consent.json 2>/dev/null
# Windows (PowerShell)
Get-Content "$env:APPDATA\pw-skills\gemini-web\consent.json" 2>$null
步骤 2: 如果同意文件存在且 accepted: true 并匹配 disclaimerVersion: "1.0":
打印警告并继续:
⚠️ 警告: 使用逆向工程的 Gemini Web API(非官方)。接受时间: <acceptedAt 日期>
步骤 3: 如果同意文件不存在或 disclaimerVersion 不匹配:
显示免责声明并询问用户:
⚠️ 免责声明
此工具使用逆向工程的 Gemini Web API,而非官方 Google API。
风险:
- 如果 Google 更改其 API,可能会在没有通知的情况下失效
- 没有官方支持或保证
- 使用风险自负
您是否接受这些条款并希望继续?
使用 AskUserQuestion 工具,选项为:
步骤 4: 接受后,创建同意文件:
# macOS
mkdir -p ~/Library/Application\ Support/pw-skills/gemini-web
cat > ~/Library/Application\ Support/pw-skills/gemini-web/consent.json << 'EOF'
{
"version": 1,
"accepted": true,
"acceptedAt": "<ISO 时间戳>",
"disclaimerVersion": "1.0"
}
EOF
# Linux
mkdir -p ~/.local/share/pw-skills/gemini-web
cat > ~/.local/share/pw-skills/gemini-web/consent.json << 'EOF'
{
"version": 1,
"accepted": true,
"acceptedAt": "<ISO 时间戳>",
"disclaimerVersion": "1.0"
}
EOF
步骤 5: 拒绝后,输出消息并停止:
用户拒绝了免责声明。退出。
npx -y bun ${SKILL_DIR}/scripts/main.ts "你好,Gemini"
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "解释量子计算"
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "一只可爱的猫" --image cat.png
npx -y bun ${SKILL_DIR}/scripts/main.ts --promptfiles system.md content.md --image out.png
# 多轮对话(agent 生成唯一的 sessionId)
npx -y bun ${SKILL_DIR}/scripts/main.ts "记住这个: 42" --sessionId my-unique-id-123
npx -y bun ${SKILL_DIR}/scripts/main.ts "什么数字?" --sessionId my-unique-id-123
# 简单提示(位置参数)
npx -y bun ${SKILL_DIR}/scripts/main.ts "你的提示内容"
# 显式提示标志
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "你的提示内容"
npx -y bun ${SKILL_DIR}/scripts/main.ts -p "你的提示内容"
# 选择模型
npx -y bun ${SKILL_DIR}/scripts/main.ts -p "你好" -m gemini-2.5-pro
# 从标准输入管道
echo "总结这个" | npx -y bun ${SKILL_DIR}/scripts/main.ts
# 使用默认路径生成图像(./generated.png)
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "山上的日落" --image
# 使用自定义路径生成图像
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "一个可爱的机器人" --image robot.png
# 简写形式
npx -y bun ${SKILL_DIR}/scripts/main.ts "一条龙" --image=dragon.png
# 文本 + 图像 -> 文本
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "描述这张图片" --reference a.png
# 文本 + 图像 -> 图像
npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "生成一个变体" --reference a.png --image out.png
# 纯文本(默认)
npx -y bun ${SKILL_DIR}/scripts/main.ts "你好"
# JSON 输出
npx -y bun ${SKILL_DIR}/scripts/main.ts "你好" --json
--prompt <text> (别名: -p)
--prompt "生成一只可爱的猫咪"--promptfiles <files...>
--promptfiles system.md content.md--model <id> (别名: -m)
- gemini-3-pro (默认): 最新最强模型,推荐使用 - gemini-2.5-pro: 上一代 pro 版本,稳定性好 - gemini-2.5-flash: 快速轻量,适合简单任务
--model gemini-2.5-flash- 图像生成: 使用 gemini-3-pro 获得最佳质量 - 简单文本: 使用 gemini-2.5-flash 提高速度 - 复杂推理: 使用 gemini-3-pro
--image [path]
generated.png (如果只写 --image 不带路径)- --image (保存为 generated.png) - --image cat.png (保存为 cat.png) - --image=/path/to/output.png (使用等号语法)
- 路径可以是相对路径或绝对路径 - 目录必须存在,否则会报错 - 支持 PNG 格式
--reference <files...> (别名: --ref)
- --reference photo.jpg (单张图片) - --reference img1.png img2.png (多张图片)
- 图生文: 描述图片内容 - 图生图: 基于参考图生成变体 - 图文结合: 结合图片和文字提示
--sessionId <id>
--sessionId task-abc123- 需要保持上下文的连续对话 - 批量处理同一主题的多个任务 - 需要 Gemini 记住之前的交互
- Agent 应生成唯一的 session ID (如 UUID 或基于任务的 hash) - 同一批次任务使用相同 session ID - 不同主题使用不同 session ID
--list-sessions
--json
``json { "text": "生成的文本内容", "imagePath": "/path/to/image.png", "sessionId": "task-abc123" } ``
--login
- Cookie 过期需要重新登录 - 切换 Google 账号 - 预先完成认证避免后续中断
--cookie-path <path>
--profile-dir <path>
--help (别名: -h)
gemini-3-pro - 默认,最新模型gemini-2.5-pro - 上一代 pro 版本gemini-2.5-flash - 快速、轻量级首次运行会打开浏览器进行 Google 认证。Cookies 会被缓存以供后续运行使用。
支持的浏览器(按顺序自动检测):
如需要,可使用 GEMINIWEBCHROME_PATH 环境变量覆盖。
# 强制刷新 cookie
npx -y bun ${SKILL_DIR}/scripts/main.ts --login
登录说明:
| 变量 | 说明 |
|---|---|
GEMINIWEBDATA_DIR |
数据目录 |
GEMINIWEBCOOKIE_PATH |
Cookie 文件路径 |
GEMINIWEBCHROMEPROFILEDIR |
Chrome 配置文件目录 |
GEMINIWEBCHROME_PATH |
Chrome 可执行文件路径 |
如果需要代理访问 Google 服务(例如在中国),请在运行前设置 HTTPPROXY 和 HTTPSPROXY 环境变量:
# 使用本地代理的示例
HTTP_PROXY=http://127.0.0.1:7890 HTTPS_PROXY=http://127.0.0.1:7890 npx -y bun ${SKILL_DIR}/scripts/main.ts "你好"
# 使用代理生成图像
HTTP_PROXY=http://127.0.0.1:7890 HTTPS_PROXY=http://127.0.0.1:7890 npx -y bun ${SKILL_DIR}/scripts/main.ts --prompt "一只猫" --image cat.png
# 使用代理刷新 cookie
HTTP_PROXY=http://127.0.0.1:7890 HTTPS_PROXY=http://127.0.0.1:7890 npx -y bun ${SKILL_DIR}/scripts/main.ts --login
注意: 环境变量必须与命令内联设置。Shell 配置文件设置(如 .bashrc)可能不会被子进程继承。
npx -y bun ${SKILL_DIR}/scripts/main.ts "法国的首都是什么?"
npx -y bun ${SKILL_DIR}/scripts/main.ts "一张金毛猎犬幼犬的逼真照片" --image puppy.png
npx -y bun ${SKILL_DIR}/scripts/main.ts "你好" --json | jq '.text'
# 将 system.md + content.md 连接作为提示
npx -y bun ${SKILL_DIR}/scripts/main.ts --promptfiles system.md content.md --image output.png
# 使用唯一 ID 开始会话(agent 生成此 ID)
npx -y bun ${SKILL_DIR}/scripts/main.ts "你是一个有帮助的数学导师。" --sessionId task-abc123
# 继续对话(记住上下文)
npx -y bun ${SKILL_DIR}/scripts/main.ts "2+2 等于多少?" --sessionId task-abc123
npx -y bun ${SKILL_DIR}/scripts/main.ts "现在乘以 10" --sessionId task-abc123
# 列出最近的会话(最多 100 个,按更新时间排序)
npx -y bun ${SKILL_DIR}/scripts/main.ts --list-sessions
批量处理最佳实践:
# 为目录生成固定的 session ID(使用目录路径的 hash)
DIR_PATH="/path/to/project"
SESSION_ID=$(echo -n "$DIR_PATH" | md5sum | cut -d' ' -f1)
# 批量处理该目录下的文件,使用同一个 session ID
npx -y bun ${SKILL_DIR}/scripts/main.ts "生成第一张图" --sessionId "$SESSION_ID" --image img1.png
npx -y bun ${SKILL_DIR}/scripts/main.ts "生成第二张图" --sessionId "$SESSION_ID" --image img2.png
npx -y bun ${SKILL_DIR}/scripts/main.ts "生成第三张图" --sessionId "$SESSION_ID" --image img3.png
会话文件存储在 ~/Library/Application Support/pw-skills/gemini-web/sessions/<id>.json 中,包含:
id: 会话 IDmetadata: 用于继续的 Gemini 聊天元数据messages: {role, content, timestamp, error?} 数组createdAt, updatedAt: 时间戳通过 EXTEND.md 进行自定义配置。
检查路径 (优先级顺序):
.pw-skills/pw-danger-gemini-web/EXTEND.md (项目级)~/.pw-skills/pw-danger-gemini-web/EXTEND.md (用户级)如果找到,在工作流之前加载。扩展内容会覆盖默认值。
错误: "Cookie expired" 或 "Authentication failed"
``bash # 重新登录刷新 cookie npx -y bun ${SKILL_DIR}/scripts/main.ts --login ``
错误: "Browser not found"
- 安装 Chrome、Chromium 或 Edge - 或使用环境变量指定浏览器路径: ``bash GEMINIWEBCHROMEPATH=/path/to/chrome npx -y bun ${SKILLDIR}/scripts/main.ts --login ``
错误: "Login timeout" 或登录窗口一直等待
- 确保在浏览器中完成完整的登录流程 - 处理多因素认证 (如果启用) - 登录成功后浏览器会在 3 秒后自动关闭 - 没有超时限制,可以慢慢完成登录
错误: "Connection refused" 或 "Network error"
``bash HTTPPROXY=http://127.0.0.1:7890 HTTPSPROXY=http://127.0.0.1:7890 \ npx -y bun ${SKILL_DIR}/scripts/main.ts "你好" ``
错误: "Rate limit exceeded"
- 降低请求频率 - 在请求之间添加延迟 - 避免短时间内大量请求
错误: "Failed to save image" 或 "Directory not found"
``bash # 确保目录存在 mkdir -p /path/to/output npx -y bun ${SKILL_DIR}/scripts/main.ts "一只猫" --image /path/to/output/cat.png ``
错误: "Image generation failed"
- 检查提示是否清晰明确 - 避免违反内容政策的提示 - 尝试重新表述提示 - 使用不同的模型 (如 gemini-3-pro)
错误: "Reference image not found"
- 检查文件路径是否正确 - 使用绝对路径避免相对路径问题 - 确保文件格式受支持 (PNG, JPG, JPEG, WebP)
错误: "Session not found"
- 使用 --list-sessions 查看可用会话 - 确保 session ID 拼写正确 - 首次使用会自动创建新会话
错误: "Session corrupted"
``bash # 删除损坏的会话文件 rm ~/Library/Application\ Support/pw-skills/gemini-web/sessions/<session-id>.json # 或在 Linux 上 rm ~/.local/share/pw-skills/gemini-web/sessions/<session-id>.json ``
错误: "Bun not found"
npx -y bun 会自动下载 Bun,无需手动安装错误: "Permission denied"
- 检查输出目录权限 - 检查数据目录权限 - 使用有权限的路径
1. Session ID 管理
task-<uuid> 或 project-<hash>``bash # 为目录生成固定 session ID SESSION_ID=$(echo -n "/path/to/project" | md5sum | cut -d' ' -f1) ``
2. 错误处理
--json 输出便于解析结果``bash if ! output=$(npx -y bun ${SKILL_DIR}/scripts/main.ts "test" --json 2>&1); then echo "Error: $output" exit 1 fi ``
3. 代理配置
``bash # 检测是否需要代理 if [[ $(curl -s -o /dev/null -w "%{http_code}" https://gemini.google.com) != "200" ]]; then echo "提示: 可能需要配置代理访问 Google 服务" fi ``
4. 批量处理
--json 输出便于批量解析``bash for file in *.txt; do npx -y bun ${SKILLDIR}/scripts/main.ts \ --promptfiles "$file" \ --sessionId "$SESSIONID" \ --image "${file%.txt}.png" \ --json sleep 2 # 避免限流 done ``
1. 提示词优化
2. 模型选择
gemini-3-progemini-2.5-flashgemini-3-pro3. 参考图像使用
``bash # 基于参考图生成变体 npx -y bun ${SKILL_DIR}/scripts/main.ts \ --prompt "生成一个卡通风格的变体,保持主体不变" \ --reference original.jpg \ --image cartoon.png ``
1. 上下文管理
```bash # 第一轮: 设置角色 npx -y bun ${SKILL_DIR}/scripts/main.ts \ "你是一个专业的图像描述专家" \ --sessionId img-desc-001
# 后续轮次: 描述图像 npx -y bun ${SKILL_DIR}/scripts/main.ts \ --prompt "描述这张图片" \ --reference photo.jpg \ --sessionId img-desc-001 ```
2. 会话清理
--list-sessions 查看会话列表```bash # macOS rm ~/Library/Application\ Support/pw-skills/gemini-web/sessions/<id>.json
# Linux rm ~/.local/share/pw-skills/gemini-web/sessions/<id>.json ```
1. 减少不必要的请求
--promptfiles 组合多个文件2. 并行处理
3. 缓存策略
1. 凭证管理
2. 内容审查
3. 数据隐私
遇到问题时,按以下顺序检查:
``bash curl -I https://gemini.google.com `` - 如果失败,配置代理
``bash npx -y bun ${SKILL_DIR}/scripts/main.ts --login `` - 重新登录刷新 cookie
``bash which chrome || which chromium || which microsoft-edge `` - 确保安装了支持的浏览器
``bash ls -la ~/Library/Application\ Support/pw-skills/gemini-web/ `` - 确保有读写权限
``bash mkdir -p /path/to/output && ls -la /path/to/output `` - 确保目录存在且可写
``bash npx -y bun ${SKILL_DIR}/scripts/main.ts "test" 2>&1 | tee error.log `` - 保存完整错误日志
```bash # 测试文本生成 npx -y bun ${SKILL_DIR}/scripts/main.ts "你好"
# 测试图像生成 npx -y bun ${SKILL_DIR}/scripts/main.ts "一只猫" --image test.png ```
已知限制:
不支持的功能:
性能特征:
查看项目 Git 历史了解最新变更:
cd ${SKILL_DIR}
git log --oneline --decorate