PHP code example of itsimiro / laravel-openai

1. Go to this page and download the library: Download itsimiro/laravel-openai 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/ */

    

itsimiro / laravel-openai example snippets


$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

php artisan vendor:publish --provider="Itsimiro\OpenAI\Providers\OpenaiServiceProvider"