ImageRouter
2026-03-30
新闻来源:网淘吧
围观:18
电脑广告
手机广告
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": "a serene mountain landscape at sunset",
"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=a cyberpunk city at night' \
-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=transform this into a watercolor painting' \
-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=combine these images' \
-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=fill the masked area with flowers' \
-F 'model=test/test' \
-F 'image[]=@original.webp' \
-F 'mask[]=@mask.webp'
参数
- model(必需):要使用的图像模型(参见https://imagerouter.io/models提示词
- (可选):用于生成的文本描述。大多数模型需要文本提示词,但并非全部。质量
- (可选):自动
(默认)、低、中、高尺寸 - (可选):自动
(默认)或宽度x高度(例如,1024x1024)。响应格式 - (可选):url
(默认)- 返回托管URLb64_json- 返回base64编码的图像- Returns base64-encoded imageb64_ephemeral- 不保存到日志的Base64
- output_format(可选):
webp(默认),jpeg,png - 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(质量支持、编辑支持等)
- 在以下网址获取您的API密钥https://imagerouter.io/api-keys
按使用场景的示例
快速测试生成:
curl 'https://api.imagerouter.io/v1/openai/images/generations' \
-H 'Authorization: Bearer YOUR_API_KEY' \
--json '{"prompt":"test image","model":"test/test"}'
直接下载图像:
curl 'https://api.imagerouter.io/v1/openai/images/generations' \
-H 'Authorization: Bearer YOUR_API_KEY' \
--json '{"prompt":"abstract art","model":"test/test"}' \
| jq -r '.data[0].url' \
| xargs curl -o output.webp
文章底部电脑广告
手机广告位-内容正文底部


微信扫一扫,打赏作者吧~