ComfyPilotComfyPilot
文档 / 开发 / 通过 Comfy Router 使用 MiniMax H3 Image

通过 Comfy Router 使用 MiniMax H3 Image

通过 Comfy Router 调用 minimax/minimax-h3-image:端点、请求形状以及 Router 返回的响应。

开发 code 更新于 2026-11-15

查看官方原文

通过 Comfy Router 使用 MiniMax H3 Image

通过 Comfy Router 调用 minimax/minimax-h3-image:端点、请求形状以及 Router 返回的响应。

minimax/minimax-h3-image 的 API 参考,由 Comfy Router 提供,模型来自 MiniMax。

输入: 文本、图像 · 输出: 图像

快速开始

在你的 Comfy 工作区中创建密钥,并将其导出为 COMFY_API_KEY。Python 和 TypeScript 代码片段使用 Comfy SDK(pip install comfy-sdk 和 npm install @comfyorg/sdk);cURL 代码片段则是通过原始 HTTP 发出的同一调用。

模型 ID: minimax/minimax-h3-image

端点: POST https://api.comfy.org/v2/models/minimax/minimax-h3-image

等待结果 ``python Python theme={null} from comfy_sdk import Comfy # 从环境变量读取 COMFY_API_KEY。 # SDK 会自动创建幂等键,并在自动重试时复用。 with Comfy() as client: result = client.models.run( "minimax/minimax-h3-image", { "area": "1K", "prompt": "A single red maple leaf resting on a plain white background.", }, ) print(result) ` `typescript TypeScript theme={null} import { comfy } from "@comfyorg/sdk"; // 从环境变量读取 COMFY_API_KEY。 // SDK 会自动创建幂等键,并在自动重试时复用。 const { data } = await comfy.models.run("minimax/minimax-h3-image", { area: "1K", prompt: "A single red maple leaf resting on a plain white background.", }); console.log(data); ` `bash cURL theme={null} curl https://api.comfy.org/v2/models/minimax/minimax-h3-image \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"area\": \"1K\", \"prompt\": \"A single red maple leaf resting on a plain white background.\"}" ``
排队并稍后收集 相同的请求体,发送到 POST https://api.comfy.org/v2/models/minimax/minimax-h3-image/requests。一旦运行被接纳,Router 就会返回 201 和一个 request_id,结果在就绪后即可收集,可由本进程或另一个进程完成。队列交付详细介绍了状态、取消与收集。 ``python Python theme={null} import asyncio from comfy_sdk import AsyncComfy # 从环境变量读取 COMFY_API_KEY。 # 每次调用 submit() 都会生成自己的 Idempotency-Key,并在自动重试时复用。 async def main(): async with AsyncComfy() as client: handle = await client.models.submit( "minimax/minimax-h3-image", { "area": "1K", "prompt": "A single red maple leaf resting on a plain white background.", }, ) print("request_id:", handle.request_id) # 配合模型 ID,这就是另一个进程所需的全部信息 # 轮询直到请求完成,等待服务器指定的 Retry-After。 async for update in handle.iter_events(): print(update.status, update.queue_position) # 提供商自己的载荷,与 models.run() 返回的值相同。 # 失败或已取消的请求会在这里抛出类型化的 Router 错误。 result = await handle.get() print(result) asyncio.run(main()) ` `typescript TypeScript theme={null} import { comfy } from "@comfyorg/sdk"; // 从环境变量读取 COMFY_API_KEY。 // 每次调用 submit() 都会生成自己的 Idempotency-Key,并在自动重试时复用。 const handle = await comfy.models.submit("minimax/minimax-h3-image", { area: "1K", prompt: "A single red maple leaf resting on a plain white background.", }); console.log("requestId:", handle.requestId); // 配合模型 ID,这就是另一个进程所需的全部信息 // 轮询直到请求完成,等待服务器指定的 Retry-After。 for await (const update of handle.events()) { console.log(update.status, update.queuePosition); } // 与 models.run() 返回的结果相同。失败或已取消的请求会在这里被拒绝。 const result = await handle.get(); console.log(result.data); ` `bash cURL theme={null} # 1. 提交。Router 返回 201,并带有 request_id、status_url、response_url 和 cancel_url。 curl https://api.comfy.org/v2/models/minimax/minimax-h3-image/requests \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"area\": \"1K\", \"prompt\": \"A single red maple leaf resting on a plain white background.\"}" # 2. 轮询直到 status 为 COMPLETED,每次响应都会指明需要等待的 Retry-After 秒数。 REQUEST_ID="<request_id from the 201 body>" curl -i https://api.comfy.org/v2/models/minimax/minimax-h3-image/requests/$REQUEST_ID/status \ -H "X-API-Key: $COMFY_API_KEY" # 3. 收集。200 返回模型的原生输出,202 表示仍在运行并返回状态体。 curl https://api.comfy.org/v2/models/minimax/minimax-h3-image/requests/$REQUEST_ID \ -H "X-API-Key: $COMFY_API_KEY" ``

