A laravel package to integrate openai in laravel application.
You can install the package via composer:
composer require itsimiro/laravel-openai
Publish 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 images
See the documentation for more details on using OpenAI.
composer test
Please 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.