I’m having a bit of trouble getting the openai-php client to work. In the example below I’ve made it very basic and am still getting a class not found error. Does anyone see anything off here?
<?php
require_once 'vendor/autoload.php';
use OpenAIClient;
$openai_token = 'sk-...';
$client = OpenAI::client($openai_token);
$result = $client->chat()->create([
'model' => 'gpt-4',
'messages' => [
['role' => 'user', 'content' => 'Hello!'],
],
]);
echo $result->choices[0]->message->content; // Hello! How can I assist you today?
The result is:
Fatal error: Uncaught Error: Class "OpenAI" not found in...
I’ve checked my Composer packages and it shows:
openai-php/client 0.8.5