全功能midjourney proxy 接口代理 高性能 稳定 免费
v1.0.18
版本
2024-09-12
版本更新时间
559
安装
98
star
midjourney-proxy
全功能Midjourney代理,支持Midjourney所有作图功能,高性能、稳定,免费
- 支持 Imagine(画图)
- 支持 Imagine 时支持添加图片垫图
- 支持扩图 Pan ⬅️ ➡️ ⬆️ ⬇️
- 支持扩图 ZoomOut 🔍
- 支持自定义扩图 Custom Zoom 🔍
- 支持局部重绘 Vary (Region) 🖌
- 支持 Make Square
- 支持任务实时进度
- 支持 Blend(图片混合)
- 支持 Describe(图生文)
- 支持账号池
- 支持禁用词设置
- 支持图片cdn替换
Webman AI QQ交流群
QQ群号:789898358,2000人群欢迎加入
完整项目
https://bla.cn
https://www.workerman.net/ai
安装
-
首先需要安装webman框架(如果已经安装请忽略此步骤)
composer create-project workerman/webman
-
进入webman目录安装
webman/midjourney
cd webman composer require webman/midjourney
配置
打开config/plugin/webman/midjourney/process.php
文件,配置如下
<?php
use Webman\Midjourney\TaskStore\File;
return [
'server' => [
'handler' => Webman\Midjourney\Server::class,
'listen' => 'http://0.0.0.0:8686',
'reloadable' => false,
'constructor' => [
'config' => [
'accounts' => [
[
'enable' => true,
'token' => '<获取方式参见下面>',
'guild_id' => '<获取方式参见下面>',
'channel_id' => '<获取方式参见下面>',
'useragent' => '<获取方式参见下面>',
'concurrency' => 3, // 并发数,10刀/30刀用户3并发 60刀/120刀用户12并发
'timeoutMinutes' => 10, // 任务提交discord后10分钟后没有响应则认为超时
]
],
'proxy' => [
'server' => 'https://discord.com', // 国内需要代理,代理搭建参见下面
'cdn' => 'https://cdn.discordapp.com', // 国内需要代理,代理搭建参见下面
'gateway' => 'wss://gateway.discord.gg', // 国内需要代理,代理搭建参见下面
'upload' => 'https://discord-attachments-uploads-prd.storage.googleapis.com', // 国内需要代理,代理搭建参见下面
],
'store' => [
'handler' => File::class, // 任务存储方式
'expiredDates' => 30, // 任务30天后过期
File::class => [
'dataPath' => runtime_path() . '/data/midjourney', // 任务存储目录
]
],
'settings' => [
'debug' => false, // 调试模式会显示更多信息在终端
'secret' => '', // 接口密钥,不为空时需要在http头 mj-api-secret 中传递
'notifyUrl' => '', // webman ai项目请留空
'apiPrefix' => '', // 接口前缀
'tmpPath' => runtime_path() . '/tmp/midjourney' // 上传文件临时目录
]
]
]
]
];
获取token、guild_id、channel_id useragent
参见 Midjourney获取token guild_id channel_id useragent
代理示例
https服务nginx代理
discord.com
cdn.discordapp.com
discord-attachments-uploads-prd.storage.googleapis.com
每个域名都要设置一个代理,以discord.com为例代理配置类似如下:
server {
listen 80;
server_name your_domain.com;
proxy_buffer_size 64k;
proxy_buffers 32 64k;
proxy_busy_buffers_size 128k;
location ^~ / {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_ssl_server_name on;
proxy_pass https://discord.com;
proxy_set_header Host discord.com;
proxy_set_header Referer "";
}
}
wss服务代理
注意 gateway.discord.gg 是websocket协议,代理方式与上面https代理有所不同。gateway.discord.gg 代理类似如下:
server {
listen 80;
server_name your_wss_domain.com;
proxy_buffer_size 64k;
proxy_buffers 32 64k;
proxy_busy_buffers_size 128k;
location ^~ / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_http_version 1.1;
proxy_ssl_server_name on;
proxy_pass https://gateway.discord.gg;
proxy_set_header Host gateway.discord.gg;
proxy_set_header Referer "";
}
}
接口
/image/imagine 画图
-
参数 POST
{ "prompt": "a cat", "images": [url1, url2, ...], // 可选参数 "notifyUrl": "https://your-server.com/notify", // 可选参数 }
-
返回
{ "code": 0, "msg": "ok", "taskId": "1710816049856103374", "data": [] }
/image/action 图片操作
-
参数 POST
{ "taskId": "1710816049856103374", "customId": "MJ::JOB::upsample::1::749b4d14-75ec-4f16-8765-b2b9a78125fb", "notifyUrl": "https://your-server.com/notify", // 可选参数 }
-
返回
{ "code": 0, "msg": "ok", "taskId": "1710816302060986090", "data": [] }
/image/describe 图生文
-
参数 POST
{ "images": [url], "notifyUrl": "https://your-server.com/notify", // 可选参数 }
-
返回
{ "code": 0, "msg": "ok", "taskId": "1710816302060386071", "data": [] }
/image/blend 图片混合
-
参数 POST
{ "images": [url1, url2], "notifyUrl": "https://your-server.com/notify", // 可选参数 }
-
返回
{ "code": 0, "msg": "ok", "taskId": "1710816302060354172", "data": [] }
/task/fetch?taskId=1710816049856103374 任务状态
-
返回
{ "code": 0, "msg": "success", "data": { "id": "1710816049856103374", "action": "IMAGINE", "status": "FINISHED", "submitTime": 1710903739, "startTime": 1710903739, "finishTime": 1710903844, "progress": "100%", "imageUrl": "https:\/\/your_cdn.com\/attachments\/1148151204884726471\/121984387748450658284\/a_cat._65e72369d-1db1-5be4-9566-71056a5b0caf.png?ex=660cc723&is=65fa5223&hm=0d9b721610b62101c7cb4c0f3bf4e364cdd69be3441b9c3b1c200d20b309d97e&", "imageRawUrl": "https:\/\/cdn.discordapp.com\/attachments\/1148151204884726471\/121984387748450658284\/a_cat._65e72369d-1db1-5be4-9566-71056a5b0caf.png?ex=660cc723&is=65fa5223&hm=0d9b721610b62101c7cb4c0f3bf4e364cdd69be3441b9c3b1c200d20b309d97e&", "prompt": "A cat. --v 6.0 --relax", "finalPrompt": "A cat. --v 6.0 --relax", "params": [], "images": [], "description": null, "failReason": null, "discordId": "1148151204875075657", "data": [], "buttons": [ [ { "type": 2, "style": 2, "label": "U1", "custom_id": "MJ::JOB::upsample::1::65e72369d-1db1-5be4-9566-71056a5b0caf" }, { "type": 2, "style": 2, "label": "U2", "custom_id": "MJ::JOB::upsample::2::65e72369d-1db1-5be4-9566-71056a5b0caf" }, { "type": 2, "style": 2, "label": "U3", "custom_id": "MJ::JOB::upsample::3::65e72369d-1db1-5be4-9566-71056a5b0caf" }, { "type": 2, "style": 2, "label": "U4", "custom_id": "MJ::JOB::upsample::4::65e72369d-1db1-5be4-9566-71056a5b0caf" }, { "type": 2, "style": 2, "emoji": { "name": "🔄" }, "custom_id": "MJ::JOB::reroll::0::65e72369d-1db1-5be4-9566-71056a5b0caf::SOLO" } ], [ { "type": 2, "style": 2, "label": "V1", "custom_id": "MJ::JOB::variation::1::65e72369d-1db1-5be4-9566-71056a5b0caf" }, { "type": 2, "style": 2, "label": "V2", "custom_id": "MJ::JOB::variation::2::65e72369d-1db1-5be4-9566-71056a5b0caf" }, { "type": 2, "style": 2, "label": "V3", "custom_id": "MJ::JOB::variation::3::65e72369d-1db1-5be4-9566-71056a5b0caf" }, { "type": 2, "style": 2, "label": "V4", "custom_id": "MJ::JOB::variation::4::65e72369d-1db1-5be4-9566-71056a5b0caf" } ] ] } }
-
字段含义
- id 任务ID
- action 任务类型 (IMAGINE, UPSCALE, VARIATION 等参考下方 action 值说明)
- status 任务状态 (PENDING, STARTED, SUBMITTED, RUNNING, FINISHED, FAILED)
- submitTime 任务创建时间
- startTime 开始时间
- finishTime 完成时间
- progress 任务进度 0% - 100%,不管成功还是失败,最终状态为100%
- imageUrl 图片地址 cdn替换后的地址
- imageRawUrl 图片原始地址 国内无法访问
- prompt 提示词
- finalPrompt MJ最终使用的提示词
- params 任务相关参数
- images 任务相关图片,格式为url数组
- description 图生文的结果,只有describe任务有
- failReason 任务失败原因,只要此处值不为空代表任务失败
- discordId 任务所属的discord id
- data 任务自定义数据
- buttons 任务操作按钮,其中 custom_id 为 /image/action 接口的 customId 参数
-
action 值说明
- IMAGINE 画图
- UPSCALE 选图
- VARIATION 局部重绘
- REROLL 重新生成
- DESCRIBE 图生文
- BLEND 图片混合
- ZOOMOUT 扩图
- ZOOMOUT_CUSTOM 自定义扩图
- PANLEFT 扩图左移
- PANRIGHT 扩图右移
- PANUP 扩图上移
- PANDOWN 扩图下移
- MAKE_SQUARE 扩图成正方形
- PIC_READER 从图片中提取文字后生成新图
- CANCEL_JOB 取消任务
- UPSCALE_V5_2X v5 2倍高清图
- UPSCALE_V5_4X v5 4倍高清图
- UPSCALE_V6_2X_CREATIVE v6 2倍创意高清图
- UPSCALE_V6_2X_SUBTLE v6 2倍微调高清图
- VARIATION_STRONG 强烈变换
- VARIATION_SUBTLE 微调变换
- VARIATION_REGION 局部重绘
notifyUrl 通知格式
如果有设置 notifyUrl 参数,当任务状态变化时会向此地址发送 POST 请求,请求内容为任务状态的 json 格式,格式与 /task/status
接口返回的data内容一致。
{
"id": "1710816049856103374",
"action": "IMAGINE",
"status": "FINISHED",
"submitTime": 1710903739,
"startTime": 1710903739,
"finishTime": 1710903844,
"progress": "100%",
"imageUrl": "https:\/\/your_cdn.com\/attachments\/1148151204884726471\/121984387748450658284\/a_cat._65e72369d-1db1-5be4-9566-71056a5b0caf.png?ex=660cc723&is=65fa5223&hm=0d9b721610b62101c7cb4c0f3bf4e364cdd69be3441b9c3b1c200d20b309d97e&",
"imageRawUrl": "https:\/\/cdn.discordapp.com\/attachments\/1148151204884726471\/121984387748450658284\/a_cat._65e72369d-1db1-5be4-9566-71056a5b0caf.png?ex=660cc723&is=65fa5223&hm=0d9b721610b62101c7cb4c0f3bf4e364cdd69be3441b9c3b1c200d20b309d97e&",
"prompt": "A cat. --v 6.0 --relax",
"finalPrompt": "A cat. --v 6.0 --relax",
"params": [],
"images": [],
"description": null,
"failReason": null,
"discordId": "1148151204875075657",
"data": [],
"buttons": [
...
]
}