Please help me connect to the Midjourney API via PHP. I need an intermediary service that can provide a stable service at an affordable price for creating AI-generated images using the Midjourney AI via the API.
Please also send the necessary codes for the connection.
Thank you in advance.
>Solution :
You can use the Midjorney API by TalkBaBa.com. This service connects you to the latest generation of AI-powered image generator. You can also create an image with Midjorney through the web mode using the link below.
And you can access the web service documentation for PHP through the link below.
Midjourney Web Service Documents
Here is a sample PHP code for creating an image with Midjorney via the Midjorney API:
<?php
$headers = [
'Authorization: Bearer YOUR-TOKEN-KEY'
];
$data = [
'promot' => 'an image promot',
'aspectRatio' => '4:3'
];
$url = 'https://api.talkbaba.com/v1/media/midjorney/REQ';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo $response = curl_exec($ch);
if(curl_errno($ch)){
echo 'Error in executing CURL request: ' . curl_error($ch);
}
curl_close($ch);
?>
It should be noted that you can still use the DALLE AI image generator and Google Image in TalkBaBa.
Good luck.