setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MeiGen Plugin Setup

MeiGen插件设置

You are guiding the user through configuring the MeiGen plugin for image generation. Follow this flow step by step.
你将引导用户完成用于图片生成的MeiGen插件配置,请按以下步骤逐步操作。

Step 1: Welcome

步骤1:欢迎

First, check if a config file already exists:
bash
cat ~/.config/meigen/config.json 2>/dev/null
Also check for existing ComfyUI workflows:
bash
ls ~/.config/meigen/workflows/*.json 2>/dev/null
If config exists, show the current configuration (mask API keys: show first 10 chars + "...") and any saved workflows. Ask if they want to reconfigure.
If no config exists, present this introduction:
MeiGen Plugin Configuration
This is optional. Without configuration, you can still use free features:
  • Search gallery for inspiration and prompts
  • Enhance simple ideas into professional prompts
  • Browse available AI models
Configuring a provider unlocks image generation.
Then proceed to Step 2.
首先,检查配置文件是否已存在:
bash
cat ~/.config/meigen/config.json 2>/dev/null
同时检查是否存在已有的ComfyUI工作流:
bash
ls ~/.config/meigen/workflows/*.json 2>/dev/null
如果配置已存在,显示当前配置(隐藏API密钥:显示前10个字符+“...”)以及所有已保存的工作流。询问用户是否需要重新配置。
如果配置不存在,展示以下介绍内容:
MeiGen插件配置
此配置为可选操作。未配置时,你仍可使用免费功能:
  • 搜索灵感图库及提示词
  • 将简单想法优化为专业提示词
  • 浏览可用AI模型
配置提供商后即可解锁图片生成功能。
之后进入步骤2。

Step 2: Choose Provider

步骤2:选择提供商

Present these options to the user:
为用户提供以下选项:

Option A: MeiGen Platform (Recommended)

选项A:MeiGen平台(推荐)

  • Supports Nanobanana Pro, GPT image 1.5, Seedream 4.5 and more
  • Reference image support for style transfer
  • No additional accounts needed — just get a token from meigen.ai
  • 支持Nanobanana ProGPT image 1.5Seedream 4.5等更多模型
  • 支持参考图片进行风格迁移
  • 无需额外注册账号——只需从meigen.ai获取令牌

Option B: ComfyUI (Local)

选项B:ComfyUI(本地)

  • Use your local ComfyUI installation for image generation
  • Full control over models, samplers, and workflow settings
  • No cloud API needed — runs entirely on your machine
  • Import your own workflow from ComfyUI
  • 使用本地ComfyUI安装环境进行图片生成
  • 完全控制模型、采样器及工作流设置
  • 无需云API——完全在本地设备运行
  • 可从ComfyUI导入自定义工作流

Option C: Custom OpenAI-Compatible API

选项C:自定义OpenAI兼容API

  • Use your own OpenAI, Together AI, Fireworks AI, or any OpenAI-compatible service
  • Bring your own API key and billing
  • Supports any model that uses the OpenAI
    /v1/images/generations
    endpoint
  • 使用自有OpenAITogether AIFireworks AI或任何OpenAI兼容服务
  • 自带API密钥及计费方式
  • 支持所有使用OpenAI
    /v1/images/generations
    接口的模型

Option D: Import from curl Example

选项D:从curl示例导入

  • Already have a working curl command from your API provider's docs? Paste it directly!
  • We'll automatically extract the API key, base URL, and model name
  • 已有API提供商文档中的可用curl命令?直接粘贴即可!
  • 系统将自动提取API密钥、基础URL及模型名称

Option E: Skip image generation for now

选项E:暂时跳过图片生成配置

  • Free features still available (inspiration search, prompt enhancement, model listing)
  • You can run
    /meigen:setup
    anytime later to enable image generation
If user chooses Skip, say goodbye and exit. Otherwise continue to the appropriate Step 3.
  • 仍可使用免费功能(灵感搜索、提示词优化、模型列表浏览)
  • 之后随时运行
    /meigen:setup
    即可启用图片生成功能
如果用户选择跳过,告知用户并退出流程。否则进入对应步骤3。

Step 3A: MeiGen Platform Setup

步骤3A:MeiGen平台设置

Ask the user:
Do you already have a MeiGen API token, or do you need to create one?
询问用户:
你是否已拥有MeiGen API令牌,还是需要创建新令牌?

If they need to create one:

如果用户需要创建令牌:

Provide these instructions:
  1. Go to https://www.meigen.ai
  2. Sign in or create an account
  3. Navigate to Settings (click your avatar) → API Keys
  4. Click Create API Key, give it a name
  5. Copy the token (starts with
    meigen_sk_
    )
Then ask them to paste the token.
提供以下操作说明:
  1. 访问https://www.meigen.ai
  2. 登录或创建账号
  3. 进入设置(点击头像)→ API密钥
  4. 点击创建API密钥,为其命名
  5. 复制令牌(以
    meigen_sk_
    开头)
之后请用户粘贴该令牌。

If they already have one:

如果用户已拥有令牌:

Ask them to paste their
meigen_sk_...
token.
请用户粘贴其
meigen_sk_...
格式的令牌。

Validate the token:

验证令牌:

  • Must start with
    meigen_sk_
  • Must be at least 30 characters long
If valid, proceed to Step 4 with this config:
json
{
  "meigenApiToken": "<the token>"
}
  • 必须以
    meigen_sk_
    开头
  • 长度至少为30个字符
如果验证通过,使用以下配置进入步骤4
json
{
  "meigenApiToken": "<令牌内容>"
}

Step 3B: ComfyUI (Local) Setup

步骤3B:ComfyUI(本地)设置

3B-1: Check Connection

3B-1:检查连接

Ask the user for their ComfyUI server URL:
What is your ComfyUI server URL? (default:
http://localhost:8188
)
Test the connection:
bash
curl -s <URL>/system_stats | head -c 200
  • Success: Show confirmation and continue to 3B-2
  • Failure: Tell the user:
    Cannot connect to ComfyUI at
    <URL>
    . Please make sure:
    1. ComfyUI is running (start it with
      python main.py
      or your launcher)
    2. The URL and port are correct
    3. No firewall is blocking the connection
询问用户ComfyUI服务器地址:
你的ComfyUI服务器地址是什么?(默认:
http://localhost:8188
测试连接:
bash
curl -s <URL>/system_stats | head -c 200
  • 连接成功:显示确认信息并进入3B-2
  • 连接失败:告知用户:
    无法连接到
    <URL>
    地址的ComfyUI。请确保:
    1. ComfyUI已启动(使用
      python main.py
      或启动器运行)
    2. 地址及端口正确
    3. 无防火墙阻止连接

3B-2: Import Workflow

3B-2:导入工作流

Explain the workflow export process to the user:
To use ComfyUI with this plugin, you need to export a workflow in API format:
  1. Open ComfyUI in your browser (usually
    http://localhost:8188
    )
  2. Load or create your preferred workflow
  3. Click ⚙️ Settings → enable "Enable Dev mode options"
  4. Click the "Save (API Format)" button that appears
  5. Save the downloaded
    .json
    file somewhere convenient
Then ask them to provide the file path:
Please provide the path to your exported workflow JSON file: Example:
~/Downloads/workflow_api.json
Use the
comfyui_workflow
tool with action
import
to import the workflow:
  • Ask for a short name for the workflow (e.g., "txt2img", "anime", "realistic")
  • Call:
    comfyui_workflow import
    with
    filePath
    and
    name
  • Show the detected nodes and parameters to the user for confirmation
If the import succeeds, ask if they want to import additional workflows. If yes, repeat this step.
向用户说明工作流导出流程:
要在本插件中使用ComfyUI,你需要以API格式导出工作流:
  1. 在浏览器中打开ComfyUI(通常为
    http://localhost:8188
  2. 加载或创建你偏好的工作流
  3. 点击**⚙️ 设置** → 启用**“启用开发者模式选项”**
  4. 点击出现的**“保存(API格式)”**按钮
  5. 将下载的
    .json
    文件保存至方便访问的位置
之后请用户提供文件路径:
请提供你导出的工作流JSON文件路径: 示例:
~/Downloads/workflow_api.json
使用
comfyui_workflow
工具并指定
import
动作来导入工作流:
  • 请用户为工作流设置简短名称(例如:“txt2img”、“anime”、“realistic”)
  • 调用:
    comfyui_workflow import
    并传入
    filePath
    name
    参数
  • 向用户展示检测到的节点及参数以确认
如果导入成功,询问用户是否需要导入更多工作流。如果是,重复此步骤。

3B-3: Save Configuration

3B-3:保存配置

Build the config JSON:
json
{
  "comfyuiUrl": "<the URL, omit if http://localhost:8188>",
  "comfyuiDefaultWorkflow": "<the first imported workflow name>"
}
Proceed to Step 4 to save. The workflow files are already saved by the import step.
构建配置JSON:
json
{
  "comfyuiUrl": "<服务器地址,默认地址可省略>",
  "comfyuiDefaultWorkflow": "<首个导入的工作流名称>"
}
进入步骤4保存配置。工作流文件已在导入步骤中完成保存。

Step 3C: Custom OpenAI-Compatible API Setup

步骤3C:自定义OpenAI兼容API设置

Collect the following information. Present common presets first for convenience:
收集以下信息。为方便操作,先展示常用预设:

Quick Presets

快速预设

ServiceBase URLDefault Model
OpenAI
https://api.openai.com
(default)
gpt-image-1.5
Together AI
https://api.together.xyz/v1
(check their docs)
Fireworks AI
https://api.fireworks.ai/inference/v1
(check their docs)
Ask the user to either pick a preset or provide custom values.
服务基础URL默认模型
OpenAI
https://api.openai.com
(默认)
gpt-image-1.5
Together AI
https://api.together.xyz/v1
(请查阅其官方文档)
Fireworks AI
https://api.fireworks.ai/inference/v1
(请查阅其官方文档)
询问用户选择预设或提供自定义参数。

Required Fields

必填字段

  1. API Key (required): Their API key for the service
    • Example:
      sk-...
      for OpenAI
  2. Base URL (optional): API endpoint URL
    • Default:
      https://api.openai.com
    • Only needed if using a non-OpenAI service
  3. Model Name (optional): Which model to use
    • Default:
      gpt-image-1.5
    • Different services use different model names
  1. API密钥(必填):对应服务的API密钥
    • 示例:OpenAI的密钥格式为
      sk-...
  2. 基础URL(可选):API接口地址
    • 默认:
      https://api.openai.com
    • 仅在使用非OpenAI服务时需要填写
  3. 模型名称(可选):要使用的模型
    • 默认:
      gpt-image-1.5
    • 不同服务使用的模型名称不同

Optional: Test the connection

可选:测试连接

After collecting the info, suggest testing with curl:
bash
curl -s <BASE_URL>/v1/models \
  -H "Authorization: Bearer <API_KEY>" | head -c 500
This helps catch invalid keys or wrong URLs before saving.
Proceed to Step 4 with config from the collected fields (see bottom of this section for format).
Only include fields that differ from defaults. Omit
openaiBaseUrl
if it's
https://api.openai.com
, omit
openaiModel
if it's
gpt-image-1.5
.
收集信息后,建议使用curl测试连接:
bash
curl -s <BASE_URL>/v1/models \
  -H "Authorization: Bearer <API_KEY>" | head -c 500
这有助于在保存配置前发现无效密钥或错误地址。
使用收集到的字段构建配置,进入步骤4(格式见本节末尾)。
仅保留与默认值不同的字段。如果
openaiBaseUrl
https://api.openai.com
则省略,如果
openaiModel
gpt-image-1.5
则省略。

Step 3D: Import from curl Example

步骤3D:从curl示例导入

Ask the user to paste their curl command. Common formats they might paste:
Format 1: Image generation endpoint
bash
curl https://api.openai.com/v1/images/generations \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-image-1.5", "prompt": "a cat", "n": 1, "size": "1024x1024"}'
Format 2: Simple model list test
bash
curl https://api.together.xyz/v1/models \
  -H "Authorization: Bearer xxx"
Format 3: With -u flag or other auth styles
bash
curl -u :sk-xxx https://api.fireworks.ai/inference/v1/images/generations \
  -d '{"model": "accounts/fireworks/models/flux", "prompt": "a cat"}'
请用户粘贴其curl命令。用户可能粘贴的常见格式如下:
格式1:图片生成接口
bash
curl https://api.openai.com/v1/images/generations \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-image-1.5", "prompt": "a cat", "n": 1, "size": "1024x1024"}'
格式2:简单模型列表测试
bash
curl https://api.together.xyz/v1/models \
  -H "Authorization: Bearer xxx"
格式3:带-u标志或其他认证方式
bash
curl -u :sk-xxx https://api.fireworks.ai/inference/v1/images/generations \
  -d '{"model": "accounts/fireworks/models/flux", "prompt": "a cat"}'

Parse the curl command and extract:

解析curl命令并提取信息:

  1. Base URL: The URL hostname + base path (strip
    /v1/images/generations
    ,
    /v1/models
    , etc.)
    • https://api.openai.com/v1/images/generations
      https://api.openai.com
    • https://api.together.xyz/v1/models
      https://api.together.xyz/v1
    • If URL ends with
      /v1/...
      , keep the
      /v1
      part only if it's NOT
      api.openai.com
  2. API Key: From
    Authorization: Bearer <key>
    header, or
    -u :<key>
    flag, or
    --header
    variants
  3. Model: From the JSON request body
    "model": "<value>"
    if present
  1. 基础URL:URL主机名+基础路径(移除
    /v1/images/generations
    /v1/models
    等后缀)
    • https://api.openai.com/v1/images/generations
      https://api.openai.com
    • https://api.together.xyz/v1/models
      https://api.together.xyz/v1
    • 如果URL以
      /v1/...
      结尾,仅当地址不是
      api.openai.com
      时保留
      /v1
      部分
  2. API密钥:从
    Authorization: Bearer <密钥>
    请求头、
    -u :<密钥>
    标志或
    --header
    变体中提取
  3. 模型:如果JSON请求体中存在
    "model": "<值>"
    ,则提取对应值

Show parsed results for confirmation:

展示解析结果供用户确认:

I extracted the following from your curl command:
  • API Key:
    sk-xxx...
    (first 10 chars)
  • Base URL:
    https://api.together.xyz/v1
  • Model:
    black-forest-labs/FLUX.1-schnell
Does this look correct?
If user confirms, proceed to Step 4. If not, let them correct individual fields.
已从你的curl命令中提取以下信息:
  • API密钥
    sk-xxx...
    (前10个字符)
  • 基础URL
    https://api.together.xyz/v1
  • 模型
    black-forest-labs/FLUX.1-schnell
以上信息是否正确?
如果用户确认,进入步骤4。如果不正确,允许用户修改单个字段。

Step 4: Save Configuration

步骤4:保存配置

Build the config JSON based on the chosen provider:
For MeiGen:
json
{
  "meigenApiToken": "<the token>"
}
For ComfyUI:
json
{
  "comfyuiUrl": "<url, omit if default>",
  "comfyuiDefaultWorkflow": "<workflow name>"
}
For OpenAI-compatible (manual or curl import):
json
{
  "openaiApiKey": "<the key>",
  "openaiBaseUrl": "<base url, omit if default>",
  "openaiModel": "<model, omit if default>"
}
Create the config directory and write the file:
bash
mkdir -p ~/.config/meigen
Then use the Write tool to write the JSON config to
~/.config/meigen/config.json
.
Important: If the user already has a config file with other providers configured, merge the new config into the existing one rather than overwriting. For example, a user might have both MeiGen and ComfyUI configured.
After writing, set permissions:
bash
chmod 600 ~/.config/meigen/config.json
根据用户选择的提供商构建配置JSON:
MeiGen平台配置:
json
{
  "meigenApiToken": "<令牌内容>"
}
ComfyUI配置:
json
{
  "comfyuiUrl": "<服务器地址,默认地址可省略>",
  "comfyuiDefaultWorkflow": "<工作流名称>"
}
OpenAI兼容API配置(手动或curl导入):
json
{
  "openaiApiKey": "<密钥内容>",
  "openaiBaseUrl": "<基础URL,默认地址可省略>",
  "openaiModel": "<模型名称,默认模型可省略>"
}
创建配置目录并写入文件:
bash
mkdir -p ~/.config/meigen
然后使用写入工具将JSON配置写入
~/.config/meigen/config.json
重要提示:如果用户已存在包含其他提供商配置的文件,请将新配置合并到现有文件中,而非覆盖。例如,用户可能同时配置了MeiGen和ComfyUI。
写入完成后,设置文件权限:
bash
chmod 600 ~/.config/meigen/config.json

Step 5: Completion

步骤5:配置完成

Tell the user:
Configuration saved! To activate the new settings, please start a new Claude Code session (close and reopen, or open a new terminal tab).
After restarting, you can:
  • Use
    generate_image
    to create AI images
  • Run
    list_models
    to see available models and workflows
  • Try: "Generate a beautiful sunset over mountains"
You can run
/meigen:setup
again anytime to change your configuration.
For ComfyUI users, additionally mention:
ComfyUI tips:
  • Use
    comfyui_workflow list
    to see your saved workflows
  • Use
    comfyui_workflow view
    to see adjustable parameters (steps, CFG, sampler, etc.)
  • Ask me to change any workflow parameter — e.g., "increase steps to 30" or "switch sampler to dpmpp_2m"
  • You can import more workflows anytime with
    comfyui_workflow import
告知用户:
配置已保存!请重启Claude Code会话(关闭并重新打开,或打开新终端标签页)以激活新设置。
重启后,你可以:
  • 使用
    generate_image
    命令生成AI图片
  • 运行
    list_models
    查看可用模型及工作流
  • 尝试输入:“生成一幅山脉上的绝美日落图”
你可随时再次运行
/meigen:setup
修改配置。
针对ComfyUI用户,额外补充:
ComfyUI使用提示:
  • 使用
    comfyui_workflow list
    查看已保存的工作流
  • 使用
    comfyui_workflow view
    查看可调整参数(步数、CFG、采样器等)
  • 可要求修改任意工作流参数——例如:“将步数增加至30”或“切换采样器为dpmpp_2m”
  • 你可随时使用
    comfyui_workflow import
    导入更多工作流