PHP code example of openai-php / symfony

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

    

openai-php / symfony example snippets


return [
    // ...
    OpenAI\Symfony\OpenAIBundle::class => ['all' => true],
]

$result = $container->get('openai')->completions()->create([
    'model' => 'gpt-3.5-turbo-instruct',
    'prompt' => 'PHP is',
]);

echo $result['choices'][0]['text']; // an open-source, widely-used, server-side scripting language.
bash
composer