1. Go to this page and download the library: Download muhammetsafak/openai-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
muhammetsafak / openai-client example snippets
use MuhammetSafak\OpenAI\OpenAI;
use MuhammetSafak\OpenAI\Services\Completions;
const SECRET_KEY = "";
$openai = new OpenAI(SECRET_KEY);
$openai->setPrompt($_GET['prompt'])
->setTemperature(0.7);
$res = (new Completions($openai))->get();
echo $res['response']['choices'][0]['text'];