使用 ImageRouter API(需 API 密钥)生成任意模型的 AI 图像。
图像路透器 图像生成是一项面向实际任务的技能,主要用于利用卷曲命令将图像与图像路透器上的任何模型一起生成;测试/测试模型是一种自由的假模型, 用于测试该模型。
从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;
若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
使用 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"
获取全部可用模型(最多 1000 个):
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"
}'
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'
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'
auto(默认)、low、medium、highauto(默认),或指定为 WIDTHxHEIGHT 格式(例如:1024x1024)url(默认)—— 返回托管图像的 URL 地址b64_json—— 返回 base64 编码的图像数据b64_ephemeral—— 返回不记录到日志中的 base64 编码图像webp(默认)、jpeg、png{
"created": 1769286389027,
"data": [
{
"url": "https://storage.imagerouter.io/fffb4426-efbd-4bcc-87d5-47e6936bf0bb.webp"
}
],
"latency": 6942,
"cost": 0.004
}
| 功能 | 统一接口(/edits) | JSON 接口(/generations) |
|---|---|---|
| 文生图(Text-to-Image) | ✅ | ✅ |
| 图生图(Image-to-Image) | ✅ | ❌ |
| 请求编码格式 | multipart/form-data | application/json |
/v1/openai/images/generations 与 /v1/openai/images/edits 在统一接口下功能一致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
相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 134.1万人学习
共49课时 | 82.6万人学习
最新文章