-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathimage.php
More file actions
26 lines (22 loc) · 732 Bytes
/
Copy pathimage.php
File metadata and controls
26 lines (22 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<h1>Generate Image</h1>
<form action="/image.php" method="post" enctype="multipart/form-data">
Generate Image With Given Input: <br>
<label for="prompt">Prompt</label>
<input type="text" name="prompt" id="prompt">
<br>
<input type="submit" value="Generate Image" name="submit">
</form>
<?php
require __DIR__ . '/vendor/autoload.php';
use Orhanerday\OpenAi\OpenAi;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (ob_get_contents()) ob_end_clean();
$open_ai_key = getenv('OPENAI_API_KEY');
$open_ai = new OpenAi($open_ai_key);
$result = $open_ai->image([
"prompt" => $_POST["prompt"],
"n" => 1,
"size" => "256x256",
]);
echo $result;
}