A laravel package to integrate openai in laravel application.
You can install the package via composer:
composer require itsimiro/laravel-openaiPublish the configuration file:
php artisan vendor:publish --provider="Itsimiro\OpenAI\Providers\OpenaiServiceProvider"
This will create a config/laravel-openai.php configuration file in your project. Be sure to specify the key in your environment file.
OPENAI_API_KEY=sk-*
- Completions
- Chat
- Edits
- Models
- Images
- Images
- Create image edit
- Audio
- Create transcription
- Create translation
- Embeddings
- Create embeddings
$openAI = $this->container->make(\Itsimiro\OpenAI\Services\OpenAI::class);
$result = $openAI->getDavinci()->completion(new \Itsimiro\OpenAI\Services\DataTransferObjects\CompletionParameters()); // Itsimiro\OpenAI\Services\API\Results\CompletionResult
$result->getChoices(); // Choices from OpenAI.$openAI = $this->container->make(\Itsimiro\OpenAI\Services\OpenAI::class);
$result = $openAI->getDavinci()->chat(new ChatParameters()); // Itsimiro\OpenAI\Services\API\Results\CompletionResult
$result->getChoices(); // Choices from OpenAI.$openAI = $this->container->make(\Itsimiro\OpenAI\Services\OpenAI::class);
$result = $openAI->getDalle()->createImage(new CreateImageParameters(
'dog with a bone',
2,
responseFormat: ImageResponseFormatEnum::URL
));
$result->getImages(); // Generated imagesSee the documentation for more details on using OpenAI.
composer testPlease see CHANGELOG for more information on what has changed recently.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.