Schema

输入

area string

当省略 size 或为 auto 时,输出面积级别。取值为 1K、2K、4K(默认)。

aspect\_ratio string

当省略 size 或为 auto 时,输出宽高比。auto(默认),或 1:3 到 3:1 之间的 X:Y,例如 16:9。

disable\_prompt\_enhanced boolean (default: false)

关闭 MiniMax 的提示词增强。需要搭配固定的 size 或 X:Y 形式的 aspect_ratio。

images object[]

可选的参考图像。存在时,请求将以图像编辑方式执行,与编辑路由完全一致。

images\[].image\_url string required

公开的 http(s) URL,或 data:image/<format>;base64, URI。支持 JPEG、PNG、WEBP、HEIC 或 HEIF,每边 128 至 8192 px,长边不超过短边的 4 倍。

model string

模型名。MiniMax-H3-Image 或 MiniMax-H3-Image-Highspeed。Router 调用方可以省略此字段或发送 null;Router 会填入由请求路径所选的模型。

n integer (default: 1)

图像数量。输入 token 按每张图像计费一次。

范围:1 到 10

output\_compression integer

jpeg 和 webp 的压缩质量,默认 95。

范围:0 到 100

output\_format string

输出图像格式。取值为 png、jpeg、jpg(默认)、webp。

prompt string required

图像的文字描述。与 images 一起使用时,为编辑的描述;参考图像按数组顺序依次为图像 1、图像 2,以此类推。

size string

输出尺寸,auto(默认)或 WIDTHxHEIGHT,例如 2720x1536。固定尺寸的面积必须为 655,360 至 20,000,000 像素,宽高比在 1:3 到 3:1 之间,且不能与 aspect_ratio 或 area 同时使用。

由 Router 在 GET /v2/models/minimax/minimax-h3-image/openapi.json 提供的 schema 生成,这也是请求到达提供商之前校验调用所用的同一份文档。

输出

created integer

格式:int64

data object[]

data\[].error object

仅当该图像失败或被拦截时存在。

data\[].error.code string

data\[].error.message string

data\[].revised\_prompt string

MiniMax 为该图像使用的提示词。

data\[].size string

实际图像尺寸,格式为 WIDTHxHEIGHT。

data\[].url string

生成图像的 URL。该 URL 会过期,请下载图像。

output\_format string

request\_id string

usage object

成功图像的 token 用量。计费以此为基础。

usage.generated\_images integer

usage.input\_tokens integer

usage.input\_tokens\_details object

usage.input\_tokens\_details.image\_tokens integer

usage.input\_tokens\_details.text\_tokens integer

usage.output\_tokens integer

usage.output\_tokens\_details object

usage.output\_tokens\_details.image\_tokens integer

usage.total\_tokens integer

示例

输入

{
  "area": "1K",
  "prompt": "A single red maple leaf resting on a plain white background."
}

输出

{
  "created": 1794300000,
  "data": [
    {
      "size": "1024x1024",
      "url": "https://example.invalid/minimax/minimax-h3-image/generated.jpg"
    }
  ],
  "output_format": "jpeg",
  "request_id": "06a1b2c3d4e5f60718293a4b5c6d7e8f",
  "usage": {
    "generated_images": 1,
    "input_tokens": 10,
    "input_tokens_details": {
      "image_tokens": 0,
      "text_tokens": 10
    },
    "output_tokens": 1024,
    "output_tokens_details": {
      "image_tokens": 1024
    },
    "total_tokens": 1034
  }
}

发布前须知

SDK 会生成 Idempotency-Key 并在自动重试中复用它。手动重试时,请复用原始 key。Router 最长可保持连接 10 分钟。

请求失败时,Router 会发送 X-Comfy-Error-Type 响应头说明原因。422 表示 Router 在调用提供商之前就拒绝了输入,413 表示请求体超出了 Router 可接受的大小。已生成的资源请及时下载,因为结果 URL 会过期。

上文任何字段描述中提到的尺寸限制,都是提供商对该字段自身的限定,引自提供商的规范。Router 会对整个请求体另行设置上限,base64 编码的媒体内容也计入其中:参见请求体大小。

本页记录的是通过 Comfy Router 调用的某一个合作伙伴模型。同一个 comfy-sdk / @comfyorg/sdk 包还提供第二个客户端,用于在 Comfy Cloud 上运行完整的 ComfyUI 工作流图:Comfy(api_key=...) / new Comfy({ apiKey }),并带有 client.workflows、client.assets 和 client.jobs。请参阅 Comfy SDKs。

请求头 身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。
使用 Router API 模型发现、验证错误、重试与计费。
限制 Router 目前不支持的功能,以及替代方案。