ferranfg / midjourney-discord-api-php

Generate images using Midjourney Bot through the Discord API.
https://ferranfigueredo.com
MIT License
135 stars 35 forks source link
midjourney midjourney-api-bot midjourney-app-api midjourney-bot

Midjourney PHP Library for Discord API Image Generation

This PHP library provides a simple interface for generating images using the Midjourney Bot through the Discord API.

Midjourney PHP Library for Discord API

Installation

You can install this library using Composer. Run the following command in your project directory:

composer require ferranfg/midjourney-php

Usage

Basic usage

To generate an image using the Midjourney Bot, you first need to create an instance of the Midjourney class:

use Ferranfg\MidjourneyPhp\Midjourney;

$midjourney = new Midjourney($discord_channel_id, $discord_user_token);

$message = $midjourney->generate('An astronaut riding a horse');

return $message->upscaled_photo_url;

Constructor

Methods

$midjourney->imagine($prompt)

This method generates an image using a prompt and returns an object that represents the message containing the generated image. The $prompt parameter is a string that will be used to generate the image.

$imagine_object = $midjourney->imagine('An astronaut riding a horse');

$midjourney->getImagine($prompt)

This method returns a previously generated object that represents the message containing the image generated by the given prompt. The $prompt parameter is the string used to generate the image.

$imagine_object = $midjourney->getImagine('An astronaut riding a horse');

$midjourney->upscale($imagine_object, $upscale_index)

This method upscales an image contained in the given object and returns the URL of the upscaled image. The $imagine_object parameter is the object returned from the imagine / getImagine methods. The $upscale_index parameter is an integer between 0 and 3 that represents the option provided by the MJ bot we want to upscale.

$upscaled_image_url = $midjourney->upscale($imagine_object, 2);

$midjourney->getUpscale($imagine_object, $upscale_index)

This method returns the URL of a previously upscaled image generated by the given message and with the given option of upscaling. The $imagine_object parameter is the object returned from the imagine / getImagine methods. The $upscale_index parameter is an integer between 0 and 3 that represents the option provided to the MJ bot we upscaled.

$upscaled_image_url = $midjourney->getUpscale($imagine_object, 2);