首创!最全面全功能Midjourney Proxy代理SDK正式发布!

midjourney-proxy

全功能Midjourney代理,支持Midjourney所有作图功能,高性能、稳定,免费。

  • 支持 Imagine(画图)
  • 支持 Imagine 时支持添加图片垫图
  • 支持扩图 Pan ?? ?? ?? ??
  • 支持扩图 ZoomOut ??
  • 支持自定义扩图 Custom Zoom ??
  • 支持局部重绘 Vary (Region) ??
  • 支持 Make Square
  • 支持任务实时进度
  • 支持 Blend(图片混合)
  • 支持 Describe(图生文)
  • 支持账号池
  • 支持禁用词设置
  • 支持图片cdn替换

安装

  • 首先需要安装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, // 任务提交后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.ggwebsocket协议,代理方式与上面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 任务ID
  • action 任务类型 (IMAGINE, UPSCALE, VARIATION 等参考下方 action 值说明)
  • status 任务状态 (P

    原创文章,作者:网络技术联盟站,如若转载,请注明出处:https://www.sudun.com/ask/49910.html

(0)
网络技术联盟站的头像网络技术联盟站
上一篇 2024年5月17日
下一篇 2024年5月17日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注