sub2api-imagegen-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sub2api-imagegen-mcpGenerate a sticker of an orange cat in a yellow raincoat."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.

Sub2API ImageGen MCP
使用已有的 Sub2API API Key,让 Codex 生成和编辑图片。
能干什么
这个本地 MCP 提供 sub2api_imagegen.imagegen 工具,可生成图片,也可用 1–5
张本地参考图进行编辑。图片会返回给 Codex,并以私有权限保存到本地。
它通过 STDIO 工作,不监听端口,也无需修改 Sub2API。你的实例只需支持:
POST /v1/images/generationsPOST /v1/images/edits返回
data[0].b64_json
注意:它不是 Codex 内置的 image_gen,调用时请明确指定
sub2api_imagegen.imagegen。
Related MCP server: Imagen MCP Server
一键安装
需要 Node.js >=20.19.0、Git、npm,以及可执行 codex mcp 的 Codex。
Windows
在 Windows PowerShell 5.1 或 PowerShell 7 中运行:
powershell -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; irm 'https://raw.githubusercontent.com/BillSJC/sub2api-imagegen-mcp/main/install.ps1' | iex"macOS / Linux / WSL2
curl -fsSL https://raw.githubusercontent.com/BillSJC/sub2api-imagegen-mcp/main/install.sh | bash按提示输入 Sub2API 地址和 Key。安装器会:
将 Key 保存在仓库外,并限制为当前用户可读;不写入仓库、
config.toml或命令历史;构建 MCP、更新 Codex 配置,并在失败时恢复原配置;
保留 Key、配置备份和已生成图片,重复运行同一命令即可升级。
安装完成后,完全退出并重新启动 Codex,新建任务运行 /mcp,确认
sub2api_imagegen 已连接。
默认上游超时为 10 分钟,Codex 工具超时为 11 分钟。大图可在升级时提高到最大 15/16 分钟:
$env:SUB2API_TIMEOUT_MS = "900000"
powershell -NoProfile -ExecutionPolicy Bypass -Command "irm 'https://raw.githubusercontent.com/BillSJC/sub2api-imagegen-mcp/main/install.ps1' | iex"curl -fsSL https://raw.githubusercontent.com/BillSJC/sub2api-imagegen-mcp/main/install.sh |
env SUB2API_TIMEOUT_MS=900000 bash使用示例
下面的例子都使用 1024x1024 和 quality: low,构图简单、通常耗时较短。直接
复制到 Codex 即可;每次调用仍可能产生费用。
雨衣橘猫贴纸
请使用 sub2api_imagegen.imagegen,只调用一次:
prompt: 一只穿亮黄色雨衣的圆脸橘猫,手拿小荷叶,扁平贴纸风格,粗黑轮廓,三种颜色,纯白背景,居中,无文字
size: 1024x1024
quality: low
background: opaque
output_name: raincoat-cat
完成后返回本地保存路径。玻璃罐里的月球营地
请使用 sub2api_imagegen.imagegen,只调用一次:
prompt: 透明玻璃罐里的一座迷你月球营地,一顶橙色帐篷、一名小宇航员和两块岩石,等距 3D 玩具风,深蓝纯色背景,柔和灯光,无文字
size: 1024x1024
quality: low
background: opaque
output_name: moon-camp-jar
完成后返回本地保存路径。午夜拉面机器人
请使用 sub2api_imagegen.imagegen,只调用一次:
prompt: 一个圆滚滚的小机器人在午夜街边煮拉面,红蓝双色丝网印刷风格,简单几何形状,米白背景,居中,无文字
size: 1024x1024
quality: low
background: opaque
output_name: ramen-robot
完成后返回本地保存路径。编辑刚生成的图片
把路径替换为真实的绝对路径:
请使用 sub2api_imagegen.imagegen,只调用一次:
prompt: 保持主体、构图和画风不变,只把背景改成柔和的薄荷绿色
referenced_image_paths: ["/绝对路径/raincoat-cat.png"]
size: 1024x1024
quality: low
background: opaque
output_name: raincoat-cat-mint
完成后返回本地保存路径。其他内容
关键限制
无参考图时调用
/v1/images/generations,有参考图时调用/v1/images/edits。默认模型为
gpt-image-2,上游必须返回 base64 图片。参考图支持 PNG、JPEG、WebP;必须是绝对路径、普通文件且不能是符号链接。
MCP 不自动重试。超时不代表上游任务已取消;再次调用前先检查 Sub2API 请求和 计费状态。
默认
writes审批用于避免意外产生费用。
工具参数
参数 | 可选值或说明 |
| 必填,生成或编辑指令 |
| 可选,1–5 个本地绝对路径 |
|
|
|
|
|
|
| 可选,本地文件名;危险字符会被过滤,同名不会覆盖 |
常用环境变量:SUB2API_IMAGE_MODEL、SUB2API_TIMEOUT_MS、
SUB2API_MAX_INPUT_IMAGE_BYTES、SUB2API_MAX_RESPONSE_BYTES。长期使用 Key
文件;SUB2API_API_KEY 与 SUB2API_API_KEY_FILE 只能设置一个。
验收与卸载
重启 Codex,在新任务运行
/mcp。确认
sub2api_imagegen已连接并列出imagegen。运行一个低质量示例,确认 Codex 返回图片、本地出现文件、Sub2API 只有一条 对应请求。
用生成图片的绝对路径执行一次编辑,确认请求进入
/v1/images/edits。
只移除 Codex 注册项:
codex mcp remove sub2api_imagegen这不会删除 Key、图片、源码或配置备份。
常见问题
症状 | 处理 |
提示 | 这是另一个工具;重启后在新任务明确调用 |
MCP 不出现 | 检查 |
| 只设置一个 Key 来源;Key 文件须为绝对路径、普通文件、非链接,并限制为当前用户可读 |
HTTP 401/403 | 检查 Key、余额、分组状态、图片权限和可用模型 |
HTTP 404 | 检查 Sub2API 地址和两个图片端点 |
超时 | 升级时将 |
只有 URL,没有 | 确认 Sub2API/上游接受 |
| 非交互任务无法完成 |
开发与安全
npm ci
npm run check测试全部使用模拟响应,不需要真实 Key,也不会产生费用。CI 在 Ubuntu 和 Windows 运行,并扫描当前文件及 Git 历史中的常见凭据模式。更多说明见 SECURITY.md。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseBqualityDmaintenanceEnables AI assistants to generate high-quality images using OpenAI's DALL-E 3 model with configurable parameters like size, quality, and style. Generated images are automatically saved to the local filesystem with comprehensive error handling.Last updated1
- Alicense-qualityCmaintenanceEnables AI assistants to generate high-quality images using Google's Gemini and Imagen models with support for multiple aspect ratios, dynamic model selection, and direct file saving capabilities.Last updatedMIT
- AlicenseAqualityCmaintenanceEnables image generation and editing using OpenAI's GPT Image API (gpt-image-1, 1.5, 2) with support for multi-image generation, history management, and batch processing.Last updated12541MIT
- Flicense-qualityDmaintenanceProvides AI agents and coding assistants with image generation and editing capabilities using OpenAI's GPT-image-1 model, with support for local or Supabase storage.Last updated3
Related MCP Connectors
Generate, edit and upscale AI video and images from any agent via VicSee.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Generate images, GIFs, and PDFs from HTML, URLs, or templates — from your AI agent.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/BillSJC/sub2api-imagegen-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server