全功能Midjourney代理,支持Midjourney所有作图功能,高性能、稳定,免费。
composer create-project workerman/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, // 任务提交后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
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 "";
}
}
注意
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 "";
}
}
{
"prompt": "a cat",
"images": [url1, url2, ...], // 可选参数
"notifyUrl": "https://your-server.com/notify", // 可选参数
}
{
"code": 0,
"msg": "ok",
"taskId": "1710816049856103374",
"data": []
}
{
"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": []
}
{
"images": [url],
"notifyUrl": "https://your-server.com/notify", // 可选参数
}
{
"code": 0,
"msg": "ok",
"taskId": "1710816302060386071",
"data": []
}
{
"images": [url1, url2],
"notifyUrl": "https://your-server.com/notify", // 可选参数
}
{
"code": 0,
"msg": "ok",
"taskId": "1710816302060354172",
"data": []
}
{
"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"
}
]
]
}
}
字段含义
action 值说明
如果有设置 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": [
...
]
}