On Twitter Nuno said, "OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API, with this integration, developers can now easily use OpenAI's powerful natural language processing capabilities in their Laravel applications."
Getting started with the package is pretty straightforward and you can see the guide here:
First, install OpenAI:
composer require openai-php/laravel
Next, publish the configuration file:
php artisan vendor:publish --provider="OpenAI\Laravel\ServiceProvider"
This will create a
config/openai.php configuration file in your project, which you can modify to your needs
using environment variables:
Finally, you may use the
OpenAI facade to access the OpenAI API:
use OpenAI\Laravel\Facades\OpenAI;$result = OpenAI::completions()->create(['model' => 'text-davinci-003','prompt' => 'PHP is',]);echo $result['choices']['text']; // an open-source, widely-used, server-side scripting language.