PHP code example of filippo-toso / openai

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

    

filippo-toso / openai example snippets


use FilippoToso\OpenAI\OpenAI;
use FilippoToso\OpenAI\Options;

ee https://platform.openai.com/account/api-keys
    'oprganizationId' => 'your-organization-id', // @see https://platform.openai.com/account/org-settings
]);

$openAi = new OpenAI($options);

$response = $openAi->models()->list();

print_r($response->body());

return [
    
    // ...
    
    'openai' => [
        'api_key' => env('OPENAI_API_KEY'),
        'organization_id' => env('OPENAI_ORGANIZATION_ID'),
    ],   
];

use FilippoToso\OpenAI\Laravel\OpenAI;

$response = OpenAI::models()->list();

dump($response->body());

composer