ediasoft/midjourney-api-php

PHP的Midjourney API客户端

1.1.1 2024-06-03 15:09 UTC

This package is auto-updated.

Last update: 2024-09-16 05:37:40 UTC


README

PHP的Midjourney API客户端

Midjourney Splash

yellow-button

Midjourney PHP API客户端包是一个全面的库,允许开发人员通过Discord与Midjourney API交互。Midjourney是一个AI平台,可以根据提示生成图像。

本PHP API客户端包旨在简化Midjourney API集成到您的PHP应用程序中,使您能够无缝访问Midjourney平台的功能。

功能

  • 想象:根据您提供的提示创建图像。这将返回四个不同的选项供您选择。
  • 放大:获取生成的图像的全尺寸。

即将发布的版本

  • 混合:能够混合两个或更多图像。
  • 描述:将根据给定图像生成四个可能的提示。
  • 缩短:分析您的提示并突出显示,并建议您可以删除的不必要词汇。

安装

您可以使用Composer安装Midjourney PHP API客户端包。运行以下命令

composer require ediasoft/midjourney-api-php

用法

基本用法

使用有效的凭据创建MidjourneyApiClient对象,然后您将能够访问所有可用的命令。请参阅下面的Imagine命令

use eDiasoft\Midjourney\MidjourneyApiClient;

$channel_id = 00000000;
$authorization = "AUTH_TOKEN";

$midjourney = new MidjourneyApiClient($channel_id, $authorization);

$result = $midjourney->imagine('Elephant and a snake romantically having a diner')->send();

return $result;

构造函数

  • $channel_id - 前往您的Discord频道,在Midjourney Bot活动的频道上右键单击。点击 复制频道ID 复制频道ID

    如果您看不到此菜单选项,您必须启用开发者模式。转到用户设置 > 高级(在应用设置下) > 开发者模式(启用)

    Discord User Token

  • $authorization - 注意:Discord严格禁止使用自动用户账户,也称为自建机器人。如果被发现参与此类活动,可能导致您的Discord账户被终止。因此,我们强烈建议不要使用自建机器人以避免任何潜在的风险和后果。请务必注意Discord的服务条款,并负责任地使用该平台,并遵守其允许的指南。

    要获取您的用户令牌,请访问 https://discord.com/channels/@me 并在 开发者工具 中的 网络 选项卡中打开 网络。找到指向Discord API的调用,例如 friend-suggestions,并打开 请求头 选项卡,找到 Authorization 并复制此值。

    Discord User Token

命令

Imagine

$imagine_builder = $midjourney->imagine('Elephant and a snake romantically having a diner'); //Returns a Builder object
参数
$imagine_builder->aspectRatio('16:9') //Changing the aspect ratio.
                ->chaos(30) //The higher the chaos the more unusual and unexpected results.
                ->fast() //Enable fast mode for this single job.
                ->imageWeight(1.75) //Sets image prompt weight relative to text weight. The default value is 1.
                ->no('moon roses') //Exclude specific object in the image.
                ->quality(0.5)
                ->relax() //This will turn on relax mode for this single job, the interval of retrieving the image will be also delayed. 
                ->repeat(40) //Create multiple Jobs from a single prompt.
                ->seed(1000) //The Midjourney bot uses a seed number to create a field of visual noise, like television static, as a starting point to generate the initial image grids.
                ->stop(35) //Stopping a Job at an earlier percentage can create blurrier, less detailed results.
                ->style('cute')
                ->stylize(5) //Influences how strongly Midjourney's default aesthetic style is applied
                ->tile() //Generates images that can be used as repeating tiles to create seamless patterns.
                ->turbo() //Override your current setting and run a single job using Turbo Mode.
                ->weird(1000); //Explore unusual aesthetics with the experimental weird parameter

$result = $imagine_builder->send()

请参阅文档以获取完整说明。

放大

$message_id = "1234";
$upscale_image_id = "MJ::JOB::upsample::1::xxxxx";
$interaction_id = $imagine_builder->interactionId(); //You can retrieve this ID after the imagine interaction is performed, this is a identifier for the specific job request.

$upscale_builder = $midjourney->upscale($message_id, $upscale_image_id, $interaction_id); //Returns a Builder object

$upscaled_image_result = $upscale_builder->send();

文档

有关可用端点和其参数的详细信息,请参阅官方 Midjourney文档

贡献

我们欢迎社区的贡献!如果您发现任何问题或有改进建议,请随时在我们的GitHub存储库中打开问题或提交拉取请求。

许可证

本包为开源软件,遵循MIT许可协议发布。您可以根据项目需求自由使用和修改。

支持

有关Midjourney PHP API客户端包的任何问题或支持,您可以联系support@ediasoft.com