OA0 = Omni AI 0
OA0 是一个探索 AI 的论坛
现在注册
已注册用户请  登录
OA0  ›  技能包  ›  image-router: 使用 ImageRouter API 通过任意模型生成 AI 图像

image-router: 使用 ImageRouter API 通过任意模型生成 AI 图像

 
  encryption ·  2026-02-01 12:03:50 · 3 次点击  · 0 条评论  

name: imagerouter
description: 使用 ImageRouter API 生成 AI 图像(需要 API 密钥)。
homepage: https://imagerouter.io
metadata: {"clawdbot":{"emoji":"🎨","requires":{"bins":["curl"]}}}


ImageRouter 图像生成

使用 curl 命令,通过 ImageRouter 上的任意可用模型生成图像。

可用模型

test/test 模型是一个用于测试 API 的免费虚拟模型,并非真实模型,因此生成图像时应使用其他模型。

获取最受欢迎的 10 个模型:

curl -X POST 'https://backend.imagerouter.io/operations/get-popular-models'

按名称搜索可用模型:

curl "https://api.imagerouter.io/v1/models?type=image&sort=date&name=gemini"

获取所有可用模型:

curl "https://api.imagerouter.io/v1/models?type=image&sort=date&limit=1000"

快速开始 - 文生图

使用 JSON 端点进行基本生成:

curl 'https://api.imagerouter.io/v1/openai/images/generations' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  --json '{
    "prompt": "日落时宁静的山景",
    "model": "test/test",
    "quality": "auto",
    "size": "auto",
    "response_format": "url",
    "output_format": "webp"
  }'

统一端点(文生图 & 图生图)

使用 multipart/form-data 进行文生图:

curl 'https://api.imagerouter.io/v1/openai/images/edits' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -F 'prompt=夜晚的赛博朋克城市' \
  -F 'model=test/test' \
  -F 'quality=high' \
  -F 'size=1024x1024' \
  -F 'response_format=url' \
  -F 'output_format=webp'

图生图(带输入图像):

curl 'https://api.imagerouter.io/v1/openai/images/edits' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -F 'prompt=将其转换为水彩画' \
  -F 'model=test/test' \
  -F 'quality=auto' \
  -F 'size=auto' \
  -F 'response_format=url' \
  -F 'output_format=webp' \
  -F 'image[]=@/path/to/your/image.webp'

多张图像输入(最多 16 张):

curl 'https://api.imagerouter.io/v1/openai/images/edits' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -F 'prompt=组合这些图像' \
  -F 'model=test/test' \
  -F 'image[]=@image1.webp' \
  -F 'image[]=@image2.webp' \
  -F 'image[]=@image3.webp'

使用蒙版(部分模型进行图像修复时需要):

curl 'https://api.imagerouter.io/v1/openai/images/edits' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -F 'prompt=用花朵填充蒙版区域' \
  -F 'model=test/test' \
  -F 'image[]=@original.webp' \
  -F 'mask[]=@mask.webp'

参数说明

  • model(必需):使用的图像模型(参见 https://imagerouter.io/models)
  • prompt(可选):用于生成的文本描述。大多数模型需要文本提示,但并非全部。
  • quality(可选):auto(默认)、lowmediumhigh
  • size(可选):auto(默认)或 宽度x高度(例如 1024x1024)。
  • response_format(可选):
  • url(默认)- 返回托管 URL
  • b64_json - 返回 base64 编码的图像
  • b64_ephemeral - Base64 编码,但不保存到日志
  • output_format(可选):webp(默认)、jpegpng
  • image[](可选):用于图生图的输入文件(仅限 multipart 格式)
  • mask[](可选):用于图像修复的编辑蒙版(仅限 multipart 格式)

响应格式

{
  "created": 1769286389027,
  "data": [
    {
      "url": "https://storage.imagerouter.io/fffb4426-efbd-4bcc-87d5-47e6936bf0bb.webp"
    }
  ],
  "latency": 6942,
  "cost": 0.004
}

端点对比

功能 统一端点 (/edits) JSON 端点 (/generations)
文生图
图生图
编码方式 multipart/form-data application/json

使用建议

  • /v1/openai/images/generations/v1/openai/images/edits 对于统一端点功能相同
  • 当不需要文件上传时,使用 JSON 端点进行简单的文生图
  • 当需要图生图功能时,使用统一端点
  • 在 https://imagerouter.io/models 查看模型特性(如质量支持、编辑支持等)
  • 在 https://imagerouter.io/api-keys 获取您的 API 密钥

用例示例

快速测试生成:

curl 'https://api.imagerouter.io/v1/openai/images/generations' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  --json '{"prompt":"测试图像","model":"test/test"}'

直接下载图像:

curl 'https://api.imagerouter.io/v1/openai/images/generations' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  --json '{"prompt":"抽象艺术","model":"test/test"}' \
  | jq -r '.data[0].url' \
  | xargs curl -o output.webp
3 次点击  ∙  0 人收藏  
登录后收藏  
目前尚无回复
0 条回复
About   ·   Help   ·    
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
Developed with Cursor