全功能midjourney proxy 接口代理 高性能 穩(wěn)定 免費(fèi)

v1.0.20
版本
2025-05-07
版本更新時間
648
安裝
100
star
midjourney-proxy
全功能Midjourney代理,支持Midjourney所有作圖功能,高性能、穩(wěn)定,免費(fèi)
- 支持 Imagine(畫圖)
- 支持 Imagine 時支持添加圖片墊圖
- 支持?jǐn)U圖 Pan ?? ?? ?? ??
- 支持?jǐn)U圖 ZoomOut ??
- 支持自定義擴(kuò)圖 Custom Zoom ??
- 支持局部重繪 Vary (Region) ??
- 支持 Make Square
- 支持任務(wù)實(shí)時進(jìn)度
- 支持 Blend(圖片混合)
- 支持 Describe(圖生文)
- 支持賬號池
- 支持禁用詞設(shè)置
- 支持圖片cdn替換
Webman AI QQ交流群
QQ群號:789898358,2000人群歡迎加入
完整項(xiàng)目
https://bla.cn
http://www.wtbis.cn/ai
安裝
-
首先需要安裝webman框架(如果已經(jīng)安裝請忽略此步驟)
composer create-project workerman/webman
-
進(jìn)入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, // 并發(fā)數(shù),10刀/30刀用戶3并發(fā) 60刀/120刀用戶12并發(fā)
'timeoutMinutes' => 10, // 任務(wù)提交discord后10分鐘后沒有響應(yīng)則認(rèn)為超時
]
],
'proxy' => [
'server' => 'https://discord.com', // 國內(nèi)需要代理,代理搭建參見下面
'cdn' => 'https://cdn.discordapp.com', // 國內(nèi)需要代理,代理搭建參見下面
'gateway' => 'wss://gateway.discord.gg', // 國內(nèi)需要代理,代理搭建參見下面
'upload' => 'https://discord-attachments-uploads-prd.storage.googleapis.com', // 國內(nèi)需要代理,代理搭建參見下面
],
'store' => [
'handler' => File::class, // 任務(wù)存儲方式
'expiredDates' => 30, // 任務(wù)30天后過期
File::class => [
'dataPath' => runtime_path() . '/data/midjourney', // 任務(wù)存儲目錄
]
],
'settings' => [
'debug' => false, // 調(diào)試模式會顯示更多信息在終端
'secret' => '', // 接口密鑰,不為空時需要在http頭 mj-api-secret 中傳遞
'notifyUrl' => '', // webman ai項(xiàng)目請留空
'apiPrefix' => '', // 接口前綴
'tmpPath' => runtime_path() . '/tmp/midjourney' // 上傳文件臨時目錄
]
]
]
]
];
獲取token、guild_id、channel_id useragent
參見 Midjourney獲取token guild_id channel_id useragent
代理示例
https服務(wù)nginx代理
discord.com
cdn.discordapp.com
discord-attachments-uploads-prd.storage.googleapis.com
每個域名都要設(shè)置一個代理,以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服務(wù)代理
注意 gateway.discord.gg 是websocket協(xié)議,代理方式與上面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 畫圖
-
參數(shù) POST
{ "prompt": "a cat", "images": [url1, url2, ...], // 可選參數(shù) "notifyUrl": "https://your-server.com/notify", // 可選參數(shù) }
-
返回
{ "code": 0, "msg": "ok", "taskId": "1710816049856103374", "data": [] }
/image/action 圖片操作
-
參數(shù) POST
{ "taskId": "1710816049856103374", "customId": "MJ::JOB::upsample::1::749b4d14-75ec-4f16-8765-b2b9a78125fb", "notifyUrl": "https://your-server.com/notify", // 可選參數(shù) }
-
返回
{ "code": 0, "msg": "ok", "taskId": "1710816302060986090", "data": [] }
/image/describe 圖生文
-
參數(shù) POST
{ "images": [url], "notifyUrl": "https://your-server.com/notify", // 可選參數(shù) }
-
返回
{ "code": 0, "msg": "ok", "taskId": "1710816302060386071", "data": [] }
/image/blend 圖片混合
-
參數(shù) POST
{ "images": [url1, url2], "notifyUrl": "https://your-server.com/notify", // 可選參數(shù) }
-
返回
{ "code": 0, "msg": "ok", "taskId": "1710816302060354172", "data": [] }
/task/fetch?taskId=1710816049856103374 任務(wù)狀態(tài)
-
返回
{ "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 任務(wù)ID
- action 任務(wù)類型 (IMAGINE, UPSCALE, VARIATION 等參考下方 action 值說明)
- status 任務(wù)狀態(tài) (PENDING, STARTED, SUBMITTED, RUNNING, FINISHED, FAILED)
- submitTime 任務(wù)創(chuàng)建時間
- startTime 開始時間
- finishTime 完成時間
- progress 任務(wù)進(jìn)度 0% - 100%,不管成功還是失敗,最終狀態(tài)為100%
- imageUrl 圖片地址 cdn替換后的地址
- imageRawUrl 圖片原始地址 國內(nèi)無法訪問
- prompt 提示詞
- finalPrompt MJ最終使用的提示詞
- params 任務(wù)相關(guān)參數(shù)
- images 任務(wù)相關(guān)圖片,格式為url數(shù)組
- description 圖生文的結(jié)果,只有describe任務(wù)有
- failReason 任務(wù)失敗原因,只要此處值不為空代表任務(wù)失敗
- discordId 任務(wù)所屬的discord id
- data 任務(wù)自定義數(shù)據(jù)
- buttons 任務(wù)操作按鈕,其中 custom_id 為 /image/action 接口的 customId 參數(shù)
-
action 值說明
- IMAGINE 畫圖
- UPSCALE 選圖
- VARIATION 局部重繪
- REROLL 重新生成
- DESCRIBE 圖生文
- BLEND 圖片混合
- ZOOMOUT 擴(kuò)圖
- ZOOMOUT_CUSTOM 自定義擴(kuò)圖
- PANLEFT 擴(kuò)圖左移
- PANRIGHT 擴(kuò)圖右移
- PANUP 擴(kuò)圖上移
- PANDOWN 擴(kuò)圖下移
- MAKE_SQUARE 擴(kuò)圖成正方形
- PIC_READER 從圖片中提取文字后生成新圖
- CANCEL_JOB 取消任務(wù)
- UPSCALE_V5_2X v5 2倍高清圖
- UPSCALE_V5_4X v5 4倍高清圖
- UPSCALE_V6_2X_CREATIVE v6 2倍創(chuàng)意高清圖
- UPSCALE_V6_2X_SUBTLE v6 2倍微調(diào)高清圖
- VARIATION_STRONG 強(qiáng)烈變換
- VARIATION_SUBTLE 微調(diào)變換
- VARIATION_REGION 局部重繪
notifyUrl 通知格式
如果有設(shè)置 notifyUrl 參數(shù),當(dāng)任務(wù)狀態(tài)變化時會向此地址發(fā)送 POST 請求,請求內(nèi)容為任務(wù)狀態(tài)的 json 格式,格式與 /task/status
接口返回的data內(nèi)容一致。
{
"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": [
...
]
}