<?phpuse 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, // 任务提交后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 https://www.workerman.net/a/1654
代理示例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.top; 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/status?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 任务IDaction 任务类型 (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 iddata 任务自定义数据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": [ ... ] }