crembelski / iacommunication
This package allows you to communicate with OpenAI via a simple interface.
Requires
- php: >=8.3
- guzzlehttp/guzzle: >=7.8
Requires (Dev)
- mockery/mockery: ^1.6
- phpunit/phpunit: ^11.3
README
This package allows you to communicate with OpenAI via a simple interface.
Installation
-
Install the Package
Run the following command in your project root to install the package:composer require crembelski/iacommunication
-
Add the Service Provider
In yourconfig/app.php
, add the following line to theproviders
array:crembelski\iacommunication\IACommunicationServiceProvider::class,
-
Publish the Configuration
Run the following command to publish the configuration file:php artisan vendor:publish --tag=config --provider="crembelski\iacommunication\IACommunicationServiceProvider"
-
Configure Your OpenAI
Add your OpenAI API Key and the service name in the.env
file of your Laravel application. Example:IA_API_KEY=your_openai_api_key_here IA_SERVICE=OpenAI
Replace
your_openai_api_key_here
with your actual API key from OpenAI.
Usage
Once installed and configured, you can use the completions
method to send a message to OpenAI.
use crembelski\iacommunication\IACommunication; $iaComm = new IACommunication(); $response = $iaComm->completions("Hello AI!");
License
This package is open-sourced software licensed under the MIT license.