OpenAI PHP Client not working

Hey guys, I’ve been trying to implement the OpenAI PHP client into my PHP web server and I really don’t know what i’m doing wrong.

API KEY created in environment variable
Depedencies are all installed on the server hosting the site.
When I go to the site, it still pronmpts HTTP500 error

CODE BELOW:

<?php $yourApiKey = getenv('YOUR_API_KEY'); $client = OpenAI::client($yourApiKey); $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